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 list

  • b (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 is False

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 of str) – nested list of string

  • prefix (str, optional) – prefix

  • indentation (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) – value

  • type (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 of numpy.ndarray) – list of NumPy arrays

Returns

list of padded arrays

Return type

list of numpy.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 value

  • type (ValueType) – type

Returns

Python representation of the value

Return type

object

biosimulators_utils.utils.core.patch_dict(dictionary, patch)[source]

Recursively patch the attributes of a dictionary

Parameters
  • dictionary (dict) – dictionary

  • patch (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 of str) – errors

  • warnings (nested list of str) – warnings

  • error_summary (str, optional) – summary of errors

  • warning_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 value

  • type (ValueType) – type

Returns

True, if a value is a valid string representation of type type

Return type

bool

biosimulators_utils.utils.core.validate_value(val, type)[source]

Determine if a value is a valid instance of type type

Parameters
  • val (object) – value

  • type (ValueType) – type

Returns

True, if a value is a valid instance of type type

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

code: str[source]
name: str[source]
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: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry[source]
description: str[source]
home_url: str[source]
id: int[source]
name: str[source]
ror_id: str[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

created: datetime.datetime[source]
deprecated: bool[source]
deprecated_date: datetime.datetime[source]
description: str[source]
embedded_in_lui: bool[source]
id: int[source]
mir_id: str[source]
modified: datetime.datetime[source]
name: str[source]
pattern: _regex.Pattern[source]
prefix: str[source]
resources: List[biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespaceResource][source]
sample_id: str[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: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry[source]
deprecated: bool[source]
deprecated_date: datetime.datetime[source]
description: str[source]
home_url: str[source]
id: int[source]
institution: biosimulators_utils.utils.identifiers_org.IdentifiersOrgInstitution[source]
mir_id: str[source]
name: str[source]
official: bool[source]
provider_code: str[source]
sample_id: str[source]
url_pattern: str[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

IdentifiersOrgNamespace

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

biosimulators_utils.utils.logging.get_logger(name='log', filename_pattern='~/.biosimulators-utils/logs/{}.log')[source]

Get a logger

Parameters
  • name (str, optional) – name

  • filename_pattern (str, optional) – pattern for paths for log files

Returns

logger

Return type

logging.Logger