annotator¶
Annotation of SBML models.
Handle the XML annotations and notes in SBML. Annotate models from information in annotation csv files. Thereby a model can be fully annotated from information stored in a separate annotation store.
Annotation is performed via searching for ontology terms which describe the model and model components. A standard workflow is looking up the components for instance in things like OLS ontology lookup service.
ExternalAnnotation
¶
Class for handling SBML annotations defined in external source.
This corresponds to a single entry in the external annotation file. Allows to handle more complex annotation scenarios, e.g. patterns for identifiers.
The columns are
pattern sbml_type annotation_type qualifier resource name
Initialize ExternalAnnotation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
dict[str, Any]
|
one row of the annotation file, |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
if a required column is missing |
ValueError
|
if a value is not one of the supported choices |
ModelAnnotator
¶
Helper class for annotating SBML models.
Initialize ModelAnnotator.
:param doc: SBMLDocument :param annotations: iterable of ModelAnnotation
annotate_model
¶
Annotate the model with the given annotations.
This annotates a whole document, so a resource which cannot be
canonicalized is reported once for its collection rather than once
for every element it is written on, see collect_resource_losses.
get_SBMLQualifier
staticmethod
¶
Lookup of SBMLQualifier for given qualifier string.
:param qualifier_type: BQB or BQM :return: SBML qualifier string
annotate_sbase
staticmethod
¶
Annotate SBase based on given annotation data.
:param sbase: libsbml.SBase :param annotation: Annotation :return:
read_annotations_df
staticmethod
¶
Read annotations from given file into DataFrame.
Supports "xlsx", "tsv", "csv", "json", "*"
:param file_path: either path to file, or data in dict format :param file_format: annotation file format :return: pandas.DataFrame
read_annotations
staticmethod
¶
Read annotations from given file into DataFrame.
Supports "xlsx", "tsv", "csv", "json", "*"
:param file_path: either path to file, or data in dict format :param file_format: annotation file format :return: list of annotation objects
collect_resource_losses
¶
Report the resources written as given once per collection.
An annotation resource which pymetadata cannot canonicalize without
changing what it says is written as given, see _resource_for_cvterm.
A document can hold tens of thousands of resources of one collection, and
what is malformed in one of them is as a rule malformed in all of them.
Inside this context each of them is collected and logged as a single
warning per collection, in the order of the collection ids; the detail of
every single resource is logged at debug. Outside it, every resource is
warned about on its own.
The context is entered by the code which writes a whole document. A context inside an active one collects into it and reports nothing of its own, so that a document which is created and then annotated from a file is still reported once.
Returns:
| Type | Description |
|---|---|
AbstractContextManager[None]
|
the context manager |
annotate_sbml
¶
Annotate a given SBML file with the provided annotations.
:param source: SBML to annotation :param annotations_path: external file with annotations :param filepath: annotated SBML file :return: annotated SBMLDocument
annotate_sbml_doc
¶
Annotates given SBML document using the annotations file.
:param doc: SBMLDocument :param external_annotations: ModelAnnotations :return: annotated SBMLDocument