wc_kb.core


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

SubunitAttribute

Subunits

OneToOneSpeciesAttribute

Species attribute

IdentifierAttribute

Identifier attribute

ReactionParticipantAttribute

Reaction participants

Identifier

Reference to an entity in an external namespace

KnowledgeBaseObject

Knowledge of a biological entity

KnowledgeBase

A knowledge base

Cell

Knowledge of a cell

Reference

Reference to the literature

Compartment

Knowledge of a subcellular compartment

SpeciesType

Knowledge of a molecular species

Species

Species (tuple of species type, compartment)

Concentration

Species concentration

SpeciesTypeCoefficient

A tuple of a species type and a coefficient

SpeciesCoefficient

A tuple of a species and a coefficient

PolymerSpeciesType

Knowledge of a polymer

PolymerLocus

Knowledge about a locus of a polymer

ObservableExpression

A mathematical expression of Observables and Species

Observable

Observable: a linear function of other Observables and Species

Parameter

Knowledge of parameters

Validator

MetaboliteSpeciesType

Knowledge of a metabolite

DnaSpeciesType

Knowledge of a DNA species

ComplexSpeciesType

Knowledge of a protein complex

RateLawDirection

Rate law directions

RateLawExpression

Rate law expression

RateLaw

Rate law

Reaction

Knowledge of reactions

ChromosomeFeature

Knowledge of chromosome features

Evidence

Represents the measurement / observation of a property

Experiment

Represents an experiment in which a property was measured

SpeciesTypeProperty

Knowledge of the properties of species types

3.2.3.2. Attributes

PolymerStrand

PolymerDirection

wc_kb.core.PolymerStrand[source]
wc_kb.core.PolymerDirection[source]
class wc_kb.core.SubunitAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]

Bases: obj_tables.ManyToManyAttribute

Subunits

serialize(subunits, encoded=None)[source]

Serialize related object

Parameters:
  • subunits (list of SpeciesTypeCoefficient) – Python representation of subunits

  • encoded (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 representation

  • objects (dict) – dictionary of objects, grouped by model

  • decoded (dict, optional) – dictionary of objects that have already been decoded

Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

class wc_kb.core.OneToOneSpeciesAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]

Bases: obj_tables.OneToOneAttribute

Species 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 representation

  • objects (dict) – dictionary of objects, grouped by model

  • decoded (dict, optional) – dictionary of objects that have already been decoded

Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of Species, InvalidAttribute or None

class wc_kb.core.IdentifierAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]

Bases: obj_tables.ManyToManyAttribute

Identifier attribute

serialize(identifiers, encoded=None)[source]

Serialize related object :param identifiers: a list of instances of Identifier Python representation :type identifiers: list of 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 :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:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of Identifier, InvalidAttribute or None

class wc_kb.core.ReactionParticipantAttribute(related_name='', verbose_name='', verbose_related_name='', description='')[source]

Bases: obj_tables.ManyToManyAttribute

Reaction participants

serialize(participants, encoded=None)[source]

Serialize related object

