Esempio n. 1
0
    def test_configpossiblechecker(self):
        #Test is SBML string can be converted with this module
        #Checker is at the start of sbmltoconfig function
        Biomodels_ID = 'BIOMD0000000012'  #Represillator Model

        onlinemodelstr = onlinegen.get_online_biomodel(Biomodels_ID)
        onlinegen.configpossiblechecker(onlinemodelstr)
Esempio n. 2
0
    def test_compare_equations_fail(self):
        #Typo in Reaction 10 where it generates PX instead of X
        antimony_str_fail = '''
        // Reactions:
          Reaction1: X => ; kd_mRNA*X;
          Reaction2: Y => ; kd_mRNA*Y;
          Reaction3: Z => ; kd_mRNA*Z;
          Reaction4:  => PX; k_tl*X;
          Reaction5:  => PY; k_tl*Y;
          Reaction6:  => PZ; k_tl*Z;
          Reaction7: PX => ; kd_prot*PX;
          Reaction8: PY => ; kd_prot*PY;
          Reaction9: PZ => ; kd_prot*PZ;
          Reaction10:  => PX; a0_tr + a_tr*KM^n/(KM^n + PZ^n);
          Reaction11:  => Y; a0_tr + a_tr*KM^n/(KM^n + PX^n);
          Reaction12:  => Z; a0_tr + a_tr*KM^n/(KM^n + PY^n);

         '''
        reaction_test = onlinegen.gen_reactions(antimony_str_fail)
        eqn_clean = ['']

        before = len(reaction_test)
        after = 0
        while before != after:
            before = len(reaction_test)
            reaction_test = onlinegen.clean_reactions(reaction_test)
            after = len(reaction_test)

        for eqn in reaction_test:
            eqn = onlinegen.eqnreplace(eqn)
            eqn_clean.append(eqn)

        assert eqn_clean == eqn_sample, 'Reactions not sorted properly'

        return reaction_test, eqn_clean
Esempio n. 3
0
    def test_compare_equations(self):
        #Tests whether reactions pertaining to the same species are combined
        global eqn_sample
        antimony_str_test = '''
        // Reactions:
          Reaction1: X => ; kd_mRNA*X;
          Reaction2: Y => ; kd_mRNA*Y;
          Reaction3: Z => ; kd_mRNA*Z;
          Reaction4:  => PX; k_tl*X;
          Reaction5:  => PY; k_tl*Y;
          Reaction6:  => PZ; k_tl*Z;
          Reaction7: PX => ; kd_prot*PX;
          Reaction8: PY => ; kd_prot*PY;
          Reaction9: PZ => ; kd_prot*PZ;
          Reaction10:  => X; a0_tr + a_tr*KM^n/(KM^n + PZ^n);
          Reaction11:  => Y; a0_tr + a_tr*KM^n/(KM^n + PX^n);
          Reaction12:  => Z; a0_tr + a_tr*KM^n/(KM^n + PY^n);

        '''
        reaction_test = onlinegen.gen_reactions(antimony_str_test)
        print(reaction_test)
        eqn_clean = ['']

        before = len(reaction_test)
        after = 0
        while before != after:
            before = len(reaction_test)
            reaction_test = onlinegen.clean_reactions(reaction_test)
            after = len(reaction_test)

        for eqn in reaction_test:
            eqn = onlinegen.eqnreplace(eqn)
            eqn_clean.append(eqn)

        assert eqn_clean == eqn_sample, 'Reactions not sorted properly'
Esempio n. 4
0
    def test_missingparameterunit_fail(self):
        #missing unit parameter t_ave

        parametersunits_dict_fail = {
            'beta': 'per_sec',
            'alpha0': 'per_sec',
            'alpha': 'per_sec',
            'eff': 'per_sec',
            'n': 'per_sec',
            'KM': 'per_sec',
            'tau_mRNA': 'per_sec',
            'tau_prot': 'per_sec',
            'kd_mRNA': 'per_sec',
            'kd_prot': 'per_sec',
            'k_tl': 'per_sec',
            'a_tr': 'per_sec',
            'ps_a': 'per_sec',
            'ps_0': 'per_sec',
            'a0_tr': 'per_sec',
        }
        settings_test = {
            "Species": species_dict,
            "parameters": parameter_dict,
            "units": parametersunits_dict_fail,
            "equations": equations,
            "description": description_store
        }

        testconfig = onlinegen.gen_config(settings_test, system_type, tspan)
