How to use the tellurium.loada function in tellurium

To help you get started, we’ve selected a few tellurium 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 sys-bio / tellurium / examples / notebooks-py / tellurium_plotting.py View on Github external
# coding: utf-8

# Back to the main [Index](../index.ipynb)

# #### Draw diagram

# In[1]:

#!!! DO NOT CHANGE !!! THIS FILE WAS CREATED AUTOMATICALLY FROM NOTEBOOKS !!! CHANGES WILL BE OVERWRITTEN !!! CHANGE CORRESPONDING NOTEBOOK FILE !!!
from __future__ import print_function
import tellurium as te

r = te.loada('''
model feedback()
   // Reactions:http://localhost:8888/notebooks/core/tellurium_export.ipynb#
   J0: $X0 -> S1; (VM1 * (X0 - S1/Keq1))/(1 + X0 + S1 +   S4^h);
   J1: S1 -> S2; (10 * S1 - 2 * S2) / (1 + S1 + S2);
   J2: S2 -> S3; (10 * S2 - 2 * S3) / (1 + S2 + S3);
   J3: S3 -> S4; (10 * S3 - 2 * S4) / (1 + S3 + S4);
   J4: S4 -> $X1; (V4 * S4) / (KS4 + S4);

  // Species initializations:
  S1 = 0; S2 = 0; S3 = 0;
  S4 = 0; X0 = 10; X1 = 0;

  // Variable initialization:
  VM1 = 10; Keq1 = 10; h = 10; V4 = 2.5; KS4 = 0.5;
end''')
github sys-bio / tellurium / tests / test_tellurium.py View on Github external
def test_loada(self):
        rr = te.loada('''
            model example0
              S1 -> S2; k1*S1
              S1 = 10
              S2 = 0
              k1 = 0.1
            end
        ''')
        self.assertIsNotNone(rr.getModel())
github sys-bio / tellurium / examples / notebooks-py / tellurium_examples.py View on Github external
plt.ylim ((0,10))
r.plot(m1);


# ### Gene network

# In[7]:

import tellurium as te
import numpy

# Model desribes a cascade of two genes. First gene is activated
# second gene is repressed. Uses events to change the input 
# to the gene regulatory network

r = te.loada ('''
    v1:  -> P1; Vm1*I^4/(Km1 + I^4);
    v2:  P1 -> ; k1*P1;
    v3:  -> P2;  Vm2/(Km2 + P1^4);
    v4:  P2 -> ; k2*P2;
    
    at (time > 60): I = 10;
    at (time > 100): I = 0.01;
    Vm1  = 5; Vm2 = 6; Km1 = 0.5; Km2 = 0.4;
    k1 = 0.1; k2 = 0.1;
    I = 0.01;
''')

result = r.simulate (0, 200, 100)
r.plot(result);
github sys-bio / tellurium / examples / notebooks-py / model_consecutiveUniUniReactions.py View on Github external
# coding: utf-8

# Back to the main [Index](../index.ipynb)

# ### Consecutive UniUni reactions using first-order mass-action kinetics
# Model creation and simulation of a simple irreversible chain of reactions S1 -> S2 -> S3 -> S4.

# In[1]:

#!!! DO NOT CHANGE !!! THIS FILE WAS CREATED AUTOMATICALLY FROM NOTEBOOKS !!! CHANGES WILL BE OVERWRITTEN !!! CHANGE CORRESPONDING NOTEBOOK FILE !!!
from __future__ import print_function
import tellurium as te

r = te.loada('''
  model pathway()
    S1 -> S2; k1*S1
    S2 -> S3; k2*S2
    S3 -> S4; k3*S3

    # Initialize values
    S1 = 5; S2 = 0; S3 = 0; S4 = 0;
    k1 = 0.1;  k2 = 0.55; k3 = 0.76
  end
''')

result = r.simulate(0, 20, 51)
te.plotArray(result);
github sys-bio / tellurium / tellurium / sedml / tephrasedml.py View on Github external
warnings.warn("No phrasedml string selected, defaulting to first phrasedml.")
            else:
                raise IOError('No phrasedmlStr selected.')

        rePath = r"(\w*).load\('(.*)'\)"
        # reLoad = r"(\w*) = roadrunner.RoadRunner\(\)"

        # model info from phrasedml
        modelsource, modelname = self._modelInfoFromPhrasedml(phrasedmlStr)
        print('Model source:', modelsource)
        # print('Model name:', modelname)

        # find index of antimony str
        antIndex = None
        for k, antStr in enumerate(self.antimonyList):
            r = te.loada(antStr)
            modelName = r.getModel().getModelName()
            if modelName == modelsource:
                antIndex = k
        if antIndex is None:
            raise Exception("Cannot find the model name referenced in the PhraSEDML string")

        phrasedml.setReferencedSBML(modelsource, te.antimonyToSBML(self.antimonyList[antIndex]))
        sedmlstr = phrasedml.convertString(phrasedmlStr)
        if sedmlstr is None:
            raise Exception(phrasedml.getLastPhrasedError())

        phrasedml.clearReferencedSBML()
        f = tempfile.NamedTemporaryFile('w', suffix=".sedml")
        f.write(sedmlstr)
        f.flush()
        pysedml = tesedml.sedmlToPython(f.name)
