biosimulators_utils.utils package#
Submodules#
biosimulators_utils.utils.core module#
Miscellaneous utilities
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT
- biosimulators_utils.utils.core.are_lists_equal(a, b)[source]#
Determine if two lists are equal, optionally up to the order of the elements
- Parameters:
a (
list
) – first listb (
list
) – second list
- Returns:
True
, if lists are equal- Return type:
bool
- biosimulators_utils.utils.core.assert_exception(success, exception)[source]#
Raise an error if
success
isFalse
- Parameters:
success (
bool
)exception (
Exception
)
- Raises:
Exception –
- biosimulators_utils.utils.core.flatten_nested_list_of_strings(nested_list, prefix='- ', indent=' ')[source]#
Flatten a nested list of strings
- Parameters:
nested_list (nested
list
ofstr
) – nested list of stringprefix (
str
, optional) – prefixindentation (
str
, optional) – indentation
- Returns:
flattened string
- Return type:
str
- biosimulators_utils.utils.core.format_float(val)[source]#
Format a float in scientific notation
- Parameters:
val (
float
) – value- Returns:
value formatted as a string
- Return type:
str
- biosimulators_utils.utils.core.format_value(val, type)[source]#
Format a value as a string (e.g., for use with an attribute of an XML object)
- Parameters:
val (
object
) – valuetype (
ValueType
) – type
- Returns:
string representation of the value
- Return type:
str
- biosimulators_utils.utils.core.none_sorted(arr, key=None)[source]#
Sort an error that contains
None
- Parameters:
arr (
list
) – array- Returns:
sorted array
- Return type:
list
- biosimulators_utils.utils.core.pad_arrays_to_consistent_shapes(arrays)[source]#
Pad a list of NumPy arrays to a consistent shape
- Parameters:
arrays (
list
ofnumpy.ndarray
) – list of NumPy arrays- Returns:
list of padded arrays
- Return type:
list
ofnumpy.ndarray
- biosimulators_utils.utils.core.parse_value(str_val, type)[source]#
Parse the string representation of a value (e.g., for use with an attribute of an XML object)
- Parameters:
str_val (
str
) – string representation of the valuetype (
ValueType
) – type
- Returns:
Python representation of the value
- Return type:
object
- biosimulators_utils.utils.core.patch_dict(dictionary: dict, patch: dict)[source]#
Recursively patch the attributes of a dictionary
- Parameters:
dictionary (
dict
) – dictionarypatch (
dict
) – patch
- biosimulators_utils.utils.core.raise_errors_warnings(errors, warnings=None, error_summary=None, warning_summary=None)[source]#
Raises errors and warnings
- Parameters:
errors (nested
list
ofstr
) – errorswarnings (nested
list
ofstr
) – warningserror_summary (
str
, optional) – summary of errorswarning_summary (
str
, optional) – summary of warnings
- Raises:
ValueError – if errors
- biosimulators_utils.utils.core.validate_str_value(str_val, type)[source]#
Determine if a value is a valid string representation of type
type
- Parameters:
str_val (
str
) – string representation of a valuetype (
ValueType
) – type
- Returns:
True
, if a value is a valid string representation of typetype
- Return type:
bool
biosimulators_utils.utils.identifiers_org module#
Utilities for working with Identifiers.org
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2021-08-04
- Copyright:
2021, Center for Reproducible Biomedical Modeling
- License:
MIT
- class biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry(code: str, name: str)[source]#
Bases:
object
- class biosimulators_utils.utils.identifiers_org.IdentifiersOrgInstitution(id: int, name: str, home_url: str, description: str, ror_id: str, country: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry)[source]#
Bases:
object
- country: IdentifiersOrgCountry[source]#
- class biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespace(id: int, mir_id: str, prefix: str, name: str, description: str, pattern: _regex.Pattern, embedded_in_lui: bool, sample_id: str, resources: List[biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespaceResource], deprecated: bool, deprecated_date: datetime.datetime, created: datetime.datetime, modified: datetime.datetime)[source]#
Bases:
object
- resources: List[IdentifiersOrgNamespaceResource][source]#
- class biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespaceResource(id: int, mir_id: str, name: str, description: str, url_pattern: str, official: bool, provider_code: str, sample_id: str, home_url: str, institution: biosimulators_utils.utils.identifiers_org.IdentifiersOrgInstitution, country: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry, deprecated: bool, deprecated_date: datetime.datetime)[source]#
Bases:
object
- country: IdentifiersOrgCountry[source]#
- institution: IdentifiersOrgInstitution[source]#
- exception biosimulators_utils.utils.identifiers_org.InvalidIdentifiersOrgUri[source]#
Bases:
Exception
An invalid Identifers.org URI
- biosimulators_utils.utils.identifiers_org.download_identifiers_org_namespaces()[source]#
Get the namespaces registered with Identifiers.org.
- Returns:
- dictionary that maps the prefix of each Identifiers.org namespace or
a tuple of its provider code and its prefix to its attributes
- Return type:
dict
- biosimulators_utils.utils.identifiers_org.get_identifiers_org_namespace(prefix)[source]#
Get an Identifiers.org namespace
- Parameters:
prefix (
str
) – prefix (e.g.,biosimulators
) or/
-separated tuple of a provider code and prefix (e.g,icahn/biosimulators
)- Returns:
namespace
- Return type:
- Raises:
InvalidIdentifiersOrgUri – if the prefix is not defined
- biosimulators_utils.utils.identifiers_org.get_identifiers_org_namespaces(reload=False)[source]#
Get the namespaces registered with Identifiers.org.
- Parameters:
reload (
bool
, optional) – whether to reload the namespaces from the Identifiers.org API- Returns:
- dictionary that maps the prefix of each Identifiers.org namespace or
a tuple of its provider code and its prefix to its attributes
- Return type:
dict
- biosimulators_utils.utils.identifiers_org.validate_identifiers_org_uri(uri)[source]#
Determine whether a URI is a validate for one of the namespaces registered with Identifiers.org
- Raises:
InvalidIdentifiersOrgUri – if the URI is not a valid with one of the namespaces registered with Identifiers.org
biosimulators_utils.utils.logging module#
Utilities for logging
- Author:
Jonathan Karr <karr@mssm.edu>
- Date:
2020-12-06
- Copyright:
2020, Center for Reproducible Biomedical Modeling
- License:
MIT