Parameters:
  • participants (list of SpeciesCoefficient) – Python representation of reaction participants

  • encoded (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 representation

  • objects (dict) – dictionary of objects, grouped by model

  • decoded (dict, optional) – dictionary of objects that have already been decoded

Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of 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:

  • list of SpeciesCoefficient: list of species coefficients

  • list of Exception: list of errors

Return type:

tuple

class wc_kb.core.Identifier[source]

Bases: obj_tables.Model

Reference to an entity in an external namespace

namespace[source]

namespace

Type:

str

id[source]

identifier within the namespace

Type:

str

Related attributes:

compartments (list of Compartment): compartments species_types (list of SpeciesType): species_types concentrations (list of Concentration): concentrations loci (list of PolymerLocus): loci properties (list of SpeciesTypeProperty): species type properties reactions (list of Reaction): reactions rate_laws (list of RateLaw): rate_laws observables (list of Observable): observables

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('namespace', 'id')[source]
table_format[source]
ordering = ('namespace', 'id')[source]
namespace[source]
id[source]
static _serialize(namespace, id)[source]

Generate string representation

Parameters:
  • namespace (str) – namespace

  • id (str) – identifier within the namespace

Returns:

value of primary attribute

Return type:

str

serialize()[source]

Generate string representation

Returns:

value of primary attribute

Return type:

str

class wc_kb.core.KnowledgeBaseObject[source]

Bases: obj_tables.Model

Knowledge of a biological entity

id[source]

identifier

Type:

str

name[source]

name

Type:

str

synonyms[source]

synonyms

Type:

str

comments[source]

comments

Type:

str

id[source]
name[source]
synonyms[source]
comments[source]
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 (list of Reference)

_parse_EviNExperiment(metadataObjs)[source]
_append_metadata_entries(key, metadataObjs)[source]

Appends wc_kb.core.Reference / wc_kb.core.DatabaseReference / wc_kb.core.Comments objects to metadataObjs list

Input:

obj(obj_tables.Model): model object

Returns:

list of metadata objects

Return type:

metadataObjs (list of Reference / Evidence / Comments)

class wc_kb.core.KnowledgeBase[source]

Bases: KnowledgeBaseObject

A knowledge base

version[source]

version

Type:

str

translation_table[source]

translation table

Type:

int

version[source]

version of the KB

Type:

str

url[source]

url of the KB Git repository

Type:

str

branch[source]

branch of the KB Git repository

Type:

str

revision[source]

revision of the KB Git repository

Type:

str

wc_kb_version[source]

version of wc_kb

Type:

str

Related attributes:

cell (Cell): cell

class Meta[source]

Bases: obj_tables.Model.Meta

verbose_name = 'KB'[source]
description = 'Knowledge base'[source]
attribute_order = ('id', 'name', 'translation_table', 'version', 'url', 'branch', 'revision', 'wc_kb_version', 'comments')[source]
table_format[source]
translation_table[source]
version[source]
url[source]
branch[source]
revision[source]
wc_kb_version[source]
class wc_kb.core.Cell[source]

Bases: KnowledgeBaseObject

Knowledge of a cell

knowledge_base[source]

knowledge base

Type:

KnowledgeBase

taxon[source]

NCBI taxon identifier

Type:

int

Related attributes:

references (list of Reference): references compartments (list of Compartment): compartments species_types (list of SpeciesType): species types concentrations (list of Concentration): concentrations observables (list or Observable) : observables loci (list of PolymerLocus): locus reactions (list of Reaction): reactions

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'taxon', 'comments')[source]
table_format[source]
knowledge_base[source]
taxon[source]
class wc_kb.core.Reference[source]

Bases: obj_tables.Model

Reference to the literature

id[source]

identifier

Type:

str

name[source]

name

Type:

str

authors[source]

authors

Type:

str

title[source]

title

Type:

str

volume[source]

volume

Type:

str

issue[source]

issue

Type:

str

journal[source]

journal

Type:

str

pages (

obj:``str): pages

year[source]

year

Type:

int

cell[source]

cell

Type:

Cell

identifiers[source]

identifiers

Type:

list of Identifier

comments[source]

comments

Type:

str

type[source]

type of reference

Type:

pronto

Related attributes:

compartments (list of Compartment): compartments species_types (list of SpeciesType): species_types concentrations (list of Concentration): concentrations loci (list of PolymerLocus): loci properties (list of SpeciesTypeProperty): species type properties reactions (list of Reaction): reactions rate_laws (list of RateLaw): rate_laws observables (list of Observable): observables

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'type', 'title', 'authors', 'journal', 'volume', 'issue', 'pages', 'year',...[source]
id[source]
name[source]
authors[source]
title[source]
volume[source]
issue[source]
journal[source]
pages[source]
year[source]
cell[source]
identifiers[source]
comments[source]
type[source]
class wc_kb.core.Compartment[source]

Bases: KnowledgeBaseObject

Knowledge of a subcellular compartment

cell[source]

cell

Type:

Cell

volumetric_fraction[source]

average volumetric fraction relative to the cell volume

Type:

float

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

Related attributes:

reaction_participants (list of ReactionParticipant): reaction participants

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'volumetric_fraction', 'identifiers', 'references', 'comments')[source]
id[source]
cell[source]
volumetric_fraction[source]
references[source]
identifiers[source]
class wc_kb.core.SpeciesType[source]

Bases: KnowledgeBaseObject

Knowledge of a molecular species

cell[source]

cell

Type:

Cell

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

Related attributes:

reaction_participants (list of ReactionParticipant): reaction participants

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'comments', 'references', 'identifiers')[source]
id[source]
cell[source]
references[source]
identifiers[source]
abstract get_empirical_formula()[source]

Get the empirical formula

Returns:

