3.1.1.4. obj_tables.sci package¶
3.1.1.4.1. Submodules¶
3.1.1.4.2. obj_tables.sci.onto module¶
Ontology attributes
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-01-14
- Copyright
2019, Karr Lab
- License
MIT
-
class
obj_tables.sci.onto.
OntoTermAttribute
(ontology, namespace=None, namespace_sep=':', terms=None, none=True, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description='', primary=False, unique=False, unique_case_insensitive=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Ontology attribute
- Parameters
ontology (
pronto.Ontology
) – ontologynamespace (
str
, optional) – prefix in term idsnamespace_sep (
str
, optional) – namespace separatorterms (
list
ofpronto.Term
, optional) – list of allowed terms. IfNone
, all terms are allowed.none (
bool
, optional) – ifFalse
, the attribute is invalid if its value isNone
default (
pronto.Term
, optional) – default valuedefault_cleaned_value (
pronto.Term
, optional) – value to replaceNone
values with during cleaningnone_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 uniqueunique_case_insensitive (
bool
, optional) – if true, conduct case-insensitive test of uniqueness
- Raises
-
clean
(value)[source]¶ Convert attribute value into the appropriate type
- Parameters
value (
object
) – value of attribute to clean- Returns
pronto.Term
orNone
: cleaned valuecore.InvalidAttribute
orNone
: cleaning error
- Return type
tuple
-
copy_value
(value, objects_and_copies)[source]¶ Copy value
- Parameters
value (
object
) – valueobjects_and_copies (
dict
) – dictionary that maps objects to their copies
- Returns
copy of value
- Return type
object
-
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 (
str
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
pronto.Term
-
get_default_cleaned_value
()[source]¶ Get value to replace
None
values with during cleaning- Returns
initial value
- Return type
object
-
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 ontology instance
- Parameters
value (
pronto.Term
) – 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 (
pronto.Term
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
str
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value of the attribute- Parameters
obj (
Model
) – object being validatedvalue (
pronto.Term
) – value of attribute to validate
- Returns
None
if attribute is valid, other return list oferrors as an instance of
core.InvalidAttribute
- Return type
core.InvalidAttribute
orNone
3.1.1.4.3. obj_tables.sci.refs module¶
Attributes for references
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-09-20
- Copyright
2019, Karr Lab
- License
MIT
-
class
obj_tables.sci.refs.
Identifier
(namespace=None, id=None)[source]¶ Bases:
object
An identifier in a namespace registered with Identifiers.org
- Parameters
namespace (
str
, optional) – namespaceid (
str
, optional) – identifier in namespace
-
from_dict
(value)[source]¶ Set value from a dictionary representation
- Parameters
value (
dict
) – dictionary representation- Returns
self
- Return type
-
from_str
(value)[source]¶ Set value from a string representation (
'id' @ 'namespace'
)- Parameters
value (
value
) – string representation- Returns
self
- Return type
- Raises
ValueError – if string representation doesn’t match the pattern
'id' @ 'namespace'
-
get_url
()[source]¶ Get the URL for the webpage for the identifier
- Returns
URL for the webpage for the identifier
- Return type
str
-
class
obj_tables.sci.refs.
IdentifierAttribute
[source]¶ Bases:
obj_tables.core.LiteralAttribute
Identifier attribute
Args: init_value (
object
, optional): initial value default (object
, optional): default value default_cleaned_value (object
, optional): value to replaceNone
values with during cleaning, or function which computes the value to replaceNone
valuesnone_value (
object
, optional): none value verbose_name (str
, optional): verbose name description (str
, optional): description primary (bool
, optional): indicate if attribute is primary attribute unique (bool
, optional): indicate if attribute value must be unique unique_case_insensitive (bool
, optional): if true, conduct case-insensitive test of uniqueness-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – string representation of structure- Returns
Identifier
: 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 (
list
ofint
) – simple Python representation of a value of the attribute- Returns
value of attribute to validate
- 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 (
Identifier
) – value of attribute to validate- 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 (
Identifier
) – value of attribute to validate- Returns
simple Python representation of a value of the attribute
- Return type
list
ofint
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
Identifier
) – 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
-
-
class
obj_tables.sci.refs.
IdentifiersAttribute
[source]¶ Bases:
obj_tables.core.LiteralAttribute
Identifiers attribute
Args: init_value (
object
, optional): initial value default (object
, optional): default value default_cleaned_value (object
, optional): value to replaceNone
values with during cleaning, or function which computes the value to replaceNone
valuesnone_value (
object
, optional): none value verbose_name (str
, optional): verbose name description (str
, optional): description primary (bool
, optional): indicate if attribute is primary attribute unique (bool
, optional): indicate if attribute value must be unique unique_case_insensitive (bool
, optional): if true, conduct case-insensitive test of uniqueness-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – string representation of structure- Returns
Identifier
: 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 (
list
ofint
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
list
ofint
-
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 (
list
ofint
) – 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 (
list
ofIdentifier
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
list
ofint
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
list
ofIdentifier
) – 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
-
-
class
obj_tables.sci.refs.
DoiAttribute
(primary=False, unique=True)[source]¶ Bases:
obj_tables.core.RegexAttribute
DOI attribute
- Parameters
primary (
bool
, optional) – indicate if attribute is primary attributeunique (
bool
, optional) – indicate if attribute value must be unique
-
class
obj_tables.sci.refs.
DoisAttribute
[source]¶ Bases:
obj_tables.core.LiteralAttribute
DOIs attribute
Args: init_value (
object
, optional): initial value default (object
, optional): default value default_cleaned_value (object
, optional): value to replaceNone
values with during cleaning, or function which computes the value to replaceNone
valuesnone_value (
object
, optional): none value verbose_name (str
, optional): verbose name description (str
, optional): description primary (bool
, optional): indicate if attribute is primary attribute unique (bool
, optional): indicate if attribute value must be unique unique_case_insensitive (bool
, optional): if true, conduct case-insensitive test of uniqueness-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – string representation of structure- Returns
list
ofint
: 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 (
list
ofint
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
list
ofint
-
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 (
list
ofint
) – 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 (
list
ofint
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
list
ofint
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
list
ofstr
) – 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
-
-
class
obj_tables.sci.refs.
PubMedIdAttribute
(primary=False, unique=True)[source]¶ Bases:
obj_tables.core.IntegerAttribute
PubMed id attribute
- Parameters
primary (
bool
, optional) – indicate if attribute is primary attributeunique (
bool
, optional) – indicate if attribute value must be unique
-
class
obj_tables.sci.refs.
PubMedIdsAttribute
[source]¶ Bases:
obj_tables.core.LiteralAttribute
PubMed ids attribute
Args: init_value (
object
, optional): initial value default (object
, optional): default value default_cleaned_value (object
, optional): value to replaceNone
values with during cleaning, or function which computes the value to replaceNone
valuesnone_value (
object
, optional): none value verbose_name (str
, optional): verbose name description (str
, optional): description primary (bool
, optional): indicate if attribute is primary attribute unique (bool
, optional): indicate if attribute value must be unique unique_case_insensitive (bool
, optional): if true, conduct case-insensitive test of uniqueness-
deserialize
(value)[source]¶ Deserialize value
- Parameters
value (
str
) – string representation of structure- Returns
list
ofint
: 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 (
list
ofint
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
list
ofint
-
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 (
list
ofint
) – 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 (
list
ofint
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
list
ofint
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value- Parameters
obj (
Model
) – class being validatedvalue (
list
ofIdentifier
) – 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
-
3.1.1.4.4. obj_tables.sci.uncertainty module¶
Uncertain value attribute
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2012-03-05
- Copyright
2020, Karr Lab
- License
MIT
-
class
obj_tables.sci.uncertainty.
UncertainFloatAttribute
(none=True, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description="Measurement (e.g. 'x ± y')", primary=False, unique=False, unique_case_insensitive=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Attribute for a value and its uncertainty
- Parameters
none (
bool
, optional) – ifFalse
, the attribute is invalid if its value isNone
default (
uncertainties.core.Variable
, optional) – default valuedefault_cleaned_value (
uncertainties.core.Variable
, optional) – value to replaceNone
values with during cleaningnone_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 uniqueunique_case_insensitive (
bool
, optional) – if true, conduct case-insensitive test of uniqueness
-
clean
(value)[source]¶ Convert attribute value into the appropriate type
- Parameters
value (
object
) – value of attribute to clean- Returns
tuple of cleaned value and cleaning error
- Return type
tuple
ofstr
,core.InvalidAttribute
orNone
-
copy_value
(value, objects_and_copies)[source]¶ Copy value
- Parameters
value (
uncertainties.core.Variable
) – valueobjects_and_copies (
dict
) – dictionary that maps objects to their copies
- Returns
copy of value
- Return type
uncertainties.core.Variable
-
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
uncertainties.core.Variable
-
get_default
()[source]¶ Get default value for attribute
- Returns
initial value
- Return type
uncertainties.core.Variable
-
get_default_cleaned_value
()[source]¶ Get value to replace
None
values with during cleaning- Returns
initial value
- Return type
uncertainties.core.Variable
-
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 to a string
- Parameters
value (
uncertainties.core.Variable
) – 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 (
uncertainties.core.Variable
) – 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 for this UncertainFloatAttribute- Parameters
obj (
Model
) – class being validatedvalue (
uncertainties.core.Variable
) – 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
3.1.1.4.5. obj_tables.sci.units module¶
Unit attribute
- Author
Jonathan Karr <karr@mssm.edu>
- Date
2019-01-20
- Copyright
2019, Karr Lab
- License
MIT
-
class
obj_tables.sci.units.
UnitAttribute
(registry, choices=None, none=True, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description="Units (e.g. 'second', 'meter', or 'gram')", primary=False, unique=False, unique_case_insensitive=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Unit attribute
- Parameters
registry (
pint.UnitRegistry
) – unit registrychoices (
tuple
ofpint.unit._Unit
, optional) – allowed unitsnone (
bool
, optional) – ifFalse
, the attribute is invalid if its value isNone
default (
registry.Unit
, optional) – default valuedefault_cleaned_value (
registry.Unit
, optional) – value to replaceNone
values with during cleaningnone_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 uniqueunique_case_insensitive (
bool
, optional) – if true, conduct case-insensitive test of uniqueness
- Raises
ValueError – if registry is not an instance of
pint.UnitRegistry
ValueError – if default is not an instance of
registry.Unit
ValueError – if default_cleaned_value is not an instance of
registry.Unit
ValueError – if a choice is not an instance of
registry.Unit
-
clean
(value)[source]¶ Convert attribute value into the appropriate type
- Parameters
value (
object
) – value of attribute to clean- Returns
tuple of cleaned value and cleaning error
- Return type
tuple
ofstr
,core.InvalidAttribute
orNone
-
copy_value
(value, objects_and_copies)[source]¶ Copy value
- Parameters
value (
pint.unit._Unit
) – valueobjects_and_copies (
dict
) – dictionary that maps objects to their copies
- Returns
copy of value
- Return type
pint.unit._Unit
-
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 (
str
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
pint.unit._Unit
-
get_default
()[source]¶ Get default value for attribute
- Returns
initial value
- Return type
pint.unit._Unit
-
get_default_cleaned_value
()[source]¶ Get value to replace
None
values with during cleaning- Returns
initial value
- Return type
pint.unit._Unit
-
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 (
pint.unit._Unit
) – 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 (
pint.unit._Unit
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
str
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value for this UnitAttribute- Parameters
obj (
Model
) – class being validatedvalue (
pint.unit._Unit
) – 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
-
class
obj_tables.sci.units.
QuantityAttribute
(registry, choices=None, none=True, default=None, default_cleaned_value=None, none_value=None, verbose_name='', description="Units (e.g. 'second', 'meter', or 'gram')", primary=False, unique=False, unique_case_insensitive=False)[source]¶ Bases:
obj_tables.core.LiteralAttribute
Quantity (magntitude and units) attribute
- Parameters
registry (
pint.UnitRegistry
) – unit registrychoices (
tuple
ofpint.unit._Unit
, optional) – allowed unitsnone (
bool
, optional) – ifFalse
, the attribute is invalid if its value isNone
default (
pint.unit.unit
, optional) – default valuedefault_cleaned_value (
str
, optional) – value to replaceNone
values with during cleaningnone_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 uniqueunique_case_insensitive (
bool
, optional) – if true, conduct case-insensitive test of uniqueness
- Raises
ValueError – if registry is not an instance of
pint.UnitRegistry
ValueError – if default is not an instance of
registry.Unit
ValueError – if default_cleaned_value is not an instance of
registry.Unit
ValueError – if a choice is not an instance of
registry.Unit
-
clean
(value)[source]¶ Convert attribute value into the appropriate type
- Parameters
value (
object
) – value of attribute to clean- Returns
tuple of cleaned value and cleaning error
- Return type
tuple
ofstr
,core.InvalidAttribute
orNone
-
copy_value
(value, objects_and_copies)[source]¶ Copy value
- Parameters
value (
pint.quantity._Quantity
) – valueobjects_and_copies (
dict
) – dictionary that maps objects to their copies
- Returns
copy of value
- Return type
pint.quantity._Quantity
-
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 (
str
) – simple Python representation of a value of the attribute- Returns
decoded value of the attribute
- Return type
pint.quantity._Quantity
-
get_default
()[source]¶ Get default value for attribute
- Returns
initial value
- Return type
pint.quantity._Quantity
-
get_default_cleaned_value
()[source]¶ Get value to replace
None
values with during cleaning- Returns
initial value
- Return type
pint.quantity._Quantity
-
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 (
pint.quantity._Quantity
) – 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 (
pint.quantity._Quantity
) – value of the attribute- Returns
simple Python representation of a value of the attribute
- Return type
str
-
validate
(obj, value)[source]¶ Determine if
value
is a valid value for this QuantityAttribute- Parameters
obj (
Model
) – class being validatedvalue (
pint.quantity._Quantity
) – 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