Skip to content
Permalink
Browse files

updating for renaming of prokaryote module

  • Loading branch information
jonrkarr committed Sep 3, 2019
1 parent 8309244 commit aa0ba60ef3d77a80066744e6a44f337d1b0e651d
@@ -92,7 +92,7 @@ def gen_components(self):
numpy.concatenate((numpy.round(intergene_lens[0:1] / 2), intergene_lens[1:]))))
for i_gene in range(num_genes):
tu = cell.loci.get_or_create(id='tu_{}_{}'.format(
i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
tu.polymer = chr
tu.name = 'Transcription unit {}-{}'.format(
i_chr + 1, i_gene + 1)
@@ -102,7 +102,7 @@ def gen_components(self):
(wc_kb.core.PolymerStrand.positive, wc_kb.core.PolymerStrand.negative))

gene = cell.loci.get_or_create(id='gene_{}_{}'.format(
i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.GeneLocus)
i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.GeneLocus)
gene.polymer = chr
gene.transcription_units.append(tu)
gene.name = 'Gene {}-{}'.format(i_chr + 1, i_gene + 1)
@@ -213,7 +213,7 @@ def gen_genome(self):
# creates GeneLocus objects for the genes and labels their GeneType (which type of RNA they transcribe)
for i_gene, gene_start in enumerate(gene_starts):
gene = self.knowledge_base.cell.loci.get_or_create(
id='gene_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.GeneLocus)
id='gene_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.GeneLocus)
gene.start = gene_start + 1 # 1-indexed
gene.polymer = chro
gene.end = gene.start + gene_lens[i_gene] - 1 # 1-indexed
@@ -266,12 +266,12 @@ def gen_rnas_proteins(self):

locus = chromosome.loci[i]

if type(locus) == wc_kb.prokaryote_schema.TranscriptionUnitLocus:
if type(locus) == wc_kb.prokaryote.TranscriptionUnitLocus:
tu = locus

# creates RnaSpeciesType for RNA sequence corresponding to gene
rna = cell.species_types.get_or_create(
id='rna_{}'.format(tu.id), __type=wc_kb.prokaryote_schema.RnaSpeciesType)
id='rna_{}'.format(tu.id), __type=wc_kb.prokaryote.RnaSpeciesType)
rna.name = 'rna {}'.format(tu.id)
# GeneLocus object for gene sequence, attribute of ProteinSpeciesType object
if tu.genes[0].type == wc_kb.core.GeneType.mRna:
@@ -299,7 +299,7 @@ def gen_rnas_proteins(self):
# creates ProteinSpecipe object for corresponding protein sequence(s)
# print(gene.get_seq()[0:3])
prot = cell.species_types.get_or_create(
id='prot_{}'.format(gene.id), __type=wc_kb.prokaryote_schema.ProteinSpeciesType)
id='prot_{}'.format(gene.id), __type=wc_kb.prokaryote.ProteinSpeciesType)
prot.name = 'prot_{}'.format(gene.id)

prot.cell = cell
@@ -353,7 +353,7 @@ def gen_tus(self):

# add 3', 5' UTRs to the ends of the transcription unit (upstream of first gene, downstream of last gene)
tu = self.knowledge_base.cell.loci.get_or_create(
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
tu.name = 'tu {} {}'.format(i_chr+1, i_gene+1)

five_prime_start = gene.start - five_prime
@@ -393,7 +393,7 @@ def gen_tus(self):
if three_prime_end >= len(seq):
three_prime_end = len(seq) - 1
tu = self.knowledge_base.cell.loci.get_or_create(
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
tu.start = five_prime_start
tu.end = three_prime_end
tu.name = 'tu {} {}'.format(i_chr+1, i_gene+1)
@@ -404,7 +404,7 @@ def gen_tus(self):
else:
# print("not mrna")
tu = self.knowledge_base.cell.loci.get_or_create(
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
id='tu_{}_{}'.format(i_chr + 1, i_gene + 1), __type=wc_kb.prokaryote.TranscriptionUnitLocus)
tu.name = 'tu {} {}'.format(i_chr+1, i_gene+1)
tu.start = gene.start
tu.end = gene.end
@@ -33,7 +33,7 @@ def clean_and_validate_options(self):
assigned_trnas = options.get('assigned_trnas', default_assigned_trnas)

rnas = self.knowledge_base.cell.species_types.get(
__type=wc_kb.prokaryote_schema.RnaSpeciesType)
__type=wc_kb.prokaryote.RnaSpeciesType)

count = 0
for rna in rnas:
@@ -57,7 +57,7 @@ def clean_and_validate_options(self):
])

