<commit_before>import os
import unittest

import sys

import PyFBA

test_file_loc = ''
if os.path.exists('tests/roles.txt'):
    test_file_loc = 'tests'
elif os.path.exists('PyFBA/tests/roles.txt'):
    test_file_loc = 'PyFBA/tests'

media_file_loc = ''
if os.path.exists('../media/ArgonneLB.txt'):
    media_file_loc = '../media'
elif os.path.exists('media/ArgonneLB.txt'):
    media_file_loc = 'media'
elif 'PYFBA_MEDIA_DIR' in os.environ and os.path.exists(os.path.join(os.environ['PYFBA_MEDIA_DIR'], 'ArgonneLB.txt')):
    media_file_loc = os.environ['PYFBA_MEDIA_DIR']
else:
    sys.stderr.write("No media found. Can't proceed with testing the FBA.\n")
    sys.stderr.write("You can specify the media location by setting the PYFBA_MEDIA_DIR environment variable\n")


class TestFBA(unittest.TestCase):
    modeldata = PyFBA.parse.model_seed.parse_model_seed_data('gramnegative', verbose=True)
    media = PyFBA.parse.pyfba_media("ArgonneLB")

    def setUp(self):
        """
        This is run before everything else
        """

    def test_external_reactions(self):
        """Testing the fba external reactions"""
        compounds = self.__class__.modeldata.compounds
        # create a few external compounds
        cpds = list(compounds)[0:10]
        model_cpds = set()
        for c in cpds:
            new_comp = PyFBA.metabolism.CompoundWithLocation.from_compound(c, 'e')
            model_cpds.add(new_comp)

        upsec = PyFBA.fba.uptake_and_secretion_reactions(model_cpds, self.__class__.media)
        self.assertEqual(len(upsec), 10)

        # now remove them and see there is nothing left<commit_msg>Ensuring the parsed media is used<commit_after>import os
import unittest

import sys

import PyFBA

test_file_loc = ''
if os.path.exists('tests/roles.txt'):
    test_file_loc = 'tests'
elif os.path.exists('PyFBA/tests/roles.txt'):
    test_file_loc = 'PyFBA/tests'

media_file_loc = ''
if os.path.exists('../media/ArgonneLB.txt'):
    media_file_loc = '../media'
elif os.path.exists('media/ArgonneLB.txt'):
    media_file_loc = 'media'
elif 'PYFBA_MEDIA_DIR' in os.environ and os.path.exists(os.path.join(os.environ['PYFBA_MEDIA_DIR'], 'ArgonneLB.txt')):
    media_file_loc = os.environ['PYFBA_MEDIA_DIR']
else:
    sys.stderr.write("No media found. Can't proceed with testing the FBA.\n")
    sys.stderr.write("You can specify the media location by setting the PYFBA_MEDIA_DIR environment variable\n")


class TestFBA(unittest.TestCase):
    modeldata = PyFBA.parse.model_seed.parse_model_seed_data('gramnegative', verbose=True)
    media = PyFBA.parse.pyfba_media("ArgonneLB", modeldata)

    def setUp(self):
        """
        This is run before everything else
        """

    def test_external_reactions(self):
        """Testing the fba external reactions"""
        compounds = self.__class__.modeldata.compounds
        # create a few external compounds
        cpds = list(compounds)[0:10]
        model_cpds = set()
        for c in cpds:
            new_comp = PyFBA.metabolism.CompoundWithLocation.from_compound(c, 'e')
            model_cpds.add(new_comp)

        upsec = PyFBA.fba.uptake_and_secretion_reactions(model_cpds, self.__class__.media)
        self.assertEqual(len(upsec), 10)

        # now remove them and see there is nothing left
{'fraction_non_alphanumeric': 0.11637800060771802, 'fraction_numerical': 0.003038590094196293, 'mean_word_length': 3.491132332878581, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3589302', 'n_tokens_mistral': 1131, 'n_tokens_neox': 1104, 'n_words': 229}