empirical formula

Return type:

chem.EmpiricalFormula

abstract get_charge()[source]

Get the charge

Returns:

charge

Return type:

int

abstract get_mol_wt()[source]

Get the molecular weight

Returns:

molecular weight

Return type:

float

class wc_kb.core.Species[source]

Bases: obj_tables.Model

Species (tuple of species type, compartment)

species_type[source]

species type

Type:

SpeciesType

compartment[source]

compartment

Type:

Compartment

Related attributes:

concentration (Concentration): concentration species_coefficients (list of SpeciesCoefficient): participations in reactions rate_law_expressions (list of RateLawExpression): participations in the evaluation of rates observable_expressions (list of ObservableExpression): participations in observables

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'species_type', 'compartment')[source]
frozen_columns = 1[source]
table_format[source]
unique_together = (('species_type', 'compartment'),)[source]
ordering = ('species_type', 'compartment')[source]
expression_term_token_pattern = ()[source]
id[source]
species_type[source]
compartment[source]
static gen_id(species_type, compartment)[source]

Generate a Species’ primary identifier

Parameters:
  • species_type (object) – a SpeciesType, or its id

  • compartment (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) – attribute

  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of object, InvalidAttribute or None

class wc_kb.core.Concentration[source]

Bases: KnowledgeBaseObject

Species concentration

cell[source]

cell

Type:

Cell

species[source]

species

Type:

Species

medium[source]

medium

Type:

str

value[source]

value

Type:

float

units[source]

units; default units is ‘M’

Type:

unit_registry.Unit

evidence[source]

evidence

Type:

list of Evidence

comments[source]

comments

Type:

str

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'species', 'value', 'units', 'evidence', 'identifiers', 'references', 'comments')[source]
unique_together = (('species',),)[source]
ordering = ('species',)[source]
frozen_columns = 1[source]
cell[source]
species[source]
medium[source]
value[source]
units[source]
evidence[source]
references[source]
identifiers[source]
serialize()[source]

Generate string representation :returns: value of primary attribute :rtype: str

class wc_kb.core.SpeciesTypeCoefficient[source]

Bases: obj_tables.Model

A tuple of a species type and a coefficient

species_type[source]

species_type

Type:

SpeciesType

coefficient[source]

coefficient

Type:

float

Related attributes:

complex (ComplexSpeciesType): complex

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('species_type', 'coefficient')[source]
frozen_columns = 1[source]
table_format[source]
ordering = ('species_type',)[source]
species_type[source]
coefficient[source]
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_type

  • coefficient (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) – attribute

  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of SpeciesTypeCoefficient, InvalidAttribute or None

class wc_kb.core.SpeciesCoefficient[source]

Bases: obj_tables.Model

A tuple of a species and a coefficient

species[source]

species

Type:

Species

coefficient[source]

coefficient

Type:

float

Related attributes:

reaction (Reaction): reaction

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('species', 'coefficient')[source]
frozen_columns = 1[source]
table_format[source]
ordering = ('species',)[source]
species[source]
coefficient[source]
serialize(show_compartment=True, show_coefficient_sign=True)[source]

Serialize related object

Parameters:
  • show_compartment (bool, optional) – if true, show compartment

  • show_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) – species

  • coefficient (float) – coefficient

  • show_compartment (bool, optional) – if true, show compartment

  • show_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) – attribute

  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

  • compartment (Compartment, optional) – compartment

Returns:

tuple of cleaned value

and cleaning error

Return type:

tuple of list of SpeciesCoefficient, InvalidAttribute or None

class wc_kb.core.PolymerSpeciesType[source]

Bases: SpeciesType

Knowledge of a polymer

circular[source]

is the polymer circular

Type:

bool

double_stranded[source]

is the polymer double stranded

Type:

bool

Related attributes:

loci (list of PolymerLocus): loci

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'circular', 'double_stranded', 'comments', 'references', 'identifiers')[source]
circular[source]
double_stranded[source]
abstract get_seq()[source]

Get the polymer sequence

Returns:

sequence

Return type:

Bio.Seq.Seq

get_len()[source]

Get the polymer length

Returns:

length

Return type:

int

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: KnowledgeBaseObject

Knowledge about a locus of a polymer

polymer[source]

polymer

Type:

PolymerSpeciesType

start[source]

start position

Type:

int

end[source]

end position

Type:

int

strand[source]

strand

Type:

