3.1.1.2. obj_tables.chem package¶
3.1.1.2.1. Submodules¶
3.1.1.2.2. obj_tables.chem.core module¶
Chemistry attributes
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2017-05-10
- Copyright
2017, Karr Lab
- License
MIT
-
class
obj_tables.chem.core.
ChemicalFormulaAttribute
(default=None, none_value=None, verbose_name='', description="A chemical formula (e.g. 'H2O', 'CO2', or 'NaCl')", primary=False, unique=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Chemical formula attribute
- Parameters
default (
chem.EmpiricalFormula
,dict
,str
, orNone
, optional) – default valuenone_value (
object
, optional) – none valueverbose_name (
str
, optional) – verbose namedescription (
str
, optional) – descriptionprimary (
bool
, optional) – indicate if attribute is primary attributeunique (
bool
, optional) – indicate if attribute value must be unique
-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – semantically equivalent representation- Returns
chem.EmpiricalFormula
: cleaned valuecore.InvalidAttribute
: cleaning error
- Return type
tuple
-
from_builtin
(json)[source]¶ Decode a simple Python representation (dict, list, str, float, bool, None) of a value of the attribute that is compatible with JSON and YAML
- Parameters
json (
dict
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
chem.EmpiricalFormula
-
get_xlsx_validation
(sheet_models=None, doc_metadata_model=None)[source]¶ Get XLSX validation
- Parameters
sheet_models (
list
ofModel
, optional) – models encoded as separate sheetsdoc_metadata_model (
type
) – model whose worksheet contains the document metadata
- Returns
validation
- Return type
wc_utils.workbook.io.FieldValidation
-
serialize
(value)[source]¶ Serialize string
- Parameters
value (
chem.EmpiricalFormula
) – Python representation- Returns
simple Python representation
- Return type
str
-
to_builtin
(value)[source]¶ Encode a value of the attribute using a simple Python representation (dict, list, str, float, bool, None) that is compatible with JSON and YAML
- Parameters
value (
chem.EmpiricalFormula
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
dict
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
chem.EmpiricalFormula
) – value of attribute to validate
- Returns
- None if attribute is valid, other return
list of errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-
validate_unique
(objects, values)[source]¶ Determine if the attribute values are unique
- Parameters
objects (
list
ofModel
) – list ofModel
objectsvalues (
list
ofchem.EmpiricalFormula
) – list of values
- Returns
- None if values are unique, otherwise return a
list of errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-
class
obj_tables.chem.core.
ChemicalStructure
(value=None, serialized_format=None)[source]¶ Bases:
object
A chemical structure
- Attributes
value (
openbabel.OBMol
,bpforms.BpForm
,bcforms.BcForm
): value serialized_value (str
): serialized value serialized_format (ChemicalStructureFormat
): serialized format_value (
openbabel.OBMol
,bpforms.BpForm
,bcforms.BcForm
): value _serialized_value (str
): serialized value _serialized_format (ChemicalStructureFormat
): serialized format
- Parameters
value (
str
,openbabel.OBMol
,bpforms.BpForm
,bcforms.BcForm
, optional) – valueserialized_format (
ChemicalStructureFormat
, openbabel) – serialized format
-
deserialize
(serialized_value)[source]¶ Set value from a string representation
- Parameters
serialized_value (
str
) – string representation- Returns
self
- Return type
-
from_dict
(dict_value)[source]¶ Set value from a dictionary representation
- Parameters
dict_value (
dict
) – dictionary representation- Returns
self
- Return type
-
class
obj_tables.chem.core.
ChemicalStructureFormat
[source]¶ Bases:
int
,wc_utils.util.enumerate.CaseInsensitiveEnum
Format of a chemical structure
-
class
obj_tables.chem.core.
ChemicalStructureAttribute
(verbose_name='', description='The InChI, SMILES-, BpForms, BcForms-encoded structure of a compound.nnExamples:n Small molecules (SMILES): C([N+])C([O-])=On DNA (BpForms/dna): A{m2C}GTn RNA (BpForms/rna): AC{02G}Un Protein (BpForms/protein): RNC{AA0037}En Complex (BcForms): 2 * subunit-A + subunit-B', primary=False, unique=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Attribute for the structures of chemical compounds
- Parameters
verbose_name (
str
, optional) – verbose namedescription (
str
, optional) – descriptionprimary (
bool
, optional) – indicate if attribute is primary attributeunique (
bool
, optional) – indicate if attribute value must be unique
-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – string representation of structure- Returns
str
: cleaned valuecore.InvalidAttribute
: cleaning error
- Return type
tuple
-
from_builtin
(json)[source]¶ Decode a simple Python representation (dict, list, str, float, bool, None) of a value of the attribute that is compatible with JSON and YAML
- Parameters
json (
dict
) – simple Python representation of a value of the attribute- Returns
chemical structure
- Return type
-
get_xlsx_validation
(sheet_models=None, doc_metadata_model=None)[source]¶ Get XLSX validation
- Parameters
sheet_models (
list
ofModel
, optional) – models encoded as separate sheetsdoc_metadata_model (
type
) – model whose worksheet contains the document metadata
- Returns
validation
- Return type
wc_utils.workbook.io.FieldValidation
-
serialize
(value)[source]¶ Serialize chemical structure
- Parameters
value (
ChemicalStructure
) – structure- Returns
string representation
- Return type
str
-
to_builtin
(value)[source]¶ Encode a value of the attribute using a simple Python representation (dict, list, str, float, bool, None) that is compatible with JSON and YAML
- Parameters
value (
ChemicalStructure
) – chemical structure- Returns
simple Python representation of a value of the attribute
- Return type
dict
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
ChemicalStructure
) – value of attribute to validate
- Returns
- None if attribute is valid, other return list of
errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-
validate_unique
(objects, values)[source]¶ Determine if the attribute values are unique
- Parameters
objects (
list
ofModel
) – list ofModel
objectsvalues (
list
ofChemicalStructure
) – list of values
- Returns
- None if values are unique, otherwise return a
list of errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-
class
obj_tables.chem.core.
ReactionEquation
[source]¶ Bases:
list
Reaction equation
-
class
ParseTreeTransformer
(species=None, compartments=None)[source]¶ Bases:
lark.visitors.Transformer
Transforms parse trees into an instance of
ReactionEquation
- Parameters
species (
dict
, optional) – dictionary that maps species ids to instancescompartments (
dict
, optional) – dictionary that maps compartment ids to instances
-
deserialize
(value, species=None, compartments=None)[source]¶ Set the participants from a string representation
- Parameters
value (
str
) – string representationspecies (
dict
, optional) – dictionary that maps species ids to instancescompartments (
dict
, optional) – dictionary that maps compartment ids to instances
-
file
= <_io.TextIOWrapper name='/root/project/obj_tables/chem/reaction_equation.lark' mode='r' encoding='UTF-8'>[source]¶
-
is_equal
(other)[source]¶ Determine if two reaction equations are semantically equivalent
- Parameters
other (
ReactionEquation
) – other reaction equation- Returns
True
if the objects are semantically equivalent- Return type
bool
-
class
-
class
obj_tables.chem.core.
ReactionParticipant
(species=None, compartment=None, stoichiometry=None)[source]¶ Bases:
object
Participant in a reaction
- Parameters
species (
str
orcore.Model
, optional) – speciescompartment (
str
orcore.Model
, optional) – compartmentstoichiometry (
float
, optional) – stoichiometry
-
is_equal
(other)[source]¶ Determine if two reaction participants are semantically equivalent
- Parameters
other (
ReactionParticipant
) – other reaction equation- Returns
True
if the objects are semantically equivalent- Return type
bool
-
class
obj_tables.chem.core.
ReactionEquationAttribute
(verbose_name='', description="A reaction equation (e.g. 'A[c] <=> B[e]', '[c]: A <=> B')", none=True, unique=False, species_cls=None, compartment_cls=None)[source]¶ Bases:
obj_tables.core.BaseRelatedAttribute
,obj_tables.core.LiteralAttribute
Reaction equation attribute
-
species_cls
[source]¶ class which represents species compartment_cls (
type
orstr
): class which represents compartments- Type
type
orstr
- Parameters
verbose_name (
str
, optional) – verbose namedescription (
str
, optional) – descriptionnone (
bool
, optional) – ifFalse
, the attribute is invalid if its value isNone
unique (
bool
, optional) – indicate if attribute value must be uniquespecies_cls (
type
orstr
, optional) – class which represents speciescompartment_cls (
type
orstr
, optional) – class which represents compartments
-
deserialize
(value, objects=None, decoded=None)[source]¶ Deserialize value
- Parameters
value (
str
) – semantically equivalent representationobjects (
dict
, optional) – dictionary of objects, grouped by modeldecoded (
dict
, optional) – dictionary of objects that have already been decoded
- Returns
ReactionEquation
: cleaned valuecore.InvalidAttribute
: cleaning error
- Return type
tuple
-
from_builtin
(json)[source]¶ Decode a simple Python representation (dict, list, str, float, bool, None) of a value of the attribute that is compatible with JSON and YAML
- Parameters
json (
dict
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
-
get_xlsx_validation
(sheet_models=None, doc_metadata_model=None)[source]¶ Get XLSX validation
- Parameters
sheet_models (
list
ofModel
, optional) – models encoded as separate sheetsdoc_metadata_model (
type
) – model whose worksheet contains the document metadata
- Returns
validation
- Return type
wc_utils.workbook.io.FieldValidation
-
serialize
(value)[source]¶ Serialize string
- Parameters
value (
ReactionEquation
) – Python representation- Returns
simple Python representation
- Return type
str
-
to_builtin
(value)[source]¶ Encode a value of the attribute using a simple Python representation (dict, list, str, float, bool, None) that is compatible with JSON and YAML
- Parameters
value (
ReactionEquation
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
dict
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
ReactionEquation
) – value of attribute to validate
- Returns
- None if attribute is valid, other return
list of errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-
validate_unique
(objects, values)[source]¶ Determine if the attribute values are unique
- Parameters
objects (
list
ofModel
) – list ofModel
objectsvalues (
list
ofReactionEquation
) – list of values
- Returns
- None if values are unique, otherwise return a
list of errors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
or None
-