Skip to content

Commit

Permalink
Incorporated use of different NCBI transl_tables
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalshaikh42 committed Jun 15, 2018
1 parent 8971a85 commit 12a0946
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions rand_wc_model_gen/kb_gen/genome.py
Expand Up @@ -11,6 +11,7 @@
import numpy as np
import random
from Bio.Seq import Seq
from Bio.Data import CodonTable


class GenomeGenerator(wc_kb_gen.KbComponentGenerator):
Expand All @@ -21,13 +22,14 @@ class GenomeGenerator(wc_kb_gen.KbComponentGenerator):
Options:
* num_chromosomes (:obj:`int`): number of chromosomes
* mean_gc_frac (:obj:`float`): fraction of chromosomes which are G or C
* mean_gc_frac (:obj:`float`): fraction of nucleotides which are G or C
* mean_num_genes (:obj:`float`): mean number of genes
* mean_gene_len (:obj:`float`): mean length of a gene
* mean_coding_frac (:obj:`float`): mean coding fraction of the genome
* translation_table (:obj: 'int'): The NCBI standard genetic code used
* mean_num_ncRNA (:obj: 'int'): The number of non coding RNAs
* mean_num_rRNA (:obj: 'int'): The number of ribosomal RNAs
* mean_num_tRNA (:obj: 'int'): The number of transfer RNAs
"""

def clean_and_validate_options(self):
Expand Down Expand Up @@ -88,10 +90,12 @@ def gen_components(self):

# create codon list
# TODO BILAL enable use of translation table
self.START_CODONS = ['ATG'] # start codon
self.STOP_CODONS = ['TAG', 'TAA', 'TGA'] # stop codons
self.knowledge_base.translation_table = translation_table
codon_table = self.knowledge_base.translation_table = CodonTable.unambigious_dna_by_id[
translation_table]
self.START_CODONS = codon_table.start_codons # start codons from NCBI list
self.STOP_CODONS = codon_table.stop_codons # stop codons from NCBI list
cell = self.knowledge_base.cell
gen_genome()

def gen_genome(self):
""" Creates 'synthetic' chromsome with randomized genes/intergenic regions
Expand All @@ -115,8 +119,6 @@ def gen_genome(self):
mean_coding_frac = options.get('mean_coding_frac')
num_chromosomes = options.get('num_chromosomes')

# TODO BILAL Incorporate other generation function and account start/stop

for i_chr in range(num_chromosomes):
num_genes = self.rand(gen_num / num_chromosomes)[0]
gene_lens = self.rand(gen_num, count=num_genes)
Expand Down Expand Up @@ -145,6 +147,7 @@ def gen_genome(self):
gene_starts = numpy.int64(numpy.cumsum(numpy.concatenate(([0], gene_lens[0:-1])) +
numpy.concatenate((numpy.round(intergene_lens[0:1] / 2), intergene_lens[1:]))))

# TODO: BILAL label gene loci and create objects. Determine how to pass this information to TU generation method
self.knowledge_base.cell.species_types.append(chr)

def gen_rnas_proteins(self, gen_num, indexList):
Expand Down

0 comments on commit 12a0946

Please sign in to comment.