prots = self.knowledge_base.cell.species_types.get(
__type=wc_kb.prokaryote_schema.ProteinSpeciesType)
__type=wc_kb.prokaryote.ProteinSpeciesType)

assert(len(assigned_proteins) <= len(prots))
options['assigned_proteins'] = assigned_proteins
@@ -71,9 +71,9 @@ def gen_components(self):
assigned_proteins = self.options['assigned_proteins']

prots = self.knowledge_base.cell.species_types.get(
__type=wc_kb.prokaryote_schema.ProteinSpeciesType)
__type=wc_kb.prokaryote.ProteinSpeciesType)
rnas = self.knowledge_base.cell.species_types.get(
__type=wc_kb.prokaryote_schema.RnaSpeciesType)
__type=wc_kb.prokaryote.RnaSpeciesType)

trnas = []
for rna in rnas:
@@ -46,9 +46,9 @@ def gen_components(self):

# generate RNA
cytosol = cell.compartments.get_one(id='c')
tus = cell.loci.get(__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
tus = cell.loci.get(__type=wc_kb.prokaryote.TranscriptionUnitLocus)
for tu in tus:
rna = cell.species_types.get_or_create(id=tu.id.replace('tu_', 'rna_'), __type=wc_kb.prokaryote_schema.RnaSpeciesType)
rna = cell.species_types.get_or_create(id=tu.id.replace('tu_', 'rna_'), __type=wc_kb.prokaryote.RnaSpeciesType)
rna.transcription_units = [tu]
rna.name = tu.name.replace('Transcription unit', 'RNA')
rna.type = wc_kb.core.RnaType[tu.genes[0].type.name]
@@ -42,8 +42,8 @@ def test_run(self):
chr_len += len(chr.seq)
self.assertEqual(gc / chr_len, 1)

tus = cell.loci.get(__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
genes = cell.loci.get(__type=wc_kb.prokaryote_schema.GeneLocus)
tus = cell.loci.get(__type=wc_kb.prokaryote.TranscriptionUnitLocus)
genes = cell.loci.get(__type=wc_kb.prokaryote.GeneLocus)
self.assertAlmostEqual(len(tus), mean_num_genes, delta=5 * numpy.sqrt(mean_num_genes))
self.assertAlmostEqual(len(genes), mean_num_genes, delta=5 * numpy.sqrt(mean_num_genes))

@@ -60,7 +60,7 @@ def test_rna_props(self):
tRna = 0
sRna = 0
rnas = self.kb.cell.species_types.get(
__type=wc_kb.prokaryote_schema.RnaSpeciesType)
__type=wc_kb.prokaryote.RnaSpeciesType)

for rna in rnas:
if rna.type == wc_kb.core.RnaType.rRna:
@@ -91,16 +91,16 @@ def test_rna_props(self):
# test total number of proteins (should match number of GeneLocus objects with mRNA)
def test_rna_num(self):
rnas = self.kb.cell.species_types.get(
__type=wc_kb.prokaryote_schema.RnaSpeciesType)
__type=wc_kb.prokaryote.RnaSpeciesType)
tus = self.kb.cell.loci.get(
__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
__type=wc_kb.prokaryote.TranscriptionUnitLocus)
self.assertEqual(len(rnas), len(tus))

def test_prot_num(self):
prots = self.kb.cell.species_types.get(
__type=wc_kb.prokaryote_schema.ProteinSpeciesType)
__type=wc_kb.prokaryote.ProteinSpeciesType)
genes = self.kb.cell.loci.get(
__type=wc_kb.prokaryote_schema.GeneLocus)
__type=wc_kb.prokaryote.GeneLocus)
geneCount = 0
for gene in genes:
if gene.type == wc_kb.core.GeneType.mRna:
@@ -111,15 +111,15 @@ def test_start_codon(self):
trans_table = self.kb.translation_table
START_CODONS = CodonTable.unambiguous_dna_by_id[trans_table].start_codons

genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote_schema.GeneLocus)
genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote.GeneLocus)
for gene in genes:
if gene.type == wc_kb.core.GeneType.mRna:

self.assertIn(gene.get_seq()[0:3], START_CODONS)

