def setUp (self):
     sbml = SBML ()
     sbml.load_file ('input/simple_enzymatic.xml')
     self.__model = sbml_to_odes (sbml)
     self.__experiments = ExperimentSet ('input/simple_enzymatic.data')
     self.__theta_priors = define_sbml_params_priors (sbml, 
             'input/simple_enzymatic.priors')
Exemple #2
0
def run_task (model_file, priors_file, experiment_file, \
        iterations_phase1, sigma_update_n, iterations_phase2, \
        iterations_phase3, nof_process, signetms_path, seed=42):
    # pylint: disable=reimported
    import time
    start_time = time.time()
    # importing local modules...
    sys.path.insert(0, signetms_path)
    from model.SBML import SBML
    from experiment.ExperimentSet import ExperimentSet
    from model.SBMLtoODES import sbml_to_odes
    from marginal_likelihood.MarginalLikelihood \
            import MarginalLikelihood
    from model.PriorsReader import define_sbml_params_priors
    import seed_manager

    # Now the actual code...
    seed_manager.set_seed(seed)
    sbml = SBML()
    sbml.load_file(model_file)
    odes = sbml_to_odes(sbml)
    experiments = ExperimentSet(experiment_file)
    theta_priors = define_sbml_params_priors(sbml, priors_file)
    ml = MarginalLikelihood (iterations_phase1,
                             sigma_update_n,
                             iterations_phase2,
                             iterations_phase3, 20, 2, \
                             verbose=False, n_process=nof_process)
    log_l = ml.estimate_marginal_likelihood(experiments, odes, theta_priors)
    elapsed_time = time.time() - start_time
    return log_l, elapsed_time
Exemple #3
0
    def test_sbml_to_odes (self):
        """ Tests if you can create an ODES object from an SBML model. 
        """
        model = SBML ()
        model.load_file ("input/model2.xml")
        odes = sbml_to_odes (model)
        t = [0, .1, .2]
        y = odes.evaluate_on ([0])
        self.assertListEqual (y["EGF"], [0])
        self.assertListEqual (y["ERK"], [10000])

        t = [0, .1, .2]
        y = odes.evaluate_on (t)
Exemple #4
0
def perform_marginal_likelihood (sbml_file, priors_file, \
        experiment_file, burnin1_iterations, sigma_update_n, \
        burnin2_iterations, sampling_iterations, verbose=False, \
        n_process=0, sample_output_file=None, seed=0):
    print  ("Performing marginal likelihood calculations of model: " + \
            sbml_file)
    sbml = SBML()
    sbml.load_file(sbml_file)
    odes = sbml_to_odes(sbml)
    experiments = ExperimentSet(experiment_file)
    theta_priors = define_sbml_params_priors(sbml, priors_file)
    seed_manager.set_seed(seed)

    ml = MarginalLikelihood (burnin1_iterations,
            sigma_update_n,
            burnin2_iterations,
            sampling_iterations, 20, 2, \
            verbose=verbose, n_process=n_process)
    log_l = ml.estimate_marginal_likelihood(experiments, odes, theta_priors)
    ml.print_sample(output_file=sample_output_file)
    print("log_l = " + str(log_l))
    return log_l
Exemple #5
0
# Prints all chemical reactions defined in an SBML file
import sys
import os
current_path = os.path.abspath(__file__)
sys.path.insert(0, '/'.join(current_path.split('/')[:-2]))
import argparse
from model.SBML import SBML
from model.SBMLtoODES import sbml_to_odes

parser = argparse.ArgumentParser()
parser.add_argument("model", help="SBML file with model definition.")
args = parser.parse_args()

sbml_file = args.model
sbml = SBML()
sbml.load_file(sbml_file)
odes = sbml_to_odes(sbml)
odes.print_equations()
Exemple #6
0
from experiment.ExperimentSet import ExperimentSet


if len (sys.argv) != 4:
    print ("Usage: " + sys.argv[0] + " trace_file model_file " + \
            "experiment_file")
    exit()

trace_file = sys.argv[1] 
model_file = sys.argv[2]
experiment_file = sys.argv[3]

# define model
sbml = SBML ()
sbml.load_file (model_file)
ode = sbml_to_odes (sbml)
ode.print_equations ()

# get param names
param_names = []
for param in sbml.get_all_param ():
    param_names.append (param)

# experiment info
exp_set = ExperimentSet (experiment_file)
experiment_times = exp_set[-1].times
experiment_measure = exp_set[-1].measure_expression
experiment_observations = []
for exp in exp_set:
    obs = exp.values
    experiment_observations.append (obs)