Usage

Biomappings Python package.

Utilities for generating predictions with pyobo/gilda.

append_gilda_predictions(prefix: str, target_prefixes: str | Iterable[str], provenance: str, *, relation: str = 'skos:exactMatch', custom_filter: Mapping[str, Mapping[str, Mapping[str, str]]] | None = None, unnamed: Iterable[str] | None = None, identifiers_are_names: bool = False) None[source]

Add gilda predictions to the Biomappings predictions.tsv file.

Parameters:
  • prefix – The source prefix

  • target_prefixes – The target prefix or prefixes

  • provenance – The provenance text. Typically generated with biomappings.utils.get_script_url(__file__).

  • relation – The relationship. Defaults to skos:exactMatch.

  • custom_filter – A triple nested dictionary from source prefix to target prefix to source id to target id. Any source prefix, target prefix, source id combinations in this dictionary will be filtered.

  • unnamed – An optional list of prefixes whose identifiers should be considered as names (e.g., CCLE, FPLX)

  • identifiers_are_names – The source prefix’s identifiers should be considered as names

iter_prediction_tuples(prefix: str, provenance: str, *, relation: str = 'skos:exactMatch', grounder: Grounder | None = None, identifiers_are_names: bool = False) Iterable[PredictionTuple][source]

Iterate over prediction tuples for a given prefix.

filter_custom(predictions: Iterable[PredictionTuple], custom_filter: Mapping[str, Mapping[str, Mapping[str, str]]]) Iterable[PredictionTuple][source]

Filter out custom mappings.

filter_existing_xrefs(predictions: Iterable[PredictionTuple], prefixes: Iterable[str]) Iterable[PredictionTuple][source]

Filter predictions that match xrefs already loaded through PyOBO.

has_mapping(prefix: str, identifier: str, target_prefix: str) bool[source]

Check if there’s already a mapping available for this entity in a target namespace.

Utilities.

get_git_hash() str | None[source]

Get the git hash.

Returns:

The git hash, equals ‘UNHASHED’ if encountered CalledProcessError, signifying that the code is not installed in development mode.

commit(message: str) str | None[source]

Make a commit with the following message.

push(branch_name: str | None = None) str | None[source]

Push the git repo.

not_main() bool[source]

Return if on the master branch.

get_branch() str[source]

Return current git branch.

get_script_url(fname: str) str[source]

Get the source path for this script.

Parameters:

fname – Pass __file__ as the argument to this function.

Returns:

The script’s URL to GitHub

get_canonical_tuple(mapping: Mapping[str, Any]) Tuple[str, str, str, str][source]

Get the canonical tuple from a mapping entry.

exception UnregisteredPrefix[source]

Raised for an invalid prefix.

exception UnstandardizedPrefix(prefix: str, norm_prefix: str)[source]

Raised for an unstandardized prefix.

Initialize the error.

Parameters:
  • prefix – A CURIE’s prefix

  • norm_prefix – The normalized prefid

exception InvalidIdentifier(prefix: str, identifier: str)[source]

Raised for an invalid identifier.

Initialize the error.

Parameters:
  • prefix – A CURIE’s prefix

  • identifier – A CURIE’s identifier

exception InvalidIdentifierPattern(prefix: str, identifier: str, pattern)[source]

Raised for an identifier that doesn’t match the pattern.

Initialize the error.

Parameters:
  • prefix – A CURIE’s prefix

  • identifier – A CURIE’s identifier

  • pattern – A regular expression pattern

exception InvalidNormIdentifier(prefix: str, identifier: str, norm_identifier: str)[source]

Raised for an invalid normalized identifier.

Initialize the error.

Parameters:
  • prefix – A CURIE’s prefix

  • identifier – A CURIE’s identifier

  • norm_identifier – The normalized version of the identifier

check_valid_prefix_id(prefix: str, identifier: str)[source]

Check the prefix/identifier pair is valid.

Parameters:
  • prefix – The prefix from a CURIE

  • identifier – The local unique identifier from a CURIE

Raises:
  • UnregisteredPrefix – if the prefix is not registered with the Bioregistry

  • UnstandardizedPrefix – if the prefix is not standardized w.r.t. the Bioregistry

  • InvalidNormIdentifier – if the identifier is not standardized, either against the MIRIAM standard, if available, or against the Bioregistry standard

  • InvalidIdentifierPattern – if the does not match the appropriate regular expression for MIRIAM (if available) or for the Bioregistry. If no regular expression is available, then this check is not applied.

  • RuntimeError – If the preconditions for miriam standardization aren’t met. However, this shouldn’t be possible in practice, and this documentation is merely a formality.

get_curie(prefix: str, identifier: str, *, preferred: bool = False) str[source]

Get a normalized curie from a pre-parsed prefix/identifier pair.

CMapping

A filter 3-dictionary of source prefix to target prefix to source identifier to target identifier

alias of Mapping[str, Mapping[str, Mapping[str, str]]]