<commit_before>#!/usr/bin/env python

import requests
import misc
from pprint import pprint

baseUrl = 'http://www.ebi.ac.uk/ena/'
lengthLimit = 100000


def get_results(verbose=True):
    """Return the list of results in ENA as a dictionary with the key being the
    result id and the value the result description

    verbose: boolean to define the printing info
    """
    results = misc.get_results("data/ena_domain_results.csv")
    if verbose:
        pprint(results)
    return results


def check_display(display):
    """Check if display is in the list of display in ENA

    display: display to check
    """
    expectedDisplay = ["html", "xml", "text", "fasta", "fastq", "dwc"]
    if display not in expect_display:
        err_str = "The display value does not correspond to a possible display"
        err_str += "value in ENA"
        raise ValueError(err_str)


def check_download(download):
    """Check if download is in the list of download format in ENA

    download: download format to check
    """
    expectedDownload = ["gzip", "txt"]
    if download not in expectedDownload:
        err_str = "The download value does not correspond to a possible "
        err_str += "display value in ENA"
        raise ValueError(err_str)


def check_result(result):
    """Check if result is in the list of possible results in ENA

    result: id of result to check
    """
    possible_results = get_results(verbose=False)
    if result not in possible_results:
        err_str = "The result value (%s) does not correspond to a " % (result)
        err_str += "possible result value in ENA"
        raise ValueError(err_str)


def check_length(length):
    """Check if length is below the maximum length

    length: length value to test
    """
    if length >= lengthLimit:
        err_str = "The length value (%s) is higher than the " % (length)
        err_str += "limit length (%s)" % (lengthLimit)
        raise ValueError(err_str)


def get_graphical_image(ids, featureRange, sequenceRange):
    url = baseUrl + "data/view/graphics/" 

def retrieve_data(
    ids, display, download = None, file = None, offset = 0, length = 100000, 
    range = None, expanded = None, res_range = None, header = None):
    url = baseUrl + "data/view/"

    check_display(display)
    
<commit_msg>Load serialized data<commit_after>#!/usr/bin/env python

import requests
import pickle
from pprint import pprint

baseUrl = 'http://www.ebi.ac.uk/ena/'
lengthLimit = 100000


def load_object(filepath):
    """Load object from a pickle file

    filepath: path to pickle file with serialized data
    """
    with open(filepath, 'rb') as input:
        obj = pickle.load(input)
    return obj


def get_results(verbose=True):
    """Return the list of results in ENA as a dictionary with the key being the
    result id and the value the result description

    verbose: boolean to define the printing info
    """
    results = load_object("data/result_description")
    if verbose:
        for result in results:
            print("%s: %s" % (result, results[result]["description"]))
    return results


def check_display(display):
    """Check if display is in the list of display in ENA

    display: display to check
    """
    expectedDisplay = ["html", "xml", "text", "fasta", "fastq", "dwc"]
    if display not in expect_display:
        err_str = "The display value does not correspond to a possible display"
        err_str += "value in ENA"
        raise ValueError(err_str)


def check_download(download):
    """Check if download is in the list of download format in ENA

    download: download format to check
    """
    expectedDownload = ["gzip", "txt"]
    if download not in expectedDownload:
        err_str = "The download value does not correspond to a possible "
        err_str += "display value in ENA"
        raise ValueError(err_str)


def check_result(result):
    """Check if result is in the list of possible results in ENA

    result: id of result to check
    """
    possible_results = get_results(verbose=False)
    if result not in possible_results:
        err_str = "The result value (%s) does not correspond to a " % (result)
        err_str += "possible result value in ENA"
        raise ValueError(err_str)


def check_length(length):
    """Check if length is below the maximum length

    length: length value to test
    """
    if length >= lengthLimit:
        err_str = "The length value (%s) is higher than the " % (length)
        err_str += "limit length (%s)" % (lengthLimit)
        raise ValueError(err_str)


def get_graphical_image(ids, featureRange, sequenceRange):
    url = baseUrl + "data/view/graphics/" 


def retrieve_data(
    ids, display, download = None, file = None, offset = 0, length = 100000, 
    range = None, expanded = None, res_range = None, header = None):
    url = baseUrl + "data/view/"

    check_display(display)
    

{'fraction_non_alphanumeric': 0.09417040358744394, 'fraction_numerical': 0.005299633102323685, 'mean_word_length': 3.0386831275720163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2809788', 'n_tokens_mistral': 1441, 'n_tokens_neox': 1384, 'n_words': 544}