Skip to content
Permalink
Browse files

reduced genetic code

  • Loading branch information
balazs1987 committed Sep 14, 2018
1 parent 95222af commit cc920167f3328e7f43f2cdf33bda49a9a035a99f
Showing with 37 additions and 20 deletions.
  1. +0 −18 wc_kb_gen/core.py
  2. +34 −2 wc_kb_gen/random/genome.py
  3. +3 −0 wc_kb_gen/random/observables.py
@@ -79,24 +79,6 @@ def run(self):
options = component_options.get(component_generator.__name__, {})
component_generator(kb, options=options).run()

# Experimental code to ensure reduced genetic code
bases = "TCAG"
codons = [a + b + c for a in bases for b in bases for c in bases]
dna = kb.cell.species_types.get(__type = wc_kb.core.DnaSpeciesType)[0]
seq_str = str(dna.seq)
seq_list = list(seq_str)

for prot in kb.cell.species_types.get(__type = wc_kb.prokaryote_schema.ProteinSpeciesType):
for base_num in range(prot.gene.start+2,prot.gene.end-3,3):
new_codon = random.choice(['ATC', 'CTG', 'ATG', 'ACG'])
seq_list[base_num]=new_codon[0]
seq_list[base_num+1]=new_codon[1]
seq_list[base_num+2]=new_codon[2]

seq_str_new = ''.join(seq_list)
dna.seq=Seq(seq_str_new)
# End of genetic code reduction

return kb

class KbComponentGenerator(object):
@@ -12,6 +12,8 @@
import scipy.constants
import wc_kb
import wc_kb_gen
from Bio.Seq import Seq, Alphabet
import random
import numpy
from numpy import random
from Bio.Seq import Seq, Alphabet
@@ -125,15 +127,17 @@ def clean_and_validate_options(self):
options['mean_half_life'] = mean_half_life

# disabeled while playing w transcription only models
# num_tRNA = options.get('num_tRNA', 20)
num_tRNA = options.get('num_tRNA', 20)
options['num_tRNA'] = num_tRNA

# assert(num_tRNA >= 20)
# options['num_tRNA'] = num_tRNA
#assert((num_ncRNA + num_rRNA + num_tRNA + min_prots) <= mean_num_genes)

def gen_components(self):
self.gen_genome()
self.gen_tus()
self.gen_rnas_proteins()
self.reduce_model()

def gen_genome(self):
'''Construct knowledge base components and generate the DNA sequence'''
@@ -411,6 +415,34 @@ def gen_rnas_proteins(self):
prot.half_life = 1
prot.concentration = rna.concentration

def reduce_model(self):
options = self.options
genetic_code = options.get('genetic_code')

if genetic_code=='normal':
pass

elif genetic_code=='reduced':
cell = self.knowledge_base.cell
kb = self.knowledge_base

bases = "TCAG"
codons = [a + b + c for a in bases for b in bases for c in bases]

dna = kb.cell.species_types.get(__type = wc_kb.core.DnaSpeciesType)[0]
seq_str = str(dna.seq)
seq_list = list(seq_str)

for prot in kb.cell.species_types.get(__type = wc_kb.prokaryote_schema.ProteinSpeciesType):
for base_num in range(prot.gene.start+2,prot.gene.end-3,3):
new_codon = random.choice(['ATC', 'CTG', 'ATG', 'ACG'])
seq_list[base_num]=new_codon[0]
seq_list[base_num+1]=new_codon[1]
seq_list[base_num+2]=new_codon[2]

seq_str_new = ''.join(seq_list)
dna.seq=Seq(seq_str_new)

def rand(self, mean, count=1, min=0, max=numpy.inf):
""" Generated 1 or more random normally distributed integer(s) with standard deviation equal
to the square root of the mean value.
@@ -71,11 +71,14 @@ def gen_components(self):
prots = self.knowledge_base.cell.species_types.get(__type=wc_kb.prokaryote_schema.ProteinSpeciesType)
rnas = self.knowledge_base.cell.species_types.get(__type=wc_kb.prokaryote_schema.RnaSpeciesType)

print('here')
trnas = []
for rna in rnas:
if rna.type == wc_kb.RnaType.tRna:
trnas.append(rna)

print(trnas)

if genetic_code=='normal':
codons = {
'I': ['ATT', 'ATC', 'ATA'],

0 comments on commit cc92016

Please sign in to comment.
You can’t perform that action at this time.