github sys-bio / tellurium / examples / tellurium-files / nonUnitStoichiometries.py View on Github external
# -*- coding: utf-8 -*-
"""
Example of Non-unit Stoichiometries.
"""
from __future__ import print_function
import tellurium as te

model = '''
  model pathway()
    S1 + S2 -> 2 S3; k1*S1*S2
    3 S3 -> 4 S4 + 6 S5; k2*S3^3
    k1 = 0.1;k2 = 0.1;
  end
'''
r = te.loada(model)
print(r)
github sys-bio / tellurium / examples / tellurium-files / parameterscan / plot_multi_array.py View on Github external
"""
Plot multi array.
"""
from __future__ import print_function, division
import tellurium as te

model = '''
    $Xo -> S1; vo;
    S1 -> S2; k1*S1 - k2*S2;
    S2 -> $X1; k3*S2;
    
    vo = 1
    k1 = 2; k2 = 0; k3 = 3;
'''

rr = te.loada(model)
p = te.ParameterScan(rr,
    startTime = 0,
    endTime = 20,
    numberOfPoints = 50,
    width = 2,
    title = 'Cell',
    selection = ['Time', 'S1', 'S2']
)
p.plotMultiArray('k1', [1, 1.5, 2], 'k3', [.5, 1, 1.5])
github sys-bio / tellurium / examples / tellurium-files / parameterscan / steadystatescan.py View on Github external
import tellurium as te
from roadrunner import Config

Config.setValue(Config.LOADSBMLOPTIONS_CONSERVED_MOIETIES, True) 

model = '''
    $Xo -> S1; vo;
    S1 -> S2; k1*S1 - k2*S2;
    S2 -> $X1; k3*S2;
    
    vo = 1
    k1 = 2; k2 = 0; k3 = 3;
'''

    
rr = te.loada(model)

p = te.SteadyStateScan(rr,
    value='k3',
    startValue=2,
    endValue=3,
    numberOfPoints=20,
    selection=['S1', 'S2']                                     
)
p.plotArray()

Config.setValue(Config.LOADSBMLOPTIONS_CONSERVED_MOIETIES, False)
github sys-bio / tellurium / tellurium / tecombine.py View on Github external
def fromAntimony(cls, antimonyStr, location, master=None):
        """ Create SBMLAsset from antimonyStr
        :param antimonyStr:
        :type antimonyStr:
        :param location:
        :type location:
        :return:
        :rtype:
        """
        warnings.warn('Use inline_omex instead.', DeprecationWarning)
        r = te.loada(antimonyStr)
        raw = r.getSBML()
        return cls.fromRaw(raw=raw, location=location, filetype='sbml', master=master)
github sys-bio / tellurium / examples / notebooks-py / steadystate_scan.py View on Github external
# ### Steady state scan
# Using `te.ParameterScan.SteadyStateScan` for scanning the steady state.

# In[1]:

#!!! DO NOT CHANGE !!! THIS FILE WAS CREATED AUTOMATICALLY FROM NOTEBOOKS !!! CHANGES WILL BE OVERWRITTEN !!! CHANGE CORRESPONDING NOTEBOOK FILE !!!
from __future__ import print_function
import tellurium as te
import matplotlib.pyplot as plt
import tellurium as te
import numpy as np
from roadrunner import Config

Config.setValue(Config.LOADSBMLOPTIONS_CONSERVED_MOIETIES, True) 

r = te.loada('''
    $Xo -> S1; vo;
    S1 -> S2; k1*S1 - k2*S2;
    S2 -> $X1; k3*S2;
    
    vo = 1
    k1 = 2; k2 = 0; k3 = 3;
''')

p = te.SteadyStateScan(r,
    value = 'k3',
    startValue = 2,
    endValue = 3,
    numberOfPoints = 20,
    selection = ['S1', 'S2']                      
)
p.plotArray()