Core schema to represent a knowledge base to build models
- Author:
Balazs Szigeti <balazs.szigeti@mssm.edu>
- Author:
Jonathan Karr <karr@mssm.edu>
- Author:
Bilal Shaikh <bilal.shaikh@columbia.edu>
- Author:
Arthur Goldberg <Arthur.Goldberg@mssm.edu>
- Author:
Yin Hoon Chew <yinhoon.chew@mssm.edu>
- Date:
2018-02-07
- Copyright:
2018, Karr Lab
- License:
MIT
3.2.3. Module Contents¶
3.2.3.1. Classes¶
Subunits |
|
Species attribute |
|
Identifier attribute |
|
Reaction participants |
|
Reference to an entity in an external namespace |
|
Knowledge of a biological entity |
|
A knowledge base |
|
Knowledge of a cell |
|
Reference to the literature |
|
Knowledge of a subcellular compartment |
|
Knowledge of a molecular species |
|
Species (tuple of species type, compartment) |
|
Species concentration |
|
A tuple of a species type and a coefficient |
|
A tuple of a species and a coefficient |
|
Knowledge of a polymer |
|
Knowledge about a locus of a polymer |
|
A mathematical expression of Observables and Species |
|
Observable: a linear function of other Observables and Species |
|
Knowledge of parameters |
|
Knowledge of a metabolite |
|
Knowledge of a DNA species |
|
Knowledge of a protein complex |
|
Rate law directions |
|
Rate law expression |
|
Rate law |
|
Knowledge of reactions |
|
Knowledge of chromosome features |
|
Represents the measurement / observation of a property |
|
Represents an experiment in which a property was measured |
|
Knowledge of the properties of species types |
3.2.3.2. Attributes¶
- class wc_kb.core.SubunitAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]¶
Bases:
obj_tables.ManyToManyAttributeSubunits
- serialize(subunits, encoded=None)[source]¶
Serialize related object
- Parameters:
subunits (
listofSpeciesTypeCoefficient) – Python representation of subunitsencoded (
dict, optional) – dictionary of objects that have already been encoded
- Returns:
simple Python representation
- Return type:
str
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modeldecoded (
dict, optional) – dictionary of objects that have already been decoded
- Returns:
tuple of cleaned value and cleaning error
- Return type:
tupleof object, InvalidAttribute or None
- class wc_kb.core.OneToOneSpeciesAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]¶
Bases:
obj_tables.OneToOneAttributeSpecies attribute
- serialize(value, encoded=None)[source]¶
Serialize related object :param value: Python representation :type value:
Model:param encoded: dictionary of objects that have already been encoded :type encoded:dict, optional- Returns:
simple Python representation
- Return type:
str
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modeldecoded (
dict, optional) – dictionary of objects that have already been decoded
- Returns:
tupleof cleaned valueand cleaning error
- Return type:
tupleoflistofSpecies,InvalidAttributeorNone
- class wc_kb.core.IdentifierAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]¶
Bases:
obj_tables.ManyToManyAttributeIdentifier attribute
- serialize(identifiers, encoded=None)[source]¶
Serialize related object :param identifiers: a list of instances of Identifier Python representation :type identifiers:
listofModel:param encoded: dictionary of objects that have already been encoded :type encoded:dict, optional- Returns:
simple Python representation
- Return type:
str
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value :param value: String representation :type value:
str:param objects: dictionary of objects, grouped by model :type objects:dict:param decoded: dictionary of objects that have already been decoded :type decoded:dict, optional- Returns:
tupleof cleaned valueand cleaning error
- Return type:
tupleoflistofIdentifier,InvalidAttributeorNone
- class wc_kb.core.ReactionParticipantAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]¶
Bases:
obj_tables.ManyToManyAttributeReaction participants
- serialize(participants, encoded=None)[source]¶
Serialize related object
- Parameters:
participants (
listofSpeciesCoefficient) – Python representation of reaction participantsencoded (
dict, optional) – dictionary of objects that have already been encoded
- Returns:
simple Python representation
- Return type:
str
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modeldecoded (
dict, optional) – dictionary of objects that have already been decoded
- Returns:
- tuple of cleaned value
and cleaning error
- Return type:
tupleof list of SpeciesCoefficient, InvalidAttribute or None
- deserialize_side(direction, value, objects, global_comp)[source]¶
Deserialize the LHS or RHS of a reaction equation :param direction: -1. indicates LHS, +1. indicates RHS :type direction:
float:param value: String representation :type value:str:param objects: dictionary of objects, grouped by model :type objects:dict:param global_comp: global compartment of the reaction :type global_comp:Compartment- Returns:
listofSpeciesCoefficient: list of species coefficientslistofException: list of errors
- Return type:
tuple
- class wc_kb.core.Identifier[source]¶
Bases:
obj_tables.ModelReference to an entity in an external namespace
- Related attributes:
compartments (
listofCompartment): compartments species_types (listofSpeciesType): species_types concentrations (listofConcentration): concentrations loci (listofPolymerLocus): loci properties (listofSpeciesTypeProperty): species type properties reactions (listofReaction): reactions rate_laws (listofRateLaw): rate_laws observables (listofObservable): observables
- class wc_kb.core.KnowledgeBaseObject[source]¶
Bases:
obj_tables.ModelKnowledge of a biological entity
- get_nested_metadata()[source]¶
- Returns a list of wc_kb.core.Reference / wc_kb.core.DatabaseReference / wc_kb.core.Comments objects that
appear in the object’s wc_kb.core.Evidence and the associated wc_kb.core.Experiment
- Returns:
references
- Return type:
id (
listofReference)
- class wc_kb.core.KnowledgeBase[source]¶
Bases:
KnowledgeBaseObjectA knowledge base
- Related attributes:
cell (
Cell): cell
- class wc_kb.core.Cell[source]¶
Bases:
KnowledgeBaseObjectKnowledge of a cell
- Related attributes:
references (
listofReference): references compartments (listofCompartment): compartments species_types (listofSpeciesType): species types concentrations (listofConcentration): concentrations observables (listorObservable) : observables loci (listofPolymerLocus): locus reactions (listofReaction): reactions
- class wc_kb.core.Reference[source]¶
Bases:
obj_tables.ModelReference to the literature
- pages (
obj:``str): pages
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- Related attributes:
compartments (
listofCompartment): compartments species_types (listofSpeciesType): species_types concentrations (listofConcentration): concentrations loci (listofPolymerLocus): loci properties (listofSpeciesTypeProperty): species type properties reactions (listofReaction): reactions rate_laws (listofRateLaw): rate_laws observables (listofObservable): observables
- class wc_kb.core.Compartment[source]¶
Bases:
KnowledgeBaseObjectKnowledge of a subcellular compartment
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- Related attributes:
reaction_participants (
listofReactionParticipant): reaction participants
- class wc_kb.core.SpeciesType[source]¶
Bases:
KnowledgeBaseObjectKnowledge of a molecular species
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- Related attributes:
reaction_participants (
listofReactionParticipant): reaction participants
- class wc_kb.core.Species[source]¶
Bases:
obj_tables.ModelSpecies (tuple of species type, compartment)
- Related attributes:
concentration (
Concentration): concentration species_coefficients (listofSpeciesCoefficient): participations in reactions rate_law_expressions (listofRateLawExpression): participations in the evaluation of rates observable_expressions (listofObservableExpression): participations in observables
- static gen_id(species_type, compartment)[source]¶
Generate a Species’ primary identifier
- Parameters:
species_type (
object) – a SpeciesType, or its idcompartment (
object) – a Compartment, or its id
- Returns:
canonical identifier for a specie in a compartment, ‘species_type_id[compartment_id]’
- Return type:
str
- id()[source]¶
Provide a Species’ primary identifier
- Returns:
canonical identifier for a specie in a compartment, ‘specie_id[compartment_id]’
- Return type:
str
- serialize()[source]¶
Provide a Species’ primary identifier
- Returns:
canonical identifier for a specie in a compartment, ‘specie_id[compartment_id]’
- Return type:
str
- classmethod deserialize(attribute, value, objects)[source]¶
Deserialize value
- Parameters:
attribute (
Attribute) – attributevalue (
str) – String representationobjects (
dict) – dictionary of objects, grouped by model
- Returns:
tuple of cleaned value and cleaning error
- Return type:
tupleof object, InvalidAttribute or None
- class wc_kb.core.Concentration[source]¶
Bases:
KnowledgeBaseObjectSpecies concentration
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- class wc_kb.core.SpeciesTypeCoefficient[source]¶
Bases:
obj_tables.ModelA tuple of a species type and a coefficient
- Related attributes:
complex (
ComplexSpeciesType): complex
- serialize()[source]¶
Serialize related object
- Returns:
string representation of a species type and a coefficient
- Return type:
str
- static _serialize(species_type, coefficient)[source]¶
Serialize values
- Parameters:
species_type (
SpeciesType) – species_typecoefficient (
float) – coefficient
- Returns:
string representation of a species type and a coefficient
- Return type:
str
- classmethod deserialize(attribute, value, objects)[source]¶
Deserialize value
- Parameters:
attribute (
Attribute) – attributevalue (
str) – String representationobjects (
dict) – dictionary of objects, grouped by model
- Returns:
- tuple of cleaned value
and cleaning error
- Return type:
tupleof list of SpeciesTypeCoefficient, InvalidAttribute or None
- class wc_kb.core.SpeciesCoefficient[source]¶
Bases:
obj_tables.ModelA tuple of a species and a coefficient
- Related attributes:
reaction (
Reaction): reaction
- serialize(show_compartment=True, show_coefficient_sign=True)[source]¶
Serialize related object
- Parameters:
show_compartment (
bool, optional) – if true, show compartmentshow_coefficient_sign (
bool, optional) – if true, show coefficient sign
- Returns:
string representation of a species and a coefficient
- Return type:
str
- static _serialize(species, coefficient, show_compartment=True, show_coefficient_sign=True)[source]¶
Serialize values
- Parameters:
species (
Species) – speciescoefficient (
float) – coefficientshow_compartment (
bool, optional) – if true, show compartmentshow_coefficient_sign (
bool, optional) – if true, show coefficient sign
- Returns:
string representation of a species and a coefficient
- Return type:
str
- classmethod deserialize(attribute, value, objects, compartment=None)[source]¶
Deserialize value
- Parameters:
attribute (
Attribute) – attributevalue (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modelcompartment (
Compartment, optional) – compartment
- Returns:
- tuple of cleaned value
and cleaning error
- Return type:
tupleof list of SpeciesCoefficient, InvalidAttribute or None
- class wc_kb.core.PolymerSpeciesType[source]¶
Bases:
SpeciesTypeKnowledge of a polymer
- Related attributes:
loci (
listofPolymerLocus): loci
- get_subseq(start, end, strand=PolymerStrand.positive)[source]¶
Get a subsequence
- Parameters:
start (
int) – start coordinate (1-indexed)end (
int) – end coordinate (1-indexed)strand (
PolymerStrand, optional) – strand
- Returns:
sequence
- Return type:
Bio.Seq.Seq- Raises:
ValueError – if the polymer is linear and the start or end coordinates are less than 1 or greater than the length of the sequence
- class wc_kb.core.PolymerLocus[source]¶
Bases:
KnowledgeBaseObjectKnowledge about a locus of a polymer
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- get_direction()[source]¶
Returns the direction of the polymer feature defind by its strand and start/end coordinate
- Returns:
direction (in [‘forward’, ‘reverse’])
- Return type:
- Raises:
ValueError – start and end coordinate of chromosome feature can not be the same
Exception – strand is not member of PolymerStrand
- class wc_kb.core.ObservableExpression[source]¶
Bases:
obj_tables.Model,obj_tables.math.expression.ExpressionA mathematical expression of Observables and Species
The expression used by a Observable.
- observables[source]¶
other Observables used by this Observable expression
- Type:
listofObservable
- Related attributes:
observable (
Observable): observable
- classmethod deserialize(value, objects)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by model
- Returns:
tuple of cleaned value and cleaning error
- Return type:
tupleofObservableExpression, InvalidAttribute or None
- class wc_kb.core.Observable[source]¶
Bases:
KnowledgeBaseObjectObservable: a linear function of other Observables and Species
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- Related attributes:
observable_expressions (
listofObservableExpression): observable expressions rate_law_expressions (listofRateLawExpression): rate law expressions
- class Meta[source]¶
Bases:
obj_tables.Model.Meta,obj_tables.math.expression.ExpressionExpressionTermMeta
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modeldecoded (
dict, optional) – dictionary of objects that have already been decoded
- Returns:
tuple of cleaned value and cleaning error
- Return type:
tupleofObservableExpression, InvalidAttribute or None
- class wc_kb.core.Parameter[source]¶
Bases:
KnowledgeBaseObjectKnowledge of parameters
- Related attributes:
rate_law_expressions (
listofRateLawExpression): rate law expressions that use a Parameter
- class wc_kb.core.Validator[source]¶
Bases:
obj_tables.Validator- run(knowledge_base, get_related=True)[source]¶
Validate a knowledge_base and return its errors
- Parameters:
knowledge_base (
KnowledgeBase) – knowledge baseget_related (
bool, optional) – if true, get all related objects
- Returns:
list of invalid objects/models and their errors
- Return type:
InvalidObjectSetor None
- class wc_kb.core.MetaboliteSpeciesType[source]¶
Bases:
SpeciesTypeKnowledge of a metabolite
- get_structure()[source]¶
Get the structure
- Returns:
InChI or SMILES structure
- Return type:
str- Raises:
ValueError – if structure has not been provided
- calc_structure(ph=7.4, major_tautomer=False, keep_hydrogens=False, dearomatize=False)[source]¶
Get the major microspecies
- Parameters:
pH (
float, optional) – pH, default is 7.4major_tautomer (
bool, optional) – ifTrue, use the major tautomeric in the calculationkeep_hydrogens (
bool, optional) – ifTrue, keep explicity defined hydrogensdearomatize (
bool, optional) – ifTrue, dearomatize molecule
- Returns:
InChI-encoded structure
- Return type:
str
- to_openbabel_mol()[source]¶
Convert species type to an Open Babel molecule
- Returns:
Open Babel molecule
- Return type:
openbabel.OBMol
- get_empirical_formula()[source]¶
Get the empirical formula
- Returns:
empirical formula
- Return type:
chem.EmpiricalFormula
- class wc_kb.core.DnaSpeciesType[source]¶
Bases:
PolymerSpeciesTypeKnowledge of a DNA species
- get_seq(start=None, end=None)[source]¶
Get the sequence
- Parameters:
start (
int, optional) – start coordinate of the queried subsequence, default is the start of the full sequenceend (
int, optional) – end coordinate of the queried subsequence, default is the end of the full sequence
- Returns:
structure
- Return type:
Bio.Seq.Seq
- get_empirical_formula()[source]¶
Get the empirical formula for a DNA molecule with
5’ monophosphate (for linear molecules)
Deprotonated phosphate oxygens
Linear DNA
\(N_A * dAMP + N_C * dCMP + N_G * dGMP + N_T * dTMP - (L - 1) * OH\)
Circular DNA
\(N_A * dAMP + N_C * dCMP + N_G * dGMP + N_T * dTMP - L * OH\)
N’s in the sequence will be distributed into the four bases by preserving the original ratio
- Returns:
empirical formula
- Return type:
chem.EmpiricalFormula
- get_charge()[source]¶
Get the charge for a DNA molecule with
5’ monophosphate (for linear molecules)
Deprotonated phosphate oxygens
Linear DNA
\(-L - 1\)
Circular DNA
\(-L\)
- Returns:
charge
- Return type:
int
- get_mol_wt()[source]¶
Get the molecular weight for a DNA molecule with
5’ monophosphate (for linear molecules)
Deprotonated phosphate oxygens
Linear DNA
\(N_A * MW_{dAMP} + N_C * MW_{dCMP} + N_G * MW_{dGMP} + N_T * MW_{dTMP} - (L - 1) * MW_{OH}\)
Circular DNA
\(N_A * MW_{dAMP} + N_C * MW_{dCMP} + N_G * MW_{dGMP} + N_T * MW_{dTMP} - L * MW_{OH}\)
- Returns:
molecular weight
- Return type:
float
- class wc_kb.core.ComplexSpeciesType[source]¶
Bases:
SpeciesTypeKnowledge of a protein complex
- subunits[source]¶
subunits
- Type:
listofSpeciesTypeCoefficient
- class wc_kb.core.RateLawDirection[source]¶
Bases:
int,wc_utils.util.enumerate.CaseInsensitiveEnumRate law directions
- class wc_kb.core.RateLawExpression[source]¶
Bases:
obj_tables.Model,obj_tables.math.expression.ExpressionRate law expression
- species[source]¶
species whose dynamic concentrations are used in the rate law
- Type:
listofSpecies
- observables[source]¶
observables whose values are used in the rate law
- Type:
listofObservable
- Related attributes:
rate_law (
RateLaw): the RateLaw which uses this RateLawExpression
- serialize()[source]¶
Generate string representation :returns: value of primary attribute :rtype:
str
- classmethod deserialize(value, objects)[source]¶
Deserialize value :param value: String representation :type value:
str:param objects: dictionary of objects, grouped by model :type objects:dict- Returns:
- tuple of cleaned value
and cleaning error
- Return type:
tupleofRateLawExpression, InvalidAttribute or None
- class wc_kb.core.RateLaw[source]¶
Bases:
KnowledgeBaseObjectRate law
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- class Meta[source]¶
Bases:
obj_tables.Model.Meta,obj_tables.math.expression.ExpressionExpressionTermMeta
- deserialize(value, objects, decoded=None)[source]¶
Deserialize value
- Parameters:
value (
str) – String representationobjects (
dict) – dictionary of objects, grouped by modeldecoded (
dict, optional) – dictionary of objects that have already been decoded
- Returns:
tuple of cleaned value and cleaning error
- Return type:
tupleofObservableExpression, InvalidAttribute or None
- class wc_kb.core.Reaction[source]¶
Bases:
KnowledgeBaseObjectKnowledge of reactions
- participants[source]¶
participants
- Type:
listofSpeciesCoefficient
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- enzymes[source]¶
enzymes
- Type:
listofSpeciesType
- coenzymes[source]¶
coenzymes
- Type:
listofSpeciesType
- Related attributes:
- rate_laws (
listofRateLaw): rate laws; if present, rate_laws[0] is the forward rate law, and rate_laws[1] is the backward rate law
- rate_laws (
- class wc_kb.core.ChromosomeFeature[source]¶
Bases:
PolymerLocusKnowledge of chromosome features
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
- Related attributes:
seq_path (
str): path to sequence fasta file ploidy (int): ploidy
- class Meta[source]¶
Bases:
obj_tables.Model.Meta
- class wc_kb.core.Evidence[source]¶
Bases:
KnowledgeBaseObjectRepresents the measurement / observation of a property
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
Related attributes:
- class wc_kb.core.Experiment[source]¶
Bases:
KnowledgeBaseObjectRepresents an experiment in which a property was measured
- identifiers[source]¶
identifiers
- Type:
listofIdentifier
Related attributes:
- class wc_kb.core.SpeciesTypeProperty[source]¶
Bases:
KnowledgeBaseObjectKnowledge of the properties of species types
- identifiers[source]¶
identifiers
- Type:
listofIdentifier