import BMSS.models.setup_sim        as sm
import BMSS.simulation       as sim

    
if __name__ == '__main__':
    
    '''
    Use following function to create SBML from BIOModel online database
    Outputs both the sbmlstring and the XML file
    '''
    
    Biomodels_ID    = 'BIOMD0000000012' 
    #Input biomodels ID number
    SBMLfilename    = 'Repressilator_TestModel_SBML.xml' #Name the XML file
    outputpath      = str(Path.cwd()/SBMLfilename)
    onlinemodelstr  = onlinegen.get_online_biomodel(Biomodels_ID, outputfile=outputpath)
    antimony_str        = te.sbmlToAntimony(onlinemodelstr)
    
    
    '''
    Use the following function to create SBML from local folder.
    XML file must be in same folder as this Tutorial
    '''
    
    inputpath       = str(Path.cwd()/'Repressilator_TestModel_SBML_1.xml')
    with open(inputpath, 'r', encoding='utf8', errors='ignore') as f:
        localmodelstr = f.read()
    
      
    '''
    To create config ini file from SBML file in folder
Esempio n. 6
0
    def test_configpossiblechecker_fail(self):
        #SBML string is too complex for module
        Biomodels_ID = 'MODEL1606100000'  #Model too complicated to convert

        onlinemodelstr = onlinegen.get_online_biomodel(Biomodels_ID)
        onlinegen.configpossiblechecker(onlinemodelstr)
Esempio n. 7
0
 def test_tspanchecker_fail_3(self):
     #Start time larger than end time
     tspan = '[6000, 600, 61]'
     onlinegen.tspanchecker(tspan)
Esempio n. 8
0
 def test_tspanchecker_fail_2(self):
     #Missing ']' at end of tspan
     tspan = '0, 600, 61]'
     onlinegen.tspanchecker(tspan)
Esempio n. 9
0
 def test_tspanchecker_fail_1(self):
     #Missing '[' at start of tspan
     tspan = '0, 600, 61]'
     onlinegen.tspanchecker(tspan)
Esempio n. 10
0
 def test_tspanchecker(self):
     #Check if tspan has been declared correctly
     #Checker is at the start of sbmltoconfig function
     tspan = '[0, 600, 61]'
     onlinegen.tspanchecker(tspan)
Esempio n. 11
0
    def test_makesampleconfig(self):
        testconfig = onlinegen.gen_config(settings_test, system_type, tspan)

        assert testconfig == sampleconfig, 'Config Statements are not the same'
Esempio n. 12
0
    "description": description_store,
    "reference": reference_store,
    "species_parameter_descriptions": species_parameter_descriptions
}

eqn_sample = [
    '', '  dPX = +(k_tl*X) -(kd_prot*PX)', '  dPY = +(k_tl*Y) -(kd_prot*PY)',
    '  dPZ = +(k_tl*Z) -(kd_prot*PZ)',
    '  dX = +(a0_tr + a_tr*KM**n/(KM**n + PZ**n)) -(kd_mRNA*X)',
    '  dY = +(a0_tr + a_tr*KM**n/(KM**n + PX**n)) -(kd_mRNA*Y)',
    '  dZ = +(a0_tr + a_tr*KM**n/(KM**n + PY**n)) -(kd_mRNA*Z)'
]

Biomodels_ID = 'BIOMD0000000012'  #Represillator Model
output_path = tempfile.gettempdir()
onlinemodelstr = onlinegen.get_online_biomodel(Biomodels_ID)
sampleconfig, settings_sample = onlinegen.sbmltoconfig(onlinemodelstr,
                                                       system_type, tspan,
                                                       Model_name, output_path)


class TestConfigGen:
    def test_makesampleconfig(self):
        testconfig = onlinegen.gen_config(settings_test, system_type, tspan)

        assert testconfig == sampleconfig, 'Config Statements are not the same'

    def test_compare_equations(self):
        #Tests whether reactions pertaining to the same species are combined
        global eqn_sample
        antimony_str_test = '''