Skip to content

Commit

Permalink
single translation reaction
Browse files Browse the repository at this point in the history
  • Loading branch information
balazs1987 committed Aug 28, 2018
1 parent 5df8919 commit e401652
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 186 deletions.
6 changes: 3 additions & 3 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
component_generators=[prokaryote.CompartmentsGenerator,
prokaryote.ParametersGenerator,
prokaryote.MetabolismSubmodelGenerator,
prokaryote.TranscriptionSubmodelGenerator]).run()
prokaryote.TranscriptionSubmodelGenerator,
prokaryote.TranslationSubmodelGenerator]).run()

model.id = 'rand_kb'
model.version = '0.0.1'

wc_lang.io.Writer().run(model,'/media/sf_VM_share/models/rand_model_test2.xlsx', set_repo_metadata_from_path=False)
model2 = wc_lang.io.Reader().run('/media/sf_VM_share/models/rand_model_test2.xlsx')
wc_lang.io.Writer().run(model,'/media/sf_VM_share/models/rand_model_test.xlsx', set_repo_metadata_from_path=False)
1 change: 1 addition & 0 deletions wc_model_gen/prokaryote/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .metabolism import MetabolismSubmodelGenerator
from .rna_degradation import RnaDegradationSubmodelGenerator
from .transcription import TranscriptionSubmodelGenerator
from .translation import TranslationSubmodelGenerator
from .protein_degradation import ProteinDegradationSubmodelGenerator
from .compartments import CompartmentsGenerator
from .parameters import ParametersGenerator
1 change: 0 additions & 1 deletion wc_model_gen/prokaryote/rna_degradation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import wc_model_gen
from wc_model_gen.prokaryote.species import SpeciesGenerator


class RnaDegradationSubmodelGenerator(wc_model_gen.SubmodelGenerator):
""" Generator for RNA degradation submodel """

Expand Down
70 changes: 28 additions & 42 deletions wc_model_gen/prokaryote/transcription.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,18 @@ def gen_reactions(self):
""" Generate reactions associated with submodel """
model = self.model
submodel = self.submodel
cell = self.knowledge_base.cell
cytosol = model.compartments.get_one(id='c')
atp = model.species_types.get_one(
id='atp').species.get_one(compartment=cytosol)
ctp = model.species_types.get_one(
id='ctp').species.get_one(compartment=cytosol)
gtp = model.species_types.get_one(
id='gtp').species.get_one(compartment=cytosol)
utp = model.species_types.get_one(
id='utp').species.get_one(compartment=cytosol)
ppi = model.species_types.get_one(
id='ppi').species.get_one(compartment=cytosol)
h2o = model.species_types.get_one(
id='h2o').species.get_one(compartment=cytosol)
h = model.species_types.get_one(
id='h').species.get_one(compartment=cytosol)

cell = self.knowledge_base.cell
rna_polymerase = model.observables.get_one(id='rna_polymerase_obs').expression.species[0]
atp = model.species_types.get_one(id='atp').species.get_one(compartment=cytosol)
ctp = model.species_types.get_one(id='ctp').species.get_one(compartment=cytosol)
gtp = model.species_types.get_one(id='gtp').species.get_one(compartment=cytosol)
utp = model.species_types.get_one(id='utp').species.get_one(compartment=cytosol)
ppi = model.species_types.get_one(id='ppi').species.get_one(compartment=cytosol)
h2o = model.species_types.get_one(id='h2o').species.get_one(compartment=cytosol)
h = model.species_types.get_one(id='h').species.get_one(compartment=cytosol)

kb_rnas = cell.species_types.get(__type=wc_kb.RnaSpeciesType)
for kb_rna in kb_rnas:
if kb_rna.id.startswith('rna_'):
Expand All @@ -64,26 +59,21 @@ def gen_reactions(self):
id='transcription_'+str(kb_rna.id))
rxn.name = 'Transcription '+str(kb_rna.name)

model_rna = model.species_types.get_one(
id=kb_rna.id).species.get_one(compartment=cytosol)
model_rna = model.species_types.get_one(id=kb_rna.id).species.get_one(compartment=cytosol)
seq = kb_rna.get_seq()
rxn.participants = []
rxn.participants.add(atp.species_coefficients.get_or_create(
coefficient=-seq.count('A')))
rxn.participants.add(ctp.species_coefficients.get_or_create(
coefficient=-seq.count('C')))
rxn.participants.add(gtp.species_coefficients.get_or_create(
coefficient=-seq.count('G')))
rxn.participants.add(utp.species_coefficients.get_or_create(
coefficient=-seq.count('U')))
rxn.participants.add(h.species_coefficients.get_or_create(
coefficient=-(kb_rna.get_len() - 1)))
rxn.participants.add(
model_rna.species_coefficients.get_or_create(coefficient=1))
rxn.participants.add(ppi.species_coefficients.get_or_create(
coefficient=kb_rna.get_len()))
rxn.participants.add(h2o.species_coefficients.get_or_create(
coefficient=kb_rna.get_len() - 1))

rxn.participants.add(rna_polymerase.species_coefficients.get_or_create(coefficient=-1))
rxn.participants.add(atp.species_coefficients.get_or_create(coefficient=-seq.count('A')))
rxn.participants.add(ctp.species_coefficients.get_or_create(coefficient=-seq.count('C')))
rxn.participants.add(gtp.species_coefficients.get_or_create(coefficient=-seq.count('G')))
rxn.participants.add(utp.species_coefficients.get_or_create(coefficient=-seq.count('U')))
rxn.participants.add(h.species_coefficients.get_or_create(coefficient=-(kb_rna.get_len() - 1)))

rxn.participants.add(rna_polymerase.species_coefficients.get_or_create(coefficient=1))
rxn.participants.add(model_rna.species_coefficients.get_or_create(coefficient=1))
rxn.participants.add(ppi.species_coefficients.get_or_create(coefficient=kb_rna.get_len()))
rxn.participants.add(h2o.species_coefficients.get_or_create(coefficient=kb_rna.get_len() - 1))

def gen_rate_laws(self):
""" Generate rate laws associated with submodel """
Expand All @@ -103,19 +93,15 @@ def gen_rate_laws(self):
rate_law = reaction.rate_laws.create()
rate_law.direction = wc_lang.RateLawDirection.forward
rate_law_equation = wc_lang.RateLawEquation()

rate_law_equation.modifiers.append(rna_polymerase.expression.species[0])
expression = 'k_cat*({}/(k_m + {})'.format(rna_polymerase.expression.species[0].get_id(),
rna_polymerase.expression.species[0].get_id())
expression = expression.rstrip()
expression = 'k_cat*'

for participant in reaction.participants:
if participant.coefficient < 0:
rate_law_equation.modifiers.append(participant.species)
expression += '*({}/(k_m+{})'.format(
participant.species.id(),
participant.species.id())
expression = expression.rstrip()
expression += '({}/({}+(3/2)*{})*'.format(participant.species.id(),
participant.species.id(),
participant.species.concentration.value)

expression = expression[:-1] #clip off trailing * character
rate_law_equation.expression = expression
rate_law.equation = rate_law_equation
Loading

0 comments on commit e401652

Please sign in to comment.