def setUp(self): Monomer('A', ['a']) Monomer('B', ['b']) Parameter('ksynthA', 100) Parameter('ksynthB', 100) Parameter('kbindAB', 100) Parameter('A_init', 0) Parameter('B_init', 0) Initial(A(a=None), A_init) Initial(B(b=None), B_init) Observable("A_free", A(a=None)) Observable("B_free", B(b=None)) Observable("AB_complex", A(a=1) % B(b=1)) Rule('A_synth', None >> A(a=None), ksynthA) Rule('B_synth', None >> B(b=None), ksynthB) Rule('AB_bind', A(a=None) + B(b=None) >> A(a=1) % B(b=1), kbindAB) self.model = model # This timespan is chosen to be enough to trigger a Jacobian evaluation # on the various solvers. self.time = np.linspace(0, 1) self.solver = Solver(self.model, self.time, integrator='vode')
def test_integrate_with_expression(): """Ensure a model with Expressions simulates.""" Monomer('s1') Monomer('s9') Monomer('s16') Monomer('s20') # Parameters should be able to contain s(\d+) without error Parameter('ks0', 2e-5) Parameter('ka20', 1e5) Initial(s9(), Parameter('s9_0', 10000)) Observable('s1_obs', s1()) Observable('s9_obs', s9()) Observable('s16_obs', s16()) Observable('s20_obs', s20()) Expression('keff', (ks0 * ka20) / (ka20 + s9_obs)) Rule('R1', None >> s16(), ks0) Rule('R2', None >> s20(), ks0) Rule('R3', s16() + s20() >> s16() + s1(), keff) time = np.linspace(0, 40) x = odesolve(model, time)
def setUp(self): Monomer('A', ['a']) Monomer('B', ['b']) Parameter('ksynthA', 100) Parameter('ksynthB', 100) Parameter('kbindAB', 100) Parameter('A_init', 0) Parameter('B_init', 0) Initial(A(a=None), A_init) Initial(B(b=None), B_init) Observable("A_free", A(a=None)) Observable("B_free", B(b=None)) Observable("AB_complex", A(a=1) % B(b=1)) Rule('A_synth', None >> A(a=None), ksynthA) Rule('B_synth', None >> B(b=None), ksynthB) Rule('AB_bind', A(a=None) + B(b=None) >> A(a=1) % B(b=1), kbindAB) self.model = model # Convenience shortcut for accessing model monomer objects self.mon = lambda m: self.model.monomers[m] # This timespan is chosen to be enough to trigger a Jacobian evaluation # on the various solvers. self.time = np.linspace(0, 1) self.sim = ScipyOdeSimulator(self.model, tspan=self.time, integrator='vode')
def test_integrate_with_expression(): """Ensure a model with Expressions simulates.""" Monomer('s1') Monomer('s9') Monomer('s16') Monomer('s20') # Parameters should be able to contain s(\d+) without error Parameter('ks0', 2e-5) Parameter('ka20', 1e5) Initial(s9(), Parameter('s9_0', 10000)) Observable('s1_obs', s1()) Observable('s9_obs', s9()) Observable('s16_obs', s16()) Observable('s20_obs', s20()) Expression('keff', (ks0 * ka20) / (ka20 + s9_obs)) Rule('R1', None >> s16(), ks0) Rule('R2', None >> s20(), ks0) Rule('R3', s16() + s20() >> s16() + s1(), keff) time = np.linspace(0, 40) sim = ScipyOdeSimulator(model, tspan=time) simres = sim.run() keff_vals = simres.expressions['keff'] assert len(keff_vals) == len(time) assert np.allclose(keff_vals, 1.8181818181818182e-05)
def test_integrate_with_expression(): """Ensure a model with Expressions simulates.""" Monomer('s1') Monomer('s9') Monomer('s16') Monomer('s20') # Parameters should be able to contain s(\d+) without error Parameter('ks0', 2e-5) Parameter('ka20', 1e5) Initial(s9(), Parameter('s9_0', 10000)) Observable('s1_obs', s1()) Observable('s9_obs', s9()) Observable('s16_obs', s16()) Observable('s20_obs', s20()) Expression('keff', (ks0 * ka20) / (ka20 + s9_obs)) Rule('R1', None >> s16(), ks0) Rule('R2', None >> s20(), ks0) Rule('R3', s16() + s20() >> s16() + s1(), keff) time = np.linspace(0, 40) solver = Solver(model, time) solver.run() assert solver.yexpr_view.shape == (len(time), len(model.expressions_dynamic())) assert solver.yobs_view.shape == (len(time), len(model.observables))
def test_get_mp_with_grounding_2(): a1 = Agent('A', mods=[ModCondition('phosphorylation', None, None)], db_refs={'HGNC': '6840'}) a2 = Agent('A', mods=[ModCondition('phosphorylation', 'Y', '187')], db_refs={'HGNC': '6840'}) Monomer('A_monomer', ['phospho', 'T185', 'Y187'], { 'phospho': 'y', 'T185': ['u', 'p'], 'Y187': ['u', 'p'] }) Annotation(A_monomer, 'https://identifiers.org/hgnc:6840') A_monomer.site_annotations = [ Annotation(('phospho', 'y'), 'phosphorylation', 'is_modification'), Annotation(('T185', 'p'), 'phosphorylation', 'is_modification'), Annotation(('Y187', 'p'), 'phosphorylation', 'is_modification'), Annotation('T185', 'T', 'is_residue'), Annotation('T185', '185', 'is_position'), Annotation('Y187', 'Y', 'is_residue'), Annotation('Y187', '187', 'is_position') ] mps_1 = list(pa.grounded_monomer_patterns(model, a1)) assert len(mps_1) == 3 mps_2 = list(pa.grounded_monomer_patterns(model, a2)) assert len(mps_2) == 1 mp = mps_2[0] assert mp.monomer == A_monomer assert mp.site_conditions == {'Y187': ('p', WILD)}
def test_get_mp_with_grounding(): foo = Agent('Foo', db_refs={'HGNC': 'foo'}) a = Agent('A', db_refs={'HGNC': '6840'}) b = Agent('B', db_refs={'HGNC': '6871'}) Monomer('A_monomer') Monomer('B_monomer') Annotation(A_monomer, 'http://identifiers.org/hgnc/HGNC:6840') Annotation(B_monomer, 'http://identifiers.org/hgnc/HGNC:6871') mps = list(pa.grounded_monomer_patterns(model, foo)) assert len(mps) == 0 mps = list(pa.grounded_monomer_patterns(model, a)) assert len(mps) == 1 assert mps[0].monomer == A_monomer mps = list(pa.grounded_monomer_patterns(model, b)) assert len(mps) == 1 assert mps[0].monomer == B_monomer
def _get_gk_model(): SelfExporter.do_export = True Model() Monomer('DUSP6', ['mapk1']) Monomer('MAP2K1', ['mapk1']) Monomer('MAPK1', ['phospho', 'map2k1', 'dusp6'], {'phospho': ['u', 'p']}) Parameter('kf_mm_bind_1', 1e-06) Parameter('kr_mm_bind_1', 0.001) Parameter('kc_mm_phos_1', 0.001) Parameter('kf_dm_bind_1', 1e-06) Parameter('kr_dm_bind_1', 0.001) Parameter('kc_dm_dephos_1', 0.001) Parameter('DUSP6_0', 100.0) Parameter('MAP2K1_0', 100.0) Parameter('MAPK1_0', 100.0) Rule('MAP2K1_phospho_bind_MAPK1_phospho_1', MAP2K1(mapk1=None) + \ MAPK1(phospho='u', map2k1=None) >> MAP2K1(mapk1=1) % MAPK1(phospho='u', map2k1=1), kf_mm_bind_1) Rule('MAP2K1_phospho_MAPK1_phospho_1', MAP2K1(mapk1=1) % \ MAPK1(phospho='u', map2k1=1) >> MAP2K1(mapk1=None) + MAPK1(phospho='p', map2k1=None), kc_mm_phos_1) Rule( 'MAP2K1_dissoc_MAPK1', MAP2K1(mapk1=1) % MAPK1(map2k1=1) >> MAP2K1(mapk1=None) + MAPK1(map2k1=None), kr_mm_bind_1) Rule( 'DUSP6_dephos_bind_MAPK1_phospho_1', DUSP6(mapk1=None) + MAPK1(phospho='p', dusp6=None) >> DUSP6(mapk1=1) % MAPK1(phospho='p', dusp6=1), kf_dm_bind_1) Rule( 'DUSP6_dephos_MAPK1_phospho_1', DUSP6(mapk1=1) % MAPK1(phospho='p', dusp6=1) >> DUSP6(mapk1=None) + MAPK1(phospho='u', dusp6=None), kc_dm_dephos_1) Rule( 'DUSP6_dissoc_MAPK1', DUSP6(mapk1=1) % MAPK1(dusp6=1) >> DUSP6(mapk1=None) + MAPK1(dusp6=None), kr_dm_bind_1) Initial(DUSP6(mapk1=None), DUSP6_0) Initial(MAP2K1(mapk1=None), MAP2K1_0) Initial(MAPK1(phospho='u', map2k1=None, dusp6=None), MAPK1_0) SelfExporter.do_export = False return model
def add_gf_bolus(model, name: str, created_monomers: List[str]): bolus = Monomer(f'{name}_ext') Initial(bolus(), Parameter(f'{name}_0', 0.0), fixed=True) for created_monomer in created_monomers: koff = Parameter(f'{name}_{created_monomer}_koff', 0.1) kd = Parameter(f'{name}_{created_monomer}_kd', 1.0) kon = Expression(f'{name}_{created_monomer}_kon', kd * koff) Rule(f'{name}_ext_to_{created_monomer}', bolus() | model.monomers[created_monomer](inh=None), kon, koff)
def test_stop_if(): Model() Monomer('A') Rule('A_synth', None >> A(), Parameter('k', 1)) Observable('Atot', A()) Expression('exp_const', k + 1) Expression('exp_dyn', Atot + 1) sim = BngSimulator(model, verbose=5) tspan = np.linspace(0, 100, 101) x = sim.run(tspan, stop_if='Atot>9', seed=_BNG_SEED) # All except the last Atot value should be <=9 assert all(x.observables['Atot'][:-1] <= 9) assert x.observables['Atot'][-1] > 9 # Starting with Atot > 9 should terminate simulation immediately y = sim.run(tspan, initials=x.species[-1], stop_if='Atot>9') assert len(y.observables) == 1
def make_model(self, initial_conditions=True, policies=None): model = Model() # Keep track of which policies we're using self.policies = policies self.agent_set = BaseAgentSet() # Collect information about the monomers/self.agent_set from the # statements for stmt in self.statements: stmt.monomers(self.agent_set, policies=policies) # Add the monomers to the model based on our BaseAgentSet for agent_name, agent in self.agent_set.iteritems(): m = Monomer(agent_name, agent.sites, agent.site_states) model.add_component(m) # Iterate over the statements to generate rules for stmt in self.statements: stmt.assemble(model, self.agent_set, policies=policies) # Add initial conditions if initial_conditions: add_default_initial_conditions(model) return model
def make_model(self, initial_conditions=True): self.model = Model() self.agent_set = BaseAgentSet() # Collect information about the monomers/self.agent_set from the # statements self.monomers() # Add the monomers to the model based on our BaseAgentSet for agent_name, agent in self.agent_set.iteritems(): m = Monomer(agent_name, agent.sites, agent.site_states) self.model.add_component(m) for db_name, db_ref in agent.db_refs.iteritems(): a = get_annotation(m, db_name, db_ref) if a is not None: self.model.add_annotation(a) # Iterate over the statements to generate rules self.assemble() # Add initial conditions if initial_conditions: add_default_initial_conditions(self.model) return self.model
from pysb import ANY, WILD, Model, Monomer, Parameter, Expression, Initial, Observable, Rule from pysb.macros import * Model() ################################################################################################### # DNA Monomer('DNA_rpoA', ['type'], {'type': ['P1', 'RBS', 'CDS', 'T1']}) Initial(DNA_rpoA(type = 'P1'), Parameter('t0_DNA_rpoA_P1', 1)) Initial(DNA_rpoA(type = 'RBS'), Parameter('t0_DNA_rpoA_RBS', 1)) Initial(DNA_rpoA(type = 'CDS'), Parameter('t0_DNA_rpoA_CDS', 1)) Initial(DNA_rpoA(type = 'T1'), Parameter('t0_DNA_rpoA_T1', 1)) Monomer('DNA_rpoB', ['type'], {'type': ['P1', 'RBS', 'CDS', 'T1']}) Initial(DNA_rpoB(type = 'P1'), Parameter('t0_DNA_rpoB_P1', 1)) Initial(DNA_rpoB(type = 'RBS'), Parameter('t0_DNA_rpoB_RBS', 1)) Initial(DNA_rpoB(type = 'CDS'), Parameter('t0_DNA_rpoB_CDS', 1)) Monomer('DNA_rpoC', ['type'], {'type': ['RBS', 'CDS', 'T1']}) Initial(DNA_rpoC(type = 'RBS'), Parameter('t0_DNA_rpoC_RBS', 1)) Initial(DNA_rpoC(type = 'CDS'), Parameter('t0_DNA_rpoC_CDS', 1)) Initial(DNA_rpoC(type = 'T1'), Parameter('t0_DNA_rpoC_T1', 1)) Monomer('DNA_rpoD', ['type'], {'type': ['P1', 'RBS', 'CDS', 'T1']}) Initial(DNA_rpoD(type = 'P1'), Parameter('t0_DNA_rpoD_P1', 1)) Initial(DNA_rpoD(type = 'RBS'), Parameter('t0_DNA_rpoD_RBS', 1)) Initial(DNA_rpoD(type = 'CDS'), Parameter('t0_DNA_rpoD_CDS', 1)) Initial(DNA_rpoD(type = 'T1'), Parameter('t0_DNA_rpoD_T1', 1)) Monomer('DNA_rpoE', ['type'], {'type': ['P1', 'RBS', 'CDS', 'T1']}) Initial(DNA_rpoE(type = 'P1'), Parameter('t0_DNA_rpoE_P1', 1))
# exported from PySB model 'EGFR_MAPK' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, MultiState, Tag, ANY, WILD Model() Monomer('EGF', ['inh']) Monomer('EGF_ext') Monomer('EGFR', ['Y1173', 'inh'], {'Y1173': ['u', 'p']}) Monomer('ERBB2', ['Y1248', 'inh'], {'Y1248': ['u', 'p']}) Monomer('RAF1', ['S338', 'inh'], {'S338': ['u', 'p']}) Monomer('BRAF', ['S445', 'inh'], {'S445': ['u', 'p']}) Monomer('MAP2K1', ['S218', 'S222', 'inh'], { 'S218': ['u', 'p'], 'S222': ['u', 'p'] }) Monomer('MAP2K2', ['S226', 'S222', 'inh'], { 'S226': ['u', 'p'], 'S222': ['u', 'p'] }) Monomer('MAPK1', ['Y187', 'T185', 'inh'], { 'Y187': ['u', 'p'], 'T185': ['u', 'p'] }) Monomer('MAPK3', ['T202', 'Y204', 'inh'], { 'T202': ['u', 'p'], 'Y204': ['u', 'p'] }) Parameter('EGF_eq', 100.0) Parameter('EGF_0', 0.0)
# exported from PySB model 'earm.lopez_embedded' from pysb import Model, Monomer, Parameter, Rule, Observable, Initial, \ Annotation, \ MatchOnce Model() Monomer('L', ['bf']) Monomer('R', ['bf']) Monomer('DISC', ['bf']) Monomer('flip', ['bf']) Monomer('C8', ['bf', 'state'], {'state': ['pro', 'A']}) Monomer('BAR', ['bf']) Monomer('Bid', ['bf', 'state'], {'state': ['U', 'T', 'M']}) Monomer('Bax', ['bf', 's1', 's2', 'state'], {'state': ['C', 'M', 'A']}) Monomer('Bak', ['bf', 's1', 's2', 'state'], {'state': ['M', 'A']}) Monomer('Bcl2', ['bf', 'state'], {'state': ['C', 'M']}) Monomer('BclxL', ['bf', 'state'], {'state': ['C', 'M']}) Monomer('Mcl1', ['bf', 'state'], {'state': ['C', 'M']}) Monomer('Bad', ['bf', 'state'], {'state': ['C', 'M']}) Monomer('Noxa', ['bf', 'state'], {'state': ['C', 'M']}) Monomer('CytoC', ['bf', 'state'], {'state': ['M', 'C', 'A']}) Monomer('Smac', ['bf', 'state'], {'state': ['M', 'C', 'A']}) Monomer('Apaf', ['bf', 'state'], {'state': ['I', 'A']}) Monomer('Apop', ['bf']) Monomer('C3', ['bf', 'state'], {'state': ['pro', 'A', 'ub']}) Monomer('C6', ['bf', 'state'], {'state': ['pro', 'A']}) Monomer('C9', ['bf']) Monomer('PARP', ['bf', 'state'], {'state': ['U', 'C']}) Monomer('XIAP', ['bf'])
def getEa0RT(kon, koff, phi): Ea0RT = -(phi * sp.ln(koff) + (1 - phi) * sp.ln(kon)) return Ea0RT #converts thermodynamic factors into corresponding free energy modifier #Formula: Gf/RT= ln(tf) def getTGfRT(tf): tGfRT = sp.ln(tf) return tGfRT Model() #Monomer definition Monomer('R', ['r', 'i']) #RAF Monomer('I', ['r']) #RAF inhibitor #Kinetic parameters, koff /s/M, kon /s Parameter('koff_RR', 10**-1) Parameter('kon_RR', 10**-2) Parameter('koff_RI', 10**-1) Parameter('kon_RI', 10) #Thermodynamic factors, no units Parameter('f', 1) Parameter('g', 1) #Rate distribution parameter, no units Parameter('phi', 0.5) #Standard free energy of formation, kJ/mol. Expression('Gf_RR', getGfRT(kon_RR, koff_RR))
# exported from PySB model 'p53_ATR' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, ANY, WILD Model() Monomer(u'PPM1D', [u'activity'], {u'activity': [u'inactive', u'active']}) Monomer(u'TP53', [u'activity'], {u'activity': [u'inactive', u'active']}) Monomer(u'HIPK2') Monomer(u'ATR', [u'activity'], {u'activity': [u'inactive', u'active']}) Monomer(u'ARF') Monomer(u'MDM2', [u'activity'], {u'activity': [u'inactive', u'active']}) Parameter(u'kf_aa_act_1', 5e-06) Parameter(u'kf_at_act_1', 1e-06) Parameter(u'kf_tp_act_1', 1e-06) Parameter(u'kf_tm_act_1', 1e-06) Parameter(u'kf_pt_act_1', 1e-05) Parameter(u'kf_mt_act_1', 1e-06) Parameter(u'kf_hp_act_1', 1e-06) Parameter(u'kf_am_act_1', 1e-06) Parameter(u'PPM1D_0', 100.0) Parameter(u'TP53_0', 100.0) Parameter(u'HIPK2_0', 100.0) Parameter(u'ATR_0', 100.0) Parameter(u'ARF_0', 100.0) Parameter(u'MDM2_0', 100.0) Parameter(u'ATRa_0', 1.0) Observable('p53_active', TP53(activity=u'active')) Observable('atr_active', ATR(activity=u'active'))
# exported from PySB model 'model' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, ANY, WILD Model() Monomer('A', ['B', 'C']) Monomer('B', ['A', 'D']) Monomer('C', ['A']) Monomer('D', ['B']) Parameter('inhibition_0_A_inhibitor_B_inh_target_2kf_0', 1.5e-05) Parameter('inhibition_0_A_inhibitor_B_inh_target_1kr_0', 0.00012) Parameter('inhibition_0_A_inhibitor_C_inh_target_2kf_0', 4e-05) Parameter('inhibition_0_A_inhibitor_C_inh_target_1kr_0', 7e-06) Parameter('inhibition_0_B_inhibitor_D_inh_target_2kf_0', 1e-05) Parameter('inhibition_0_B_inhibitor_D_inh_target_1kr_0', 6e-06) Parameter('A_0', 200000.0) Parameter('B_0', 50000.0) Parameter('C_0', 20000.0) Parameter('D_0', 10000.0) Observable('A_obs', A()) Observable('B_obs', B()) Observable('C_obs', C()) Observable('D_obs', D()) Rule('inhibition_0_A_inhibitor_B_inh_target', A(B=None, C=None) + B(A=None, D=None) | A(B=1, C=None) % B(A=1, D=None), inhibition_0_A_inhibitor_B_inh_target_2kf_0, inhibition_0_A_inhibitor_B_inh_target_1kr_0) Rule('inhibition_0_A_inhibitor_C_inh_target', A(B=None, C=None) + C(A=None) | A(B=None, C=1) % C(A=1), inhibition_0_A_inhibitor_C_inh_target_2kf_0, inhibition_0_A_inhibitor_C_inh_target_1kr_0) Rule('inhibition_0_B_inhibitor_D_inh_target', B(A=None, D=None) + D(B=None) | B(A=None, D=1) % D(B=1), inhibition_0_B_inhibitor_D_inh_target_2kf_0, inhibition_0_B_inhibitor_D_inh_target_1kr_0)
# exported from PySB model 'FLT3_MAPK' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, MultiState, Tag, ANY, WILD Model() Monomer('FL', ['inh']) Monomer('FLT3', ['Y843', 'inh'], {'Y843': ['u', 'p']}) Monomer('HRAS', ['N', 'inh'], {'N': ['gdp', 'gtp']}) Monomer('KRAS', ['N', 'inh'], {'N': ['gdp', 'gtp']}) Monomer('NRAS', ['N', 'inh'], {'N': ['gdp', 'gtp']}) Monomer('RAF1', ['S338', 'inh'], {'S338': ['u', 'p']}) Monomer('BRAF', ['S447', 'inh'], {'S447': ['u', 'p']}) Monomer('MAP2K1', ['S222', 'S218', 'inh'], {'S222': ['u', 'p'], 'S218': ['u', 'p']}) Monomer('MAP2K2', ['S222', 'S226', 'inh'], {'S222': ['u', 'p'], 'S226': ['u', 'p']}) Monomer('MAPK1', ['T185', 'Y187', 'inh'], {'T185': ['u', 'p'], 'Y187': ['u', 'p']}) Monomer('MAPK3', ['Y204', 'T202', 'inh'], {'Y204': ['u', 'p'], 'T202': ['u', 'p']}) Parameter('FL_eq', 100.0) Parameter('FLT3_eq', 100.0) Parameter('FLT3_dephosphorylation_Y843_base_kcat', 1.0) Parameter('INPUT_FLT3_dephosphorylation_Y843_base_kcat', 0.0) Parameter('FLT3_phosphorylation_Y843_FL_kcat', 1.0) Parameter('INPUT_FLT3_phosphorylation_Y843_FL_kcat', 0.0) Parameter('HRAS_eq', 100.0) Parameter('HRAS_gdp_exchange_N_base_kcat', 1.0) Parameter('INPUT_HRAS_gdp_exchange_N_base_kcat', 0.0) Parameter('HRAS_gtp_exchange_N_FLT3__Y843_p_kcat', 1.0) Parameter('INPUT_HRAS_gtp_exchange_N_FLT3__Y843_p_kcat', 0.0) Parameter('KRAS_eq', 100.0) Parameter('KRAS_gdp_exchange_N_base_kcat', 1.0)
Parameter('mRNAdeg', 5e-4) Parameter('mRNAtrans', 1e-3) Parameter( 'kSOCS', 5E-3 ) # 4e-3 was old value #Should sufficiently separate peak pSTAT from peak SOCS Parameter('SOCSdeg', 5e-4 * 5) #Maiwald*form factor Parameter('kSOCSon', 1E-3) # = kpa Parameter( 'kSOCSoff', 5E-4 ) #1.5e-3 #Rate of SOCS unbinding ternary complex. Very fudged. Was 1.5e-3 # ============================================================================= # # Molecules # ============================================================================= Monomer('IFN_alpha2', ['r1', 'r2']) Monomer('IFNAR1', ['re', 'ri', 'loc'], {'loc': ['in', 'out']}) Monomer('IFNAR2', ['re', 'ri', 'rs', 'loc'], {'loc': ['in', 'out']}) Monomer('STAT', ['j', 'loc', 'fdbk'], {'j': ['U', 'P'], 'loc': ['Cyt', 'Nuc']}) Monomer('SOCSmRNA', ['loc', 'reg'], {'loc': ['Nuc', 'Cyt']}) Monomer('SOCS', ['site']) # ============================================================================= # # Seed Species # ============================================================================= Initial(IFN_alpha2(r1=None, r2=None), I) Initial(IFNAR1(re=None, ri=None, loc='out'), R1) Initial(IFNAR2(re=None, ri=None, rs=None, loc='out'), R2)
def add_monomer_synth_deg( m_name: str, psites: Optional[Iterable[str]] = None, nsites: Optional[Iterable[str]] = None, asites: Optional[Iterable[str]] = None, ): """ Adds the respective monomer plus synthesis rules and basal activation/deactivation rules for all activateable sites :param m_name: monomer name :param psites: phospho sites :param nsites: nucleotide sites :param asites: other activity encoding sites """ if psites is None: psites = [] else: psites = [site for psite in psites for site in psite.split('_')] if nsites is None: nsites = [] if asites is None: asites = [] sites = psites + nsites + asites m = Monomer( m_name, sites=[psite for psite in sites], site_states={ site: ['u', 'p'] if site in psites else ['gdp', 'gtp'] if site in nsites else ['inactive', 'active'] for site in sites }) kdeg = Parameter(f'{m_name}_degradation_kdeg', 1.0) t = Parameter(f'{m_name}_eq', 100.0) ksyn = Expression(f'{m_name}_synthesis_ksyn', t * kdeg) syn_rate = Expression(f'{m_name}_synthesis_rate', ksyn * get_autoencoder_modulator(t)) Rule( f'synthesis_{m_name}', None >> m( **{ site: 'u' if site in psites else 'gdp' if site in nsites else 'inactive' for site in sites }), syn_rate) deg_rate = Expression(f'{m_name}_degradation_rate', kdeg) Rule(f'degradation_{m_name}', m() >> None, deg_rate) # basal activation for sites, labels, fstate, rstate in zip( [psites, nsites, asites], [('phosphorylation', 'dephosphorylation'), ('gtp_exchange', 'gdp_exchange'), ('activation', 'deactivation')], ['p', 'gtp', 'active'], ['u', 'gdp', 'indactive']): for site in sites: kcats = [ Parameter(f'{m_name}_{label}_{site}_base_kcat', 1.0) for label in labels ] rates = [ Expression(f'{m_name}_{label}_{site}_base_rate', kcat * get_autoencoder_modulator(kcat)) for kcat, label in zip(kcats, labels) ] Rule(F'{m_name}_{site}_base', m(**{site: fstate}) | m(**{site: rstate}), *rates) return m
# exported from PySB model 'atlas_rbm.construct_model_from_metabolic_network' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, MultiState, Tag, ANY, WILD Model() Monomer( 'met', ['name', 'loc', 'dna', 'met', 'prot', 'rna'], { 'name': [ 'ACETYL_COA', 'CO_A', 'CPD_3561', 'CPD_3785', 'CPD_3801', 'D_ARABINOSE', 'Fructofuranose', 'MELIBIOSE', 'PROTON', 'WATER', '_6_Acetyl_beta_D_Galactose', 'alpha_ALLOLACTOSE', 'alpha_GALACTOSE', 'alpha_glucose', 'alpha_lactose', 'beta_ALLOLACTOSE', 'beta_GALACTOSE', 'beta_glucose', 'beta_lactose' ], 'loc': [ 'cyt', 'cytosk', 'ex', 'mem', 'per', 'wall', 'bnuc', 'cproj', 'imem', 'omem' ] }) Monomer( 'prot', ['name', 'loc', 'dna', 'met', 'prot', 'rna', 'up', 'dw'], { 'name': ['LACY_MONOMER', 'spontaneous'], 'loc': [ 'cyt', 'cytosk', 'ex', 'mem', 'per', 'wall', 'bnuc', 'cproj', 'imem', 'omem' ] }) Monomer( 'cplx', ['name', 'loc', 'dna', 'met', 'prot', 'rna', 'up', 'dw'], {
import pylab as pl import matplotlib.pyplot as plt from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, ANY, WILD Model() # Default kinetic parameters KF = 1e-6 KR = 1e-3 KC = 1 # linear proportion to the experimental data (fluorescence i think :S) IC = 10000 lp = 1000 Monomer('RAF', ['state', 'MEK'], {'state': ['I', 'A']}) Monomer('TGFa', ['EGFR']) Monomer('IGF1R', ['state', 'IGF1'], {'state': ['A', 'I']}) Monomer('IGF1', ['IGF1R']) Monomer('PI3K', ['state', 'AKT'], {'state': ['I', 'A']}) Monomer('p70S6K', ['AKT', 'p1_site', 'ERK'], {'p1_site': ['u', 'p']}) Monomer('EGFR', ['state', 'TGFa'], {'state': ['A', 'I']}) Monomer('IRS1', ['AKT', 'p1_site', 'ERK'], {'p1_site': ['u', 'p']}) Monomer('MEK', ['RAF', 'p1_site', 'ERK'], {'p1_site': ['u', 'p']}) Monomer('AKT', ['p1_site', 'p70S6K', 'IRS1', 'PI3K', 'GSK3'], {'p1_site': ['p', 'u']}) Monomer('GSK3', ['AKT', 'p1_site', 'ERK'], {'p1_site': ['u', 'p']}) Monomer('ERK', ['p1_site', 'p70S6K', 'IRS1', 'GSK3', 'MEK'], {'p1_site': ['p', 'u']}) Parameter('EGFR_A_activation_RAF_0_2kc', KC)
''' Dimerization model: A + A <> AA ''' from pysb import Model, Parameter, Monomer, Rule, Observable, Initial Model() ####### V = 100. ####### Parameter('kf', 0.001) Parameter('kr', 1.) Monomer('A', ['d']) # Rules Rule('ReversibleBinding', A(d=None) + A(d=None) | A(d=1) % A(d=1), kf, kr) #Observables Observable("A_free", A(d=None)) Observable("A_dimer", A(d=1) % A(d=1)) # Inital Conditions Parameter("A_0", 20.*V) Initial(A(d=None), A_0)
# exported from PySB model 'model' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, ANY, WILD Model() Monomer('A', ['B']) Monomer('B', ['A']) Parameter('inhibition_0_A_inhibitor_B_inh_target_2kf_0', 1.5e-05) Parameter('inhibition_0_A_inhibitor_B_inh_target_1kr_0', 0.00012) Parameter('A_0', 200000.0) Parameter('B_0', 50000.0) Observable('A_obs', A()) Observable('B_obs', B()) Rule('inhibition_0_A_inhibitor_B_inh_target', A(B=None) + B(A=None) | A(B=1) % B(A=1), inhibition_0_A_inhibitor_B_inh_target_2kf_0, inhibition_0_A_inhibitor_B_inh_target_1kr_0) Initial(A(B=None), A_0) Initial(B(A=None), B_0) Observable('AB_complex', A(B=1) % B(A=1))
# -*- coding: utf-8 -*- """ Created on Thu Oct 17 18:27:53 2019 @author: johnv """ from pysb import Model, Monomer, Parameter, Rule, Initial, Observable Model() # ------------------------------------------------------ # DEFINE MONOMERS Monomer('g', ['b']) Monomer('u') Monomer('s') Monomer('p', ['b']) # --------------------------------------------------------- # Define parameters Parameter('k_0', 1.0) # transcription rates Parameter('k_1', 40.0) Parameter('k_p', 3.0) # translation rate Parameter('beta', 2.0) # unspliced to spliced rate Parameter('d_s', 1.0) # degradation rates Parameter('d_p', 1.0)
# Based on the BioNetGen model 'localfunc.bngl' # https://github.com/RuleWorld/bionetgen/blob/master/bng2/Models2/localfunc.bngl # # This model demonstrates the use of MultiState and local functions in PySB # # Requires Python 3.x or greater (will give a SyntaxError on Python 2.7) from pysb import Model, Monomer, Parameter, Expression, Rule, \ Observable, Initial, Tag, MultiState Model() Monomer('A', ['b', 'b', 'b']) Monomer('B', ['a']) Monomer('C') Parameter('kp', 0.5) Parameter('km', 0.1) Parameter('k_synthC', 1e3) Parameter('k_degrC', 0.5) Parameter('Ab_b_b_0', 1.0) Parameter('Ba_0', 3.0) Parameter('C_0', 0.0) Observable('Atot', A()) Observable('Btot', B()) Observable('Ctot', C()) Observable('AB0', A(b=MultiState(None, None, None)), match='species') Observable('AB1', A(b=MultiState(1, None, None)) % B(a=1), match='species') Observable('AB2', A(b=MultiState(1, 2, None)) % B(a=1) % B(a=2),
def test_wildcards(): a_wild = as_complex_pattern(Monomer('A', ['b'], _export=False)(b=WILD)) b_mon = as_complex_pattern(Monomer('B', _export=None)) # B() should not match A(b=WILD) assert not match_complex_pattern(b_mon, a_wild)
# -*- coding: utf-8 -*- """ Created on Mon Dec 8 19:56:12 2014 @author: Erin """ from pysb import Model, Monomer, Parameter, Initial, Rule, Observable from pysb.macros import bind, bind_complex, catalyze Model() #Define individual species in model Monomer('COX2', ['allo', 'cat']) #Cyclooxygenase-2 enzyme Monomer('AG', ['b']) #2-arachidonoylglycerol, a substrate of COX2 Monomer('AA', ['b']) #arachidonic acid, a substrate of COX2 Monomer('PG') #Prostaglandin, product of COX2 turnover of AA Monomer('PGG') #Prostaglandin glycerol, product of COX2 turnover of 2-AG #Initial starting concentrations in micromolar Parameter('COX2_0', 15e-3) Parameter('AG_0', 16) Parameter('AA_0', 16) Parameter('PG_0', 0) Parameter('PGG_0', 0) Initial(COX2(allo=None, cat=None), COX2_0) Initial(AG(b=None), AG_0) Initial(AA(b=None), AA_0) Initial(PG(), PG_0) Initial(PGG(), PGG_0)
# exported from PySB model 'EGFR' from pysb import Model, Monomer, Parameter, Expression, Compartment, Rule, Observable, Initial, MatchOnce, Annotation, MultiState, Tag, ANY, WILD Model() Monomer('EGF', ['inh']) Monomer('EGF_ext') Monomer('ERBB2', ['Y1248', 'inh'], {'Y1248': ['u', 'p']}) Parameter('EGF_degradation_kdeg', 1.0) Parameter('EGF_eq', 100.0) Parameter('INPUT_EGF_eq', 0.0) Parameter('EGF_0', 0.0) Parameter('EGF_EGF_koff', 0.1) Parameter('EGF_EGF_kd', 1.0) Parameter('ERBB2_degradation_kdeg', 1.0) Parameter('ERBB2_eq', 100.0) Parameter('INPUT_ERBB2_eq', 0.0) Parameter('ERBB2_phosphorylation_Y1248_base_kcat', 1.0) Parameter('ERBB2_dephosphorylation_Y1248_base_kcat', 1.0) Parameter('INPUT_ERBB2_phosphorylation_Y1248_base_kcat', 0.0) Parameter('INPUT_ERBB2_dephosphorylation_Y1248_base_kcat', 0.0) Parameter('ERBB2_phosphorylation_Y1248_EGF_kcat', 1.0) Parameter('INPUT_ERBB2_phosphorylation_Y1248_EGF_kcat', 0.0) Expression('EGF_synthesis_ksyn', EGF_degradation_kdeg*EGF_eq) Expression('EGF_synthesis_rate', EGF_synthesis_ksyn*INPUT_EGF_eq) Expression('EGF_degradation_rate', EGF_degradation_kdeg) Expression('EGF_ss', EGF_synthesis_rate/EGF_degradation_rate) Expression('EGF_EGF_kon', EGF_EGF_kd*EGF_EGF_koff)