def test_stop_codon(self):
trans_table = self.kb.translation_table
genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote_schema.GeneLocus)
genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote.GeneLocus)
STOP_CODONS = CodonTable.unambiguous_dna_by_id[trans_table].stop_codons
for gene in genes:
if gene.type == wc_kb.core.GeneType.mRna:
@@ -132,7 +132,7 @@ def test_prot_sites(self):
def test_length(self):
# Tests that the average length of the genes is within 3 standard deviations of the expected.

genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote_schema.GeneLocus)
genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote.GeneLocus)

sum_len = 0
for gene in genes:
@@ -146,7 +146,7 @@ def test_length(self):
# checks average lengths of 5'/3' UTRs on transcription units with mRna
def test_utrs(self):
tus = self.kb.cell.loci.get(
__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
__type=wc_kb.prokaryote.TranscriptionUnitLocus)
sum_five_prime = 0
sum_three_prime = 0
mRnaCount = 0
@@ -168,7 +168,7 @@ def test_utrs(self):

def test_operons(self):
tus = self.kb.cell.loci.get(
__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus)
__type=wc_kb.prokaryote.TranscriptionUnitLocus)
gene_sum = 0
operonCount = 0
for tu in tus:
@@ -179,7 +179,7 @@ def test_operons(self):
avg_operon_gen = gene_sum / operonCount
operon_gen_num = self.options.get('operon_gen_num')

genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote_schema.GeneLocus)
genes = self.kb.cell.loci.get(__type=wc_kb.prokaryote.GeneLocus)
geneCount = 0

for gene in genes:
@@ -197,7 +197,7 @@ def test_operons(self):

def test_protein_start_codon(self):

for protein in self.kb.cell.species_types.get(__type=wc_kb.prokaryote_schema.ProteinSpeciesType):
for protein in self.kb.cell.species_types.get(__type=wc_kb.prokaryote.ProteinSpeciesType):
seq = str(protein.get_seq())
self.assertEqual(seq[0], 'M')

@@ -207,4 +207,4 @@ def test_assignment(self):
assert (rna.type == wc_kb.core.RnaType.tRna)

protein = self.kb.cell.species_types.get(id="translation_init_factors")
assert(type(protein[0]) == wc_kb.prokaryote_schema.ProteinSpeciesType)
assert(type(protein[0]) == wc_kb.prokaryote.ProteinSpeciesType)
@@ -49,9 +49,9 @@ def test_assignment(self):
cell = self.cell

self.assertIsInstance(cell.species_types.get_one(
id='a'), wc_kb.prokaryote_schema.ProteinSpeciesType)
id='a'), wc_kb.prokaryote.ProteinSpeciesType)
self.assertIsInstance(cell.species_types.get_one(
id='x'), wc_kb.prokaryote_schema.RnaSpeciesType)
id='x'), wc_kb.prokaryote.RnaSpeciesType)

def test_observables(self):
cell = self.cell
@@ -61,6 +61,6 @@ def test_observables(self):
species = obs1.expression.species[0]
species_type = species.species_type
self.assertIsInstance(species, wc_kb.core.Species)
self.assertIsInstance(species_type, wc_kb.prokaryote_schema.ProteinSpeciesType)
self.assertIsInstance(species_type, wc_kb.prokaryote.ProteinSpeciesType)
self.assertEqual(species.id(), 'a[c]')
self.assertEqual(species_type.id, 'a')
@@ -23,7 +23,7 @@ def test(self):

tus = []
for i_tu in range(1000):
tu = cell.loci.create(__type=wc_kb.prokaryote_schema.TranscriptionUnitLocus,
tu = cell.loci.create(__type=wc_kb.prokaryote.TranscriptionUnitLocus,
id='tu_{}'.format(i_tu + 1),
name='Transcription unit {}'.format(i_tu + 1),
start=10 + 20 * (i_tu), end=20 + 20 * (i_tu), strand=wc_kb.core.PolymerStrand.positive)
@@ -36,7 +36,7 @@ def test(self):
})
gen.run()

rnas = cell.species_types.get(__type=wc_kb.prokaryote_schema.RnaSpeciesType)
rnas = cell.species_types.get(__type=wc_kb.prokaryote.RnaSpeciesType)
self.assertEqual(len(rnas), 1000)

self.assertEqual(rnas[0].transcription_units, [tus[0]])

0 comments on commit aa0ba60

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