class GeneLocus(core.PolymerLocus): """ Knowledge of a gene Attributes: symbol (:obj:`str`): symbol Related attributes: proteins (:obj:`list` of :obj:`ProteinSpeciesType`): protein """ symbol = obj_tables.StringAttribute() start = obj_tables.IntegerAttribute() end = obj_tables.IntegerAttribute() is_essential = obj_tables.BooleanAttribute() proteins = obj_tables.OneToOneAttribute(ProteinSpeciesType, related_name='gene') homologs = obj_tables.LongStringAttribute() evidence = obj_tables.OneToManyAttribute(core.Evidence, related_name='genes') cog = obj_tables.sci.onto.OntoTermAttribute( kbOnt, terms=kbOnt['WC:COG'].subclasses(), none=True) class Meta(obj_tables.Model.Meta): verbose_name = 'Gene' verbose_name_plural = 'Genes' attribute_order = ('id', 'name', 'synonyms', 'symbol', 'polymer', 'start', 'end', 'cog', 'homologs', 'is_essential', 'proteins', 'evidence', 'identifiers', 'references', 'comments')
class SparseMatrixOrdered(obj_tables.Model): row_number = obj_tables.IntegerAttribute(verbose_name='RowNumber') column_number = obj_tables.IntegerAttribute(verbose_name='ColumnNumber') value = obj_tables.FloatAttribute(verbose_name='Value') class Meta(obj_tables.Model.Meta): table_format = obj_tables.TableFormat.row attribute_order = ( 'row_number', 'column_number', 'value', ) verbose_name = 'SparseMatrixOrdered' verbose_name_plural = 'SparseMatrixOrdered'
class rxnconContingencyList(obj_tables.Model): u_i_d_contingency = obj_tables.IntegerAttribute( verbose_name='UID:Contingency') target = obj_tables.StringAttribute(verbose_name='Target') contingency = obj_tables.StringAttribute(verbose_name='Contingency') modifier = obj_tables.StringAttribute(verbose_name='Modifier') reference_identifiers_pubmed = obj_tables.StringAttribute( verbose_name='Reference:Identifiers:pubmed') quality = obj_tables.StringAttribute(verbose_name='Quality') comment = obj_tables.StringAttribute(verbose_name='Comment') internal_complex_i_d = obj_tables.StringAttribute( verbose_name='InternalComplexID') class Meta(obj_tables.Model.Meta): table_format = obj_tables.TableFormat.row attribute_order = ( 'u_i_d_contingency', 'target', 'contingency', 'modifier', 'reference_identifiers_pubmed', 'quality', 'comment', 'internal_complex_i_d', ) verbose_name = 'rxnconContingencyList' verbose_name_plural = 'rxnconContingencyList'
class TranscriptionUnitLocus(core.PolymerLocus): """ Knowledge about an open reading frame Attributes: genes (:obj:`list` of :obj:`GeneLocus`): genes """ pribnow_start = obj_tables.IntegerAttribute() pribnow_end = obj_tables.IntegerAttribute() genes = obj_tables.OneToManyAttribute('GeneLocus', related_name='transcription_units') rnas = obj_tables.ManyToManyAttribute('RnaSpeciesType', related_name='transcription_units') #type = obj_tables.sci.onto.OntoTermAttribute(kbOnt, # terms = kbOnt['WC:gene'].subclasses(), # none=True) class Meta(obj_tables.Model.Meta): verbose_name = 'Transcription unit' verbose_name_plural = 'Transcription units' attribute_order = ('id', 'name', 'polymer', 'strand', 'pribnow_start', 'pribnow_end', 'start', 'end', 'rnas', 'genes', 'identifiers', 'references', 'comments') def get_3_prime(self): """ Get the 3' coordinate Returns: :obj:`int`: 3' coordinate """ if self.get_direction() == core.PolymerDirection.forward: return self.end else: return self.start def get_5_prime(self): """ Get the 5' coordinate Returns: :obj:`int`: 5' coordinate """ if self.get_direction() == core.PolymerDirection.forward: return self.start else: return self.end
class rxnconReactionList(obj_tables.Model): i_d = obj_tables.IntegerAttribute(verbose_name='ID') u_i_d_reaction = obj_tables.StringAttribute(verbose_name='UID:Reaction') component_a_name = obj_tables.StringAttribute( verbose_name='ComponentA:Name') component_a_domain = obj_tables.StringAttribute( verbose_name='ComponentA:Domain') component_a_residue = obj_tables.StringAttribute( verbose_name='ComponentA:Residue') reaction = obj_tables.StringAttribute(verbose_name='Reaction') component_b_name = obj_tables.StringAttribute( verbose_name='ComponentB:Name') component_b_domain = obj_tables.StringAttribute( verbose_name='ComponentB:Domain') component_b_residue = obj_tables.StringAttribute( verbose_name='ComponentB:Residue') quality = obj_tables.StringAttribute(verbose_name='Quality') literature_identifiers_pubmed = obj_tables.StringAttribute( verbose_name='Literature:Identifiers:pubmed') comment = obj_tables.StringAttribute(verbose_name='Comment') class Meta(obj_tables.Model.Meta): table_format = obj_tables.TableFormat.row attribute_order = ( 'i_d', 'u_i_d_reaction', 'component_a_name', 'component_a_domain', 'component_a_residue', 'reaction', 'component_b_name', 'component_b_domain', 'component_b_residue', 'quality', 'literature_identifiers_pubmed', 'comment', ) verbose_name = 'rxnconReactionList' verbose_name_plural = 'rxnconReactionList'
class Relationship(obj_tables.Model): i_d = obj_tables.StringAttribute(verbose_name='ID') from_object = obj_tables.StringAttribute(verbose_name='FromObject') to_object = obj_tables.StringAttribute(verbose_name='ToObject') value = obj_tables.IntegerAttribute(verbose_name='Value') is_symmetric = obj_tables.BooleanAttribute(verbose_name='IsSymmetric') sign = obj_tables.EnumAttribute(['+', '-', '0'], default='0', verbose_name='Sign') relation = obj_tables.StringAttribute(verbose_name='Relation') class Meta(obj_tables.Model.Meta): table_format = obj_tables.TableFormat.row attribute_order = ( 'i_d', 'from_object', 'to_object', 'value', 'is_symmetric', 'sign', 'relation', ) verbose_name = 'Relationship' verbose_name_plural = 'Relationship'
class Compound(obj_tables.Model): comment = obj_tables.StringAttribute(verbose_name='Comment') reference_name = obj_tables.StringAttribute(verbose_name='ReferenceName') reference_pub_med = obj_tables.StringAttribute( verbose_name='ReferencePubMed') reference_d_o_i = obj_tables.StringAttribute(verbose_name='ReferenceDOI') description = obj_tables.StringAttribute(verbose_name='Description') name = obj_tables.StringAttribute(verbose_name='Name') miriam_annotations = obj_tables.StringAttribute( verbose_name='MiriamAnnotations') type = obj_tables.StringAttribute(verbose_name='Type') symbol = obj_tables.StringAttribute(verbose_name='Symbol') position_x = obj_tables.FloatAttribute(verbose_name='PositionX') position_y = obj_tables.FloatAttribute(verbose_name='PositionY') i_d = obj_tables.StringAttribute(verbose_name='ID') s_b_m_l_species_id = obj_tables.StringAttribute( verbose_name='SBML:species:id') s_b_m_l_speciestype_id = obj_tables.StringAttribute( verbose_name='SBML:speciestype:id') initial_value = obj_tables.FloatAttribute(verbose_name='InitialValue') initial_concentration = obj_tables.FloatAttribute( verbose_name='InitialConcentration') unit = obj_tables.StringAttribute(verbose_name='Unit') location = obj_tables.StringAttribute(verbose_name='Location') state = obj_tables.StringAttribute(verbose_name='State') compound_sum_formula = obj_tables.StringAttribute( verbose_name='CompoundSumFormula') structure_formula = obj_tables.StringAttribute( verbose_name='StructureFormula') charge = obj_tables.IntegerAttribute(verbose_name='Charge') mass = obj_tables.FloatAttribute(verbose_name='Mass') is_constant = obj_tables.BooleanAttribute(verbose_name='IsConstant') enzyme_role = obj_tables.StringAttribute(verbose_name='EnzymeRole') regulator_role = obj_tables.StringAttribute(verbose_name='RegulatorRole') s_b_o_term = obj_tables.StringAttribute(verbose_name='SBOTerm') identifiers = obj_tables.StringAttribute(verbose_name='Identifiers') identifiers_sbo_kegg = obj_tables.StringAttribute( verbose_name='Identifiers:sbo.kegg') identifiers_kegg_compound = obj_tables.StringAttribute( verbose_name='Identifiers:kegg.compound') identifiers_obo_chebi = obj_tables.StringAttribute( verbose_name='Identifiers:obo.chebi') s_b_m_l_fbc_chemical_formula = obj_tables.StringAttribute( verbose_name='SBML:fbc:ChemicalFormula') s_b_m_l_fbc_charge = obj_tables.FloatAttribute( verbose_name='SBML:fbc:Charge') has_only_substance_units = obj_tables.BooleanAttribute( verbose_name='HasOnlySubstanceUnits') name_for_plots = obj_tables.StringAttribute(verbose_name='NameForPlots') class Meta(obj_tables.Model.Meta): table_format = obj_tables.TableFormat.row attribute_order = ( 'comment', 'reference_name', 'reference_pub_med', 'reference_d_o_i', 'description', 'name', 'miriam_annotations', 'type', 'symbol', 'position_x', 'position_y', 'i_d', 's_b_m_l_species_id', 's_b_m_l_speciestype_id', 'initial_value', 'initial_concentration', 'unit', 'location', 'state', 'compound_sum_formula', 'structure_formula', 'charge', 'mass', 'is_constant', 'enzyme_role', 'regulator_role', 's_b_o_term', 'identifiers', 'identifiers_sbo_kegg', 'identifiers_kegg_compound', 'identifiers_obo_chebi', 's_b_m_l_fbc_chemical_formula', 's_b_m_l_fbc_charge', 'has_only_substance_units', 'name_for_plots', ) verbose_name = 'Compound' verbose_name_plural = 'Compound'
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) """ start = obj_tables.IntegerAttribute() end = obj_tables.IntegerAttribute() proteins = obj_tables.OneToManyAttribute('ProteinSpeciesType', related_name='rnas') coordinate = obj_tables.IntegerAttribute() length = obj_tables.IntegerAttribute() type = obj_tables.sci.onto.OntoTermAttribute( kbOnt, terms=kbOnt['WC:RNA'].subclasses(), none=True) class Meta(obj_tables.Model.Meta): verbose_name = 'RNA' verbose_name_plural = 'RNAs' attribute_order = ('id', 'name', 'synonyms', 'type', 'start', 'end', 'proteins', 'identifiers', 'references', 'comments') def get_seq(self): """ Get the sequence Returns: :obj:`Bio.Seq.Seq`: sequence """ tu = self.transcription_units[0] tu_start = tu.start tu_end = tu.end dna_seq = tu.polymer.get_subseq(start=tu_start, end=tu_end, strand=tu.strand) #tu_start = self.start #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.upper().count('A') n_c = seq.upper().count('C') n_g = seq.upper().count('G') n_u = seq.upper().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() def get_direction(self): """ Returns the direction of the polymer feature defind by its strand and start/end coordinate Returns: :obj:`str`: direction (in ['forward', 'reverse']) Raises: :obj:`ValueError`: start and end coordinate of chromosome feature can not be the same :obj:`Exception`: strand is not member of PolymerStrand """ if self.start < self.end: if self.strand == core.PolymerStrand.positive: return core.PolymerDirection.forward elif self.strand == core.PolymerStrand.negative: return core.PolymerDirection.reverse else: raise Exception( 'Unrecognized polymer strand ({}) found for {}.'.format( self.strand, self.id)) elif self.start > self.end: if self.strand == core.PolymerStrand.positive: return core.PolymerDirection.reverse elif self.strand == core.PolymerStrand.negative: return core.PolymerStrand.forward else: raise Exception( 'Unrecognized polymer strand ({}) found for {}.'.format( self.strand, self.id)) elif self.start == self.end: raise ValueError( 'Start and end position of chromosome feature can not be the same (Chrom feature id: {}).' .format(self.id))