PolymerStrand

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'polymer', 'strand', 'start', 'end', 'identifiers', 'references', 'comments')[source]
cell[source]
polymer[source]
start[source]
end[source]
references[source]
identifiers[source]
strand[source]
get_seq()[source]

Get the sequence

Returns:

sequence

Return type:

Bio.Seq.Seq

get_len()[source]

Get the length

Returns:

length

Return type:

int

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:

PolymerDirection

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.Expression

A mathematical expression of Observables and Species

The expression used by a Observable.

expression[source]

mathematical expression for an Observable

Type:

str

species[source]

Species used by this Observable expression

Type:

list of Species

observables[source]

other Observables used by this Observable expression

Type:

list of Observable

Related attributes:

observable (Observable): observable

class Meta[source]

Bases: obj_tables.Model.Meta, obj_tables.math.expression.Expression.Meta

table_format[source]
expression_term_models = ('Species', 'Observable')[source]
expression_is_linear = True[source]
expression_unit_registry[source]
expression[source]
species[source]
observables[source]
serialize()[source]

Generate string representation

Returns:

string representation

Return type:

str

classmethod deserialize(value, objects)[source]

Deserialize value

Parameters:
  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of ObservableExpression, InvalidAttribute or None

class wc_kb.core.Observable[source]

Bases: KnowledgeBaseObject

Observable: a linear function of other Observables and Species

cell[source]

cell

Type:

Cell

expression[source]

mathematical expression for an Observable

Type:

ObservableExpression

units[source]

units of expression

Type:

unit_registry.Unit

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

Related attributes:

observable_expressions (list of ObservableExpression): observable expressions rate_law_expressions (list of RateLawExpression): rate law expressions

class Meta[source]

Bases: obj_tables.Model.Meta, obj_tables.math.expression.ExpressionExpressionTermMeta

attribute_order = ('id', 'name', 'expression', 'units', 'identifiers', 'references', 'comments')[source]
expression_term_model[source]
expression_term_units = 'units'[source]
cell[source]
expression[source]
units[source]
references[source]
identifiers[source]
deserialize(value, objects, decoded=None)[source]

Deserialize value

Parameters:
  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

  • decoded (dict, optional) – dictionary of objects that have already been decoded

Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of ObservableExpression, InvalidAttribute or None

class wc_kb.core.Parameter[source]

Bases: KnowledgeBaseObject

Knowledge of parameters

cell[source]

cell

Type:

Cell

value[source]

value

Type:

float

error[source]

measurement error

Type:

float

units[source]

units of value

Type:

unit_registry.Unit

evidence[source]

evidence

Type:

list of Evidence

references[source]

references

Type:

list of Reference

identifierss[source]

reference in external namespaces

Type:

list of DatabaseReference

Related attributes:

rate_law_expressions (list of RateLawExpression): rate law expressions that use a Parameter

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'synonyms', 'value', 'units', 'evidence', 'identifiers', 'references', 'comments')[source]
expression_term_token_pattern = ()[source]
cell[source]
value[source]
error[source]
units[source]
references[source]
evidence[source]
identifiers[source]
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 base

  • get_related (bool, optional) – if true, get all related objects

Returns:

list of invalid objects/models and their errors

Return type:

InvalidObjectSet or None

class wc_kb.core.MetaboliteSpeciesType[source]

Bases: SpeciesType

Knowledge of a metabolite

synonyms[source]

synonyms

Type:

str

type[source]

type

Type:

pronto

class Meta[source]

Bases: obj_tables.Model.Meta

verbose_name = 'Metabolite'[source]
attribute_order = ('id', 'name', 'synonyms', 'type', 'identifiers', 'references', 'comments')[source]
synonyms[source]
type[source]
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.4

  • major_tautomer (bool, optional) – if True, use the major tautomeric in the calculation

  • keep_hydrogens (bool, optional) – if True, keep explicity defined hydrogens

  • dearomatize (bool, optional) – if True, 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

calc_empirical_formula()[source]

Calculate the empirical formula

Returns:

empirical formula

Return type:

chem.EmpiricalFormula

get_charge()[source]

Get the charge

Returns:

charge

Return type:

int

calc_charge()[source]

Calculate the charge

Returns:

charge

Return type:

int

get_mol_wt()[source]

Get the molecular weight

Returns:

molecular weight

Return type:

float

Raises:

ValueError – if there is not enough information to calculate molecular weight

