How to use the amici.pysb2amici 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
# amici part

                outdir = pysb_model.name

                if pysb_model.name in ['move_connected_amici']:
                    self.assertRaises(
                        Exception,
                        amici.pysb2amici,
                        *[pysb_model, outdir],
                        **{'verbose': False, 'compute_conservation_laws': True}
                    )
                    compute_conservation_laws = False
                else:
                    compute_conservation_laws = True

                amici.pysb2amici(
                    pysb_model,
                    outdir,
                    verbose=False,
                    compute_conservation_laws=compute_conservation_laws
                )
                sys.path.insert(0, outdir)

                amici_model_module = importlib.import_module(pysb_model.name)

                model_pysb = amici_model_module.getModel()

                model_pysb.setTimepoints(tspan)

                solver = model_pysb.getSolver()
                solver.setMaxSteps(int(1e5))
                solver.setAbsoluteTolerance(atol)
github ICB-DCM / AMICI / tests / testPYSB.py View on Github external
sim = ScipyOdeSimulator(
                    pysb_model,
                    tspan=tspan,
                    integrator_options={'rtol': rtol, 'atol': atol},
                    compiler='python'
                )
                pysb_simres = sim.run()

                # amici part

                outdir = pysb_model.name

                if pysb_model.name in ['move_connected_amici']:
                    self.assertRaises(
                        Exception,
                        amici.pysb2amici,
                        *[pysb_model, outdir],
                        **{'verbose': False, 'compute_conservation_laws': True}
                    )
                    compute_conservation_laws = False
                else:
                    compute_conservation_laws = True

                amici.pysb2amici(
                    pysb_model,
                    outdir,
                    verbose=False,
                    compute_conservation_laws=compute_conservation_laws
                )
                sys.path.insert(0, outdir)

                amici_model_module = importlib.import_module(pysb_model.name)
github ICB-DCM / AMICI / tests / testCPP.py View on Github external
self.default_path = copy.copy(sys.path)

        pysb.SelfExporter.cleanup()  # reset pysb
        pysb.SelfExporter.do_export = True

        sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..',
                                        'python', 'examples',
                                        'example_presimulation'))
        if 'createModelPresimulation' in sys.modules:
            importlib.reload(sys.modules['createModelPresimulation'])
            model_module = sys.modules['createModelPresimulation']
        else:
            model_module = importlib.import_module('createModelPresimulation')
        model = copy.deepcopy(model_module.model)
        model.name = 'test_model_presimulation_pysb'
        amici.pysb2amici(model,
                         model.name,
                         verbose=False,
                         observables=['pPROT_obs'],
                         constant_parameters=['DRUG_0', 'KIN_0'])
        sys.path.insert(0, model.name)
        import test_model_presimulation_pysb as modelModulePYSB
        self.model = modelModulePYSB.getModel()
        self.solver = self.model.getSolver()
github ICB-DCM / AMICI / tests / testPreequilibration.py View on Github external
pysb.SelfExporter.cleanup()  # reset pysb
        pysb.SelfExporter.do_export = True

        sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..',
                                        'python', 'examples',
                                        'example_presimulation'))
        if 'createModelPresimulation' in sys.modules:
            importlib.reload(sys.modules['createModelPresimulation'])
            model_module = sys.modules['createModelPresimulation']
        else:
            model_module = importlib.import_module('createModelPresimulation')

        model = copy.deepcopy(model_module.model)
        model.name = 'test_model_presimulation_pysb'
        outdir = model.name
        amici.pysb2amici(model,
                         outdir,
                         verbose=False,
                         observables=['pPROT_obs'],
                         constant_parameters=['DRUG_0', 'KIN_0'])
        sys.path.insert(0, outdir)
        modelModulePYSB = importlib.import_module(outdir)

        self.model = modelModulePYSB.getModel()
        self.model.setReinitializeFixedParameterInitialStates(True)

        self.solver = self.model.getSolver()
        self.solver.setSensitivityOrder(amici.SensitivityOrder_first)
        self.solver.setSensitivityMethod(amici.SensitivityMethod_forward)

        self.edata = get_data(self.model)
        self.edata.t_presim = 2
github ICB-DCM / AMICI / tests / testPYSB.py View on Github external
pysb.SelfExporter.cleanup()  # reset pysb
        pysb.SelfExporter.do_export = True

        sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..',
                                        'python', 'examples',
                                        'example_presimulation'))
        if 'createModelPresimulation' in sys.modules:
            importlib.reload(sys.modules['createModelPresimulation'])
            model_module = sys.modules['createModelPresimulation']
        else:
            model_module = importlib.import_module('createModelPresimulation')
        model = copy.deepcopy(model_module.model)
        model.name = 'test_model_presimulation_pysb'
        outdir_pysb = model.name
        amici.pysb2amici(model,
                         outdir_pysb,
                         verbose=False,
                         observables=['pPROT_obs'],
                         constant_parameters=constant_parameters)
        sys.path.insert(0, outdir_pysb)
        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',