Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# delete output directory
if os.path.exists(self.output_folder):
shutil.rmtree(self.output_folder)
# init sbml importer
sbml_importer = amici.SbmlImporter(self.petab_problem.sbml_file)
# constant parameters
condition_columns = self.petab_problem.condition_df.columns.values
constant_parameter_ids = list(
set(condition_columns) - {'conditionId', 'conditionName'}
)
# observables
observables = petab.get_observables(sbml_importer.sbml)
# sigmas
sigmas = petab.get_sigmas(sbml_importer.sbml)
# convert
sbml_importer.sbml2amici(
modelName=self.petab_problem.model_name,
output_dir=self.output_folder,
observables=observables,
constantParameters=constant_parameter_ids,
sigmas=sigmas
)
model_output_dir = os.path.join(os.getcwd(), model_name)
if verbose:
logger.log(logging.INFO,
f"{Fore.GREEN}Importing model '{sbml_file}' "
f"using fixed parameters file '{condition_file}'")
logger.log(logging.INFO,
f"{Fore.GREEN}Model name is '{model_name}' "
f"Writing model code to '{model_output_dir}'")
sbml_importer = amici.SbmlImporter(sbml_file)
sbml_model = sbml_importer.sbml
show_model_info(sbml_model)
observables = petab.get_observables(sbml_importer.sbml, remove=True)
sigmas = petab.get_sigmas(sbml_importer.sbml, remove=True)
measurement_df = petab.get_measurement_df(measurement_file)
noise_distrs = petab_noise_distributions_to_amici(
petab.get_noise_distributions(measurement_df))
# Replace observables in assignment
import sympy as sp
for observable_id, formula in sigmas.items():
repl = sp.sympify(formula).subs(observable_id,
observables[observable_id]['formula'])
sigmas[observable_id] = str(repl)
if verbose: