How to use the petab.get_sigmas function in petab

To help you get started, we’ve selected a few petab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ICB-DCM / pyPESTO / pypesto / petab_import / petab_import.py View on Github external
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
        )
github ICB-DCM / AMICI / python / amici / petab_import.py View on Github external
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:
        logger.log(logging.INFO, f'Observables {len(observables)}')
        logger.log(logging.INFO, f'Sigmas {len(sigmas)}')