How to use the amici.assignmentRules2observables function in amici

To help you get started, we’ve selected a few amici 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 / AMICI / tests / testPYSB.py View on Github external
modelModulePYSB = importlib.import_module(outdir_pysb)
        model_pysb = modelModulePYSB.getModel()

        edata = get_data(model_pysb)

        rdata_pysb = get_results(model_pysb, edata)

        # -------------- SBML -----------------

        sbmlFile = os.path.join(os.path.dirname(__file__), '..', 'python',
                                'examples', 'example_presimulation',
                                'model_presimulation.xml')

        sbmlImporter = amici.SbmlImporter(sbmlFile)

        observables = amici.assignmentRules2observables(
            sbmlImporter.sbml,  # the libsbml model object
            filter_function=lambda variable: variable.getName() == 'pPROT_obs'
        )
        outdir_sbml = 'test_model_presimulation_sbml'
        sbmlImporter.sbml2amici('test_model_presimulation_sbml',
                                outdir_sbml,
                                verbose=False,
                                observables=observables,
                                constantParameters=constant_parameters)
        sys.path.insert(0, outdir_sbml)
        modelModuleSBML = importlib.import_module(outdir_sbml)
        model_sbml = modelModuleSBML.getModel()

        rdata_sbml = get_results(model_sbml, edata)

        # check if preequilibration fixed parameters are correctly applied:
github ICB-DCM / AMICI / tests / testSBML.py View on Github external
def test_steadystate_import(self):
        sbmlFile = os.path.join(os.path.dirname(__file__), '..', 'python',
                                'examples', 'example_steadystate',
                                'model_steadystate_scaled.xml')
        sbmlImporter = amici.SbmlImporter(sbmlFile)

        observables = amici.assignmentRules2observables(
            sbmlImporter.sbml,
            filter_function=lambda variable:
            variable.getId().startswith('observable_') and
            not variable.getId().endswith('_sigma')
        )

        outdir = 'test_model_steadystate_scaled'
        sbmlImporter.sbml2amici('test_model_steadystate_scaled',
                                outdir,
                                observables=observables,
                                constantParameters=['k0'],
                                sigmas={'observable_x1withsigma':
                                            'observable_x1withsigma_sigma'})

        sys.path.insert(0, outdir)
        import test_model_steadystate_scaled as model_module
github ICB-DCM / AMICI / tests / testSBML.py View on Github external
def test_likelihoods(self):
        """
        Test the custom noise distributions used to define cost functions.
        """
        def assert_fun(x):
            return self.assertTrue(x)

        sbmlFile = os.path.join(os.path.dirname(__file__), '..', 'python',
                                'examples', 'example_steadystate',
                                'model_steadystate_scaled.xml')
        sbmlImporter = amici.SbmlImporter(sbmlFile)

        observables = amici.assignmentRules2observables(
            sbmlImporter.sbml,
            filter_function=lambda variable:
                variable.getId().startswith('observable_') and
                not variable.getId().endswith('_sigma')
        )

        # assign different noise models

        obs_keys = list(observables.keys())

        # exponentiate observable formulas
        obs1 = observables[obs_keys[1]]
        obs3 = observables[obs_keys[3]]
        obs1['formula'] = '10^(' + obs1['formula'] + ')'
        obs3['formula'] = 'exp(' + obs3['formula'] + ')'
github ICB-DCM / AMICI / tests / testPandas.py View on Github external
def setUp(self):
        self.default_path = copy.copy(sys.path)
        self.resetdir = os.getcwd()

        if os.path.dirname(__file__) != '':
            os.chdir(os.path.dirname(__file__))

        sbmlFile = os.path.join(os.path.dirname(__file__), '..', 'python',
                                'examples', 'example_presimulation',
                                'model_presimulation.xml')

        sbmlImporter = amici.SbmlImporter(sbmlFile)

        constantParameters = ['DRUG_0', 'KIN_0']

        observables = amici.assignmentRules2observables(
            sbmlImporter.sbml,  # the libsbml model object
            filter_function=lambda variable: variable.getName() == 'pPROT'
        )
        outdir = 'test_model_presimulation'
        sbmlImporter.sbml2amici('test_model_presimulation',
                                outdir,
                                verbose=False,
                                observables=observables,
                                constantParameters=constantParameters)
        sys.path.insert(0, outdir)
        import test_model_presimulation as modelModule
        self.model = modelModule.getModel()
        self.model.setTimepoints(np.linspace(0, 60, 61))
        self.solver = self.model.getSolver()
        rdata = amici.runAmiciSimulation(self.model, self.solver)
        self.edata = [amici.ExpData(rdata, 0.01, 0)]
github ICB-DCM / AMICI / tests / testSBML.py View on Github external
def test_presimulation(self):
        def assert_fun(x):
            return self.assertTrue(x)

        sbmlFile = os.path.join(os.path.dirname(__file__), '..', 'python',
                                'examples', 'example_presimulation',
                                'model_presimulation.xml')

        sbmlImporter = amici.SbmlImporter(sbmlFile)

        constantParameters = ['DRUG_0', 'KIN_0']

        observables = amici.assignmentRules2observables(
            sbmlImporter.sbml,  # the libsbml model object
            filter_function=lambda variable: variable.getName() == 'pPROT_obs'
        )
        outdir = 'test_model_presimulation'
        sbmlImporter.sbml2amici('test_model_presimulation',
                                outdir,
                                verbose=False,
                                observables=observables,
                                constantParameters=constantParameters)
        sys.path.insert(0, outdir)
        import test_model_presimulation as modelModule
        model = modelModule.getModel()
        solver = model.getSolver()
        solver.setNewtonMaxSteps(0)
        model.setTimepoints(np.linspace(0, 60, 61))
        model.setSteadyStateSensitivityMode(