class RegulatoryElementLocus(core.PolymerLocus): """ Knowledge of a regulatory element of a gene Attributes: type (:obj:`RegulatoryElementType`): type of regulatory element activity (:obj:`ActivityLevel`): cell-type specific activity level bound_start (:obj:`int`): start coordinate of binding bound_end (:obj:`int`): end coordinate of binding motif_features (:obj:`list` of :obj:`ProteinSpeciesType`): proteins that bind to the site Related attributes: regulatory_modules (:obj:`list` of :obj:`RegulatoryModule`): regulatory_modules """ type = obj_model.EnumAttribute(RegulatoryElementType) activity = obj_model.EnumAttribute(ActivityLevel) bound_start = obj_model.PositiveIntegerAttribute() bound_end = obj_model.PositiveIntegerAttribute() motif_features = obj_model.ManyToManyAttribute( 'ProteinSpeciesType', related_name='regulatory_elements') class Meta(obj_model.Model.Meta): attribute_order = ('id', 'polymer', 'name', 'type', 'activity', 'start', 'end', 'bound_start', 'bound_end', 'motif_features', 'comments', 'references', 'database_references')
class RegulatoryModule(obj_model.Model): """ Knowledge about regulatory modules Attributes: gene (:obj:`GeneLocus`): gene regulatory_elements (:obj:`list` of :obj:`RegulatoryElementLocus`): regulatory elements comments (:obj:`str`): comments references (:obj:`list` of :obj:`Reference`): references database_references (:obj:`list` of :obj:`DatabaseReference`): database references """ gene = obj_model.OneToOneAttribute(GeneLocus, related_name='regulatory_modules') regulatory_elements = obj_model.ManyToManyAttribute( RegulatoryElementLocus, related_name='regulatory_modules') comments = obj_model.LongStringAttribute() references = obj_model.ManyToManyAttribute( core.Reference, related_name='regulatory_modules') database_references = core.DatabaseReferenceAttribute( related_name='regulatory_modules') class Meta(obj_model.Model.Meta): attribute_order = ('gene', 'regulatory_elements', 'comments', 'references', 'database_references')
class TranscriptionUnitLocus(core.PolymerLocus): """ Knowledge about an open reading frame Attributes: promoter (:obj:`PromoterLocus`): promoter controlling the TU genes (:obj:`list` of :obj:`GeneLocus`): genes """ promoter = obj_model.ManyToOneAttribute('PromoterLocus', related_name='transcription_units') genes = obj_model.ManyToManyAttribute('GeneLocus', related_name='transcription_units') class Meta(obj_model.Model.Meta): attribute_order = ('id', 'polymer', 'name', 'strand', 'promoter', 'start', 'end', 'genes', 'comments', 'references', 'database_references') def get_3_prime(self): """ Get the 3' coordinate Returns: :obj:`int`: 3' coordinate """ if self.strand == core.PolymerStrand.positive: return self.end else: return self.start def get_5_prime(self): """ Get the 5' coordinate Returns: :obj:`int`: 5' coordinate """ if self.strand == core.PolymerStrand.positive: return self.start else: return self.end
class RnaSpeciesType(core.PolymerSpeciesType): """ Knowledge of an RNA species Attributes: transcription_units (:obj:`list` of :obj:`TranscriptionUnitLocus`): transcription units type (:obj:`RnaType`): type Related attributes: proteins (:obj:`list` of :obj:`ProteinSpeciesType`): protein(s) """ transcription_units = obj_model.ManyToManyAttribute( 'TranscriptionUnitLocus', related_name='rna') type = obj_model.EnumAttribute(core.RnaType) class Meta(obj_model.Model.Meta): attribute_order = ('id', 'name', 'type', 'transcription_units', 'circular', 'double_stranded', 'half_life', 'comments', 'references', 'database_references') def get_seq(self): """ Get the sequence Returns: :obj:`Bio.Seq.Seq`: sequence """ tu_start = self.transcription_units[0].start tu_end = self.transcription_units[0].end dna_seq = self.transcription_units[0].polymer.get_subseq( start=tu_start, end=tu_end) return dna_seq.transcribe() def get_empirical_formula(self): """ Get the empirical formula for an RNA transcript with * 5' monophosphate * Deprotonated phosphate oxygens :math:`N_A * AMP + N_C * CMP + N_G * GMP + N_U * UMP - (L-1) * OH` Returns: :obj:`chem.EmpiricalFormula`: empirical formula """ seq = self.get_seq() n_a = seq.count('A') n_c = seq.count('C') n_g = seq.count('G') n_u = seq.count('U') l = len(seq) formula = chem.EmpiricalFormula() formula.C = 10 * n_a + 9 * n_c + 10 * n_g + 9 * n_u formula.H = 12 * n_a + 12 * n_c + 12 * n_g + 11 * n_u - (l - 1) formula.N = 5 * n_a + 3 * n_c + 5 * n_g + 2 * n_u formula.O = 7 * n_a + 8 * n_c + 8 * n_g + 9 * n_u - (l - 1) formula.P = n_a + n_c + n_g + n_u return formula def get_charge(self): """ Get the charge for a transcript with * 5' monophosphate * Deprotonated phosphate oxygens :math:`-L - 1` Returns: :obj:`int`: charge """ return -self.get_len() - 1 def get_mol_wt(self): """ Get the molecular weight for a transcript with * 5' monophosphate * Deprotonated phosphate oxygens Returns: :obj:`float`: molecular weight (Da) """ return self.get_empirical_formula().get_molecular_weight()
class TranscriptSpeciesType(core.PolymerSpeciesType): """ Knowledge of a transcript (spliced RNA) species Attributes: rna (:obj:`RnaSpeciesType`): transcribed RNA species before splicing exons (:obj:`list` of :obj:`ExonLocus`): exons Related attributes: protein (:obj:`ProteinSpeciesType`): protein """ rna = obj_model.ManyToOneAttribute(PreRnaSpeciesType, related_name='transcripts') exons = obj_model.ManyToManyAttribute(ExonLocus, related_name='transcripts') class Meta(obj_model.Model.Meta): attribute_order = ('id', 'name', 'rna', 'exons', 'half_life', 'comments', 'references', 'database_references') def get_seq(self): """ Get the 5' to 3' sequence Returns: :obj:`Bio.Seq.Seq`: sequence """ dna_seq = '' for exon in self.exons: dna_seq += self.rna.gene.polymer.get_subseq(start=exon.start, end=exon.end) if self.rna.gene.strand == core.PolymerStrand.negative: dna_seq = dna_seq.reverse_complement() return dna_seq.transcribe() def get_empirical_formula(self): """ Get the empirical formula for a transcript (spliced RNA) species with * 5' monophosphate * Deprotonated phosphate oxygens :math:`N_A * AMP + N_C * CMP + N_G * GMP + N_U * UMP - (L-1) * OH` Returns: :obj:`chem.EmpiricalFormula`: empirical formula """ seq = self.get_seq() n_a = seq.count('A') n_c = seq.count('C') n_g = seq.count('G') n_u = seq.count('U') l = len(seq) formula = chem.EmpiricalFormula() formula.C = 10 * n_a + 9 * n_c + 10 * n_g + 9 * n_u formula.H = 12 * n_a + 12 * n_c + 12 * n_g + 11 * n_u - (l - 1) formula.N = 5 * n_a + 3 * n_c + 5 * n_g + 2 * n_u formula.O = 7 * n_a + 8 * n_c + 8 * n_g + 9 * n_u - (l - 1) formula.P = n_a + n_c + n_g + n_u return formula def get_charge(self): """ Get the charge for a transcript (spliced RNA) species with * 5' monophosphate * Deprotonated phosphate oxygens :math:`-L - 1` Returns: :obj:`int`: charge """ return -self.get_len() - 1 def get_mol_wt(self): """ Get the molecular weight for a transcript (spliced RNA) species with * 5' monophosphate * Deprotonated phosphate oxygens Returns: :obj:`float`: molecular weight (Da) """ return self.get_empirical_formula().get_molecular_weight()