biosimulators_utils.utils package — BioSimulators utils 0.1.154 documentation

# 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)

  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)

  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=' ')

  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)

  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)

  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)

  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)

  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)

  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)

  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)

  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)

  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)

  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)

  Bases: `object`

  code: str
  name: str

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)

  Bases: `object`

  country: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry
  description: str
  home_url: str
  id: int
  name: str
  ror_id: str

class biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespace(id: int, mir_id: str, prefix: str, name: str, description: str, pattern: re.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)

  Bases: `object`

  created: datetime.datetime
  deprecated: bool
  deprecated_date: datetime.datetime
  description: str
  embedded_in_lui: bool
  id: int
  mir_id: str
  modified: datetime.datetime
  name: str
  pattern: re.Pattern
  prefix: str
  resources: List[biosimulators_utils.utils.identifiers_org.IdentifiersOrgNamespaceResource]
  sample_id: str

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)

  Bases: `object`

  country: biosimulators_utils.utils.identifiers_org.IdentifiersOrgCountry
  deprecated: bool
  deprecated_date: datetime.datetime
  description: str
  home_url: str
  id: int
  institution: biosimulators_utils.utils.identifiers_org.IdentifiersOrgInstitution
  mir_id: str
  name: str
  official: bool
  provider_code: str
  sample_id: str
  url_pattern: str

exception biosimulators_utils.utils.identifiers_org.InvalidIdentifiersOrgUri

  Bases: `Exception`

  An invalid Identifers.org URI

biosimulators_utils.utils.identifiers_org.get_identifiers_org_namespace(prefix)

  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()

  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.validate_identifiers_org_uri(uri)

  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')

  Get a logger

  Parameters

    - name (`str`, optional) – name

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

  Returns

    logger

  Return type

    `logging.Logger`