def test_unnamed_parameters(self): """ If there's a parameter without a name, we should use its id as a name instead. """ model = SBML() model.load_file("input/goodwin3.xml") params = model.get_all_param() self.assertEqual(len(params), 4)
def test_definition_of_sbml_parameters(self): """ Tests if the priors have the correct parameter names of the sbml model. """ model = SBML() model.load_file("input/model1.xml") theta = define_sbml_params_priors(model, 'input/model1.priors') sbml_parameters = model.get_all_param() for t in theta.get_model_parameters(): assert (t.name in sbml_parameters)
def test_with_sbml(self): """ Tests if the module can define the prior of sbml parameters. """ model = SBML() model.load_file("input/model1.xml") theta = define_sbml_params_priors(model, 'input/model1.priors') self.assertEqual(theta.get_size() - 1, len(model.get_all_param())) sigma = theta.get_experimental_error() assert (sigma > 0)
def test_get_original_name_with_id(self): """ If there's a parameter without a name, when you call get_original_param_name you should get the parameter's id. """ model = SBML() model.load_file("input/goodwin3.xml") params = model.get_all_param() names = [] for p in params: original_name = model.get_original_param_name(p) names.append(original_name) assert ("m" in names) assert ("k1" in names) assert ("k2" in names) assert ("k3" in names)
from lxml import etree parser = argparse.ArgumentParser() parser.add_argument("model", help="SBML file with model definition") parser.add_argument ("output_file", help="A file to output the priors "\ + "sketch file.") args = parser.parse_args() sbml_file = args.model output_file = args.output_file sbml = SBML() sbml.load_file(sbml_file) original_names = [sbml.get_original_param_name (p) for p in \ sbml.get_all_param ()] priors_names = list(set(original_names)) priors_elm = etree.Element("priors") for param_name in priors_names: param_elm = etree.SubElement(priors_elm, "prior") param_elm.set("distribution", "?") param_elm.set("a", "?") param_elm.set("b", "?") param_elm.set("name", param_name) exp_error_elm = etree.SubElement(priors_elm, "experimental_error") exp_error_elm.set("distribution", "?") exp_error_elm.set("a", "?") exp_error_elm.set("b", "?") exp_error_elm.set("name", "Noise") tree = etree.ElementTree(priors_elm)
"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) parameter_regex = re.compile (r"Current theta: \[(.*)\]") f = open (trace_file) theta = None