sbmlutils.metadata.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.
Module Contents¶
Classes¶
Class for handling SBML annotations defined in external source. |
|
Helper class for annotating SBML models. |
Functions¶
|
Annotate a given SBML file with the provided annotations. |
|
Annotates given SBML document using the annotations file. |
Attributes¶
- sbmlutils.metadata.annotator.annotate_sbml(source, annotations_path, filepath)[source]¶
Annotate a given SBML file with the provided annotations.
- Parameters
source (Union[pathlib.Path, str]) – SBML to annotation
annotations_path (pathlib.Path) – external file with annotations
filepath (pathlib.Path) – annotated SBML file
- Returns
annotated SBMLDocument
- Return type
libsbml.SBMLDocument
- sbmlutils.metadata.annotator.annotate_sbml_doc(doc, external_annotations)[source]¶
Annotates given SBML document using the annotations file.
- Parameters
doc (libsbml.SBMLDocument) – SBMLDocument
external_annotations (List[ExternalAnnotation]) – ModelAnnotations
- Returns
annotated SBMLDocument
- Return type
libsbml.SBMLDocument
- class sbmlutils.metadata.annotator.ExternalAnnotation(d)[source]¶
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
- Parameters
d (Dict) –
- class sbmlutils.metadata.annotator.ModelAnnotator(doc, annotations)[source]¶
Helper class for annotating SBML models.
- Parameters
doc (libsbml.SBMLDocument) –
annotations (Iterable[ExternalAnnotation]) –
- _get_ids_from_model()[source]¶
Create dictionary of ids for given model for lookup.
- Returns
- Return type
Dict[str, List[str]]
- static _get_matching_ids(ids, pattern)[source]¶
Ids matching the regular expression.
- Parameters
ids (Iterable[str]) –
pattern (str) –
- Return type
List[str]
- static _elements_from_ids(model, sbml_ids, sbml_type=None)[source]¶
Get list of SBML elements from given ids.
- Parameters
model (libsbml.Model) – SBML model
sbml_ids (Iterable[str]) – SBML SIds
sbml_type (Optional[str]) – type of SBML objects
- Returns
- Return type
List[libsbml.SBase]
- _annotate_elements(elements, ex_a)[source]¶
Annotate given elements with annotation.
- Parameters
elements (Iterable[libsbml.SBase]) – SBase elements to annotate
ex_a (ExternalAnnotation) – annotation
- Returns
- Return type
None
- static get_SBMLQualifier(qualifier_str, qualifier_type)[source]¶
Lookup of SBMLQualifier for given qualifier string.
- Parameters
qualifier_type (str) – BQB or BQM
qualifier_str (str) –
- Returns
SBML qualifier string
- Return type
str
- static annotate_sbase(sbase, annotation)[source]¶
Annotate SBase based on given annotation data.
- Parameters
sbase (libsbml.SBase) – libsbml.SBase
annotation (pymetadata.core.annotation.RDFAnnotation) – Annotation
- Returns
- Return type
None
- static read_annotations_df(file_path, file_format='*')[source]¶
Read annotations from given file into DataFrame.
Supports “xlsx”, “tsv”, “csv”, “json”, “*”
- Parameters
file_path (pathlib.Path) – either path to file, or data in dict format
file_format (str) – annotation file format
- Returns
pandas.DataFrame
- Return type
pandas.DataFrame
- static read_annotations(file_path, file_format='*')[source]¶
Read annotations from given file into DataFrame.
Supports “xlsx”, “tsv”, “csv”, “json”, “*”
- Parameters
file_path (pathlib.Path) – either path to file, or data in dict format
file_format (str) – annotation file format
- Returns
list of annotation objects
- Return type
List[ExternalAnnotation]