<commit_before>import contextlib
import os
import random
import requests
import string
import subprocess
import tempfile
import time

from Bio import Phylo
import pylab


def encode_for_clustal(name):
    return name.replace(' ', '_')


def unfuck_clustal_name(name):
    return name.replace('_', ' ')


@contextlib.contextmanager
def tempname():
    name = '/tmp/' + ''.join(random.choice(string.ascii_letters) for _ in range(20))

    yield name

    try:
        os.remove(name)
    except FileNotFoundError:
        pass


def get_tree_desc(phylogeny_input):
    with open(phylogeny_input) as infile:
        data = infile.read()

        response = requests.post(
            'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/run/',
            headers={
                'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
            },
            params={
                'email': '<EMAIL>',
                'sequence': data,
            }
        )
        assert response.status_code == 200
        job_id = response.text

        while True:
            response = requests.get(
                'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/status/%s' % job_id,
            )
            if response.text == 'FINISHED':
                break

            time.sleep(1)

        response = requests.get(
            'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/result/%s/tree' % job_id,
        )
        assert response.status == 200
        tree_desc = response.text

        return tree_desc


def get_tree_bytes(pairs):
    with tempfile.NamedTemporaryFile(mode='w') as clustal_input, \
            tempname() as phylogeny_input:
        for name, sequence in pairs:
            clustal_input.write('> %s\n%s\n\n' % (encode_for_clustal(name), sequence))
        clustal_input.flush()

        subprocess.check_call([<commit_msg>Update phylotree<commit_after>import contextlib
import os
import random
import requests
import string
import subprocess
import tempfile
import time

from Bio import Phylo
import pylab


def encode_for_clustal(name):
    return name.replace(' ', '_')


def unfuck_clustal_name(name):
    return name.replace('_', ' ')


@contextlib.contextmanager
def tempname():
    name = '/tmp/' + ''.join(random.choice(string.ascii_letters) for _ in range(20))

    yield name

    try:
        os.remove(name)
    except FileNotFoundError:
        pass


def get_tree_desc(phylogeny_input):
    with open(phylogeny_input) as infile:
        data = infile.read()

        response = requests.post(
            'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/run/',
            headers={
                'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
            },
            params={
                'email': '<EMAIL>',
                'sequence': data,
            }
        )
        assert response.status_code == 200
        job_id = response.text

        while True:
            response = requests.get(
                'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/status/%s' % job_id,
            )
            print('Status: %s' % response.text)
            if response.text == 'FINISHED':
                break

            time.sleep(1)

        response = requests.get(
            'http://www.ebi.ac.uk/Tools/services/rest/simple_phylogeny/result/%s/tree' % job_id,
        )
        assert response.status_code == 200
        tree_desc = response.text

        return tree_desc


def get_tree_bytes(pairs):
    with tempfile.NamedTemporaryFile(mode='w') as clustal_input, \
            tempname() as phylogeny_input:
        for name, sequence in pairs:
            clustal_input.write('> %s\n%s\n\n' % (encode_for_clustal(name), sequence))
        clustal_input.flush()

        subprocess.check_call([
{'fraction_non_alphanumeric': 0.11446409989594172, 'fraction_numerical': 0.005202913631633715, 'mean_word_length': 2.1184103811841037, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5431715', 'n_tokens_mistral': 1223, 'n_tokens_neox': 1159, 'n_words': 229}