class wc_kb.core.DnaSpeciesType[source]

Bases: PolymerSpeciesType

Knowledge of a DNA species

seq_path[source]

path to sequence fasta file

Type:

str

ploidy[source]

ploidy

Type:

int

class Meta[source]

Bases: obj_tables.Model.Meta

verbose_name = 'Chromosome'[source]
attribute_order = ('id', 'name', 'sequence_path', 'circular', 'double_stranded', 'ploidy', 'identifiers',...[source]
sequence_path[source]
ploidy[source]
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 sequence

  • end (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: SpeciesType

Knowledge of a protein complex

formation_process[source]

type of formation process

Type:

pronto

subunits[source]

subunits

Type:

list of SpeciesTypeCoefficient

type[source]

type of complex formation

Type:

pronto

class Meta[source]

Bases: obj_tables.Model.Meta

verbose_name = 'Complex'[source]
attribute_order = ('id', 'name', 'synonyms', 'type', 'formation_process', 'subunits', 'identifiers', 'references',...[source]
subunits[source]
type[source]
formation_process[source]
get_empirical_formula()[source]

Get the empirical formula

Returns:

empirical formula

Return type:

chem.EmpiricalFormula

get_charge()[source]

Get the charge at physiological pH

Returns:

charge

Return type:

int

get_mol_wt()[source]

Get the molecular weight

Returns:

molecular weight

Return type:

float

class wc_kb.core.RateLawDirection[source]

Bases: int, wc_utils.util.enumerate.CaseInsensitiveEnum

Rate law directions

backward[source]
forward = 1[source]
class wc_kb.core.RateLawExpression[source]

Bases: obj_tables.Model, obj_tables.math.expression.Expression

Rate law expression

expression[source]

mathematical expression of the rate law

Type:

str

parameters[source]

parameters whose values are used in the rate law

Type:

list of Parameter

species[source]

species whose dynamic concentrations are used in the rate law

Type:

list of Species

observables[source]

observables whose values are used in the rate law

Type:

list of Observable

Related attributes:

rate_law (RateLaw): the RateLaw which uses this RateLawExpression

class Meta[source]

Bases: obj_tables.Model.Meta, obj_tables.math.expression.Expression.Meta

attribute_order = ('expression', 'parameters', 'species', 'observables')[source]
table_format[source]
ordering = ('expression',)[source]
expression_term_models = ('Parameter', 'Species', 'Observable')[source]
expression_unit_registry[source]
expression[source]
parameters[source]
species[source]
observables[source]
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:

tuple of RateLawExpression, InvalidAttribute or None

class wc_kb.core.RateLaw[source]

Bases: KnowledgeBaseObject

Rate law

reaction[source]

reaction

Type:

Reaction

direction[source]

direction

Type:

RateLawDirection

expression[source]

expression

Type:

RateLawExpression

units[source]

units

Type:

unit_registry.Unit

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

class Meta[source]

Bases: obj_tables.Model.Meta, obj_tables.math.expression.ExpressionExpressionTermMeta

attribute_order = ('id', 'reaction', 'direction', 'expression', 'units', 'identifiers', 'references', 'comments')[source]
expression_term_model[source]
expression_term_units = 'units'[source]
reaction[source]
expression[source]
units[source]
references[source]
identifiers[source]
direction[source]
gen_id()[source]

Generate identifier :returns: identifier :rtype: str

deserialize(value, objects, decoded=None)[source]

Deserialize value

Parameters:
  • value (str) – String representation

  • objects (dict) – dictionary of objects, grouped by model

  • decoded (dict, optional) – dictionary of objects that have already been decoded

Returns:

tuple of cleaned value and cleaning error

Return type:

tuple of ObservableExpression, InvalidAttribute or None

class wc_kb.core.Reaction[source]

Bases: KnowledgeBaseObject

Knowledge of reactions

cell[source]

cell

Type:

Cell

participants[source]

participants

Type:

list of SpeciesCoefficient

reversible[source]

denotes whether reaction is reversible

Type:

boolean

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

evidence[source]

evidence

Type:

list of Evidence

enzymes[source]

enzymes

Type:

list of SpeciesType

coenzymes[source]

coenzymes

Type:

list of SpeciesType

spontaneous[source]

spontaneity

Type:

bool

parameters[source]

parameters

Type:

Parameter

type[source]

type

Type:

pronto

Related attributes:
rate_laws (list of RateLaw): rate laws; if present, rate_laws[0] is the forward

rate law, and rate_laws[1] is the backward rate law

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'synonyms', 'type', 'participants', 'enzymes', 'coenzymes', 'reversible',...[source]
cell[source]
participants[source]
reversible[source]
references[source]
identifiers[source]
evidence[source]
enzymes[source]
coenzymes[source]
spontaneous[source]
parameters[source]
type[source]
class wc_kb.core.ChromosomeFeature[source]

Bases: PolymerLocus

Knowledge of chromosome features

cell[source]

cell

Type:

Cell

value[source]

value

Type:

float

error[source]

measurement error

Type:

float

units[source]

units of value

Type:

unit_registry.Unit

references[source]

references

Type:

list of Reference

identifiers[source]

identifiers

Type:

list of Identifier

Related attributes:

seq_path (str): path to sequence fasta file ploidy (int): ploidy

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'name', 'type', 'polymer', 'start', 'end', 'intensity', 'unit', 'evidence',...[source]
expression_term_token_pattern = ()[source]
coordinate[source]
start[source]
end[source]
intensity[source]
unit[source]
polymer[source]
evidence[source]
identifiers[source]
references[source]
type[source]
get_direction()[source]

Returns the direction of chromosome feature

Returns:

direction (in [‘forward’, ‘reverse’])

Return type:

PolymerDirection

class wc_kb.core.Evidence[source]

Bases: KnowledgeBaseObject

Represents the measurement / observation of a property

id[source]

identifier

Type:

str

cell[source]

cell

Type:

Cell

object[source]

object

Type:

str

property[source]

property

Type:

str

value[source]

value

Type:

float

units[source]

units

Type:

Units

identifiers[source]

identifiers

Type:

list of Identifier

references[source]

references

Type:

list of Reference

experiment[source]

experiment

Type:

Experiment

comments[source]

comments

Type:

str

Related attributes:

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'cell', 'object', 'property', 'value', 'units', 'experiment', 'identifiers',...[source]
cell[source]
object[source]
property[source]
value[source]
units[source]
identifiers[source]
references[source]
experiment[source]
comments[source]
class wc_kb.core.Experiment[source]

Bases: KnowledgeBaseObject

Represents an experiment in which a property was measured

id[source]

identifier

Type:

str

species[source]

species

Type:

str

genetic_variant[source]

genetic_variant

Type:

str

external_media[source]

external_media

Type:

str

temperature[source]

temperature

Type:

float

temperature_units[source]

temperature_units

Type:

Units

ph[source]

pH

Type:

float

experiment_design[source]

experimental design

Type:

str

measurement_technology[source]

measurement technology

Type:

str

analysis_type[source]

analysis type

Type:

str

identifiers[source]

identifiers

Type:

list of Identifier

references[source]

references

Type:

list of Reference

comments[source]

comments

Type:

str

Related attributes:

class Meta[source]

Bases: obj_tables.Model.Meta

attribute_order = ('id', 'experiment_design', 'measurement_technology', 'analysis_type', 'species',...[source]
species[source]
genetic_variant[source]
external_media[source]
temperature[source]
temperature_units[source]
ph[source]
experiment_design[source]
measurement_technology[source]
analysis_type[source]
identifiers[source]
references[source]
comments[source]
class wc_kb.core.SpeciesTypeProperty[source]

Bases: KnowledgeBaseObject

Knowledge of the properties of species types

species_type[source]

species type

Type:

SpeciesType

property[source]

name of property

Type:

str

units[source]

units

Type:

unit_registry

value[source]

value

Type:

str

identifiers[source]

identifiers

Type:

list of Identifier

references[source]

references

Type:

list of Reference

evidence[source]

evidence

Type:

list of Evidence

value_type[source]

value type

Type:

pronto

class Meta[source]

Bases: obj_tables.Model.Meta

verbose_name_plural = 'Species type properties'[source]
unique_together = (('species_type', 'property'),)[source]
attribute_order = ('id', 'species_type', 'property', 'value', 'value_type', 'units', 'evidence', 'identifiers',...[source]
species_type[source]
property[source]
units[source]
value[source]
identifiers[source]
references[source]
evidence[source]
value_type[source]
gen_id()[source]

Generate id :returns: identifier :rtype: str

get_value()[source]

SpeciesType property values are stored as strings, this function returns the value as the correct type.