Logging Messages¶
Errors¶
This module contains base exceptions that are shared through the package.
Parse Exceptions¶
Exceptions for the BEL parser.
A message for “General Parser Failure” is displayed when a problem was caused due to an unforeseen error. The line number and original statement are printed for the user to debug.
-
exception
pybel.parser.exc.
BELParserWarning
(line_number, line, position, *args)[source]¶ The base PyBEL parser exception, which holds the line and position where a parsing problem occurred.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
BELSyntaxError
(line_number, line, position, *args)[source]¶ For general syntax errors.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
InconsistentDefinitionError
(line_number, line, position, definition)[source]¶ Base PyBEL error for redefinition.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
RedefinedNamespaceError
(line_number, line, position, definition)[source]¶ Raised when a namespace is redefined.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
RedefinedAnnotationError
(line_number, line, position, definition)[source]¶ Raised when an annotation is redefined.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
NameWarning
(line_number, line, position, name, *args)[source]¶ The base class for errors related to nomenclature.
Build a warning wrapping a given name.
-
exception
pybel.parser.exc.
NakedNameWarning
(line_number, line, position, name, *args)[source]¶ Raised when there is an identifier without a namespace. Enable lenient mode to suppress.
Build a warning wrapping a given name.
-
exception
pybel.parser.exc.
MissingDefaultNameWarning
(line_number, line, position, name, *args)[source]¶ Raised if reference to value not in default namespace.
Build a warning wrapping a given name.
-
exception
pybel.parser.exc.
NamespaceIdentifierWarning
(line_number, line, position, namespace, name)[source]¶ The base class for warnings related to namespace:name identifiers.
Initialize the namespace identifier warning.
-
exception
pybel.parser.exc.
UndefinedNamespaceWarning
(line_number, line, position, namespace, name)[source]¶ Raised if reference made to undefined namespace.
Initialize the namespace identifier warning.
-
exception
pybel.parser.exc.
MissingNamespaceNameWarning
(line_number, line, position, namespace, name)[source]¶ Raised if reference to value not in namespace.
Initialize the namespace identifier warning.
-
exception
pybel.parser.exc.
MissingNamespaceRegexWarning
(line_number, line, position, namespace, name)[source]¶ Raised if reference not matching regex.
Initialize the namespace identifier warning.
-
exception
pybel.parser.exc.
AnnotationWarning
(line_number, line, position, annotation, *args)[source]¶ Base exception for annotation warnings.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
UndefinedAnnotationWarning
(line_number, line, position, annotation, *args)[source]¶ Raised when an undefined annotation is used.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
MissingAnnotationKeyWarning
(line_number, line, position, annotation, *args)[source]¶ Raised when trying to unset an annotation that is not set.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
AnnotationIdentifierWarning
(line_number, line, position, annotation, value)[source]¶ Base exception for annotation:value pairs.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
IllegalAnnotationValueWarning
(line_number, line, position, annotation, value)[source]¶ Raised when an annotation has a value that does not belong to the original set of valid annotation values.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
MissingAnnotationRegexWarning
(line_number, line, position, annotation, value)[source]¶ Raised if annotation doesn’t match regex.
Build an AnnotationWarning.
-
exception
pybel.parser.exc.
VersionFormatWarning
(line_number, line, position, version_string)[source]¶ Raised if the version string doesn’t adhere to semantic versioning or
YYYYMMDD
format.Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
MetadataException
(line_number, line, position, *args)[source]¶ Base exception for issues with document metadata.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
MalformedMetadataException
(line_number, line, position, *args)[source]¶ Raised when an invalid metadata line is encountered.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
InvalidMetadataException
(line_number, line, position, key, value)[source]¶ Raised when an incorrect document metadata key is used.
Hint
Valid document metadata keys are:
Authors
ContactInfo
Copyright
Description
Disclaimer
Licenses
Name
Version
See also
BEL specification on the properties section
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
MissingMetadataException
(line_number, line, position, key)[source]¶ Raised when a BEL Script is missing critical metadata.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
InvalidCitationLengthException
(line_number, line, position, *args)[source]¶ Base exception raised when the format for a citation is wrong.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
CitationTooShortException
(line_number, line, position, *args)[source]¶ Raised when a citation does not have the minimum of {type, name, reference}.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
CitationTooLongException
(line_number, line, position, *args)[source]¶ Raised when a citation has more than the allowed entries, {type, name, reference, date, authors, comments}.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
MissingCitationException
(line_number, line, position, *args)[source]¶ Raised when trying to parse a BEL statement, but no citation is currently set.
This might be due to a previous error in the formatting of a citation.
Though it’s not a best practice, some BEL curators set other annotations before the citation. If this is the case in your BEL document, and you’re absolutely sure that all
UNSET
statements are correctly written, you can usecitation_clearing=True
as a keyword argument in any of the IO functions inpybel.from_lines()
,pybel.from_url()
, orpybel.from_path()
.Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
MissingSupportWarning
(line_number, line, position, *args)[source]¶ Raised when trying to parse a BEL statement, but no evidence is currently set.
All BEL statements must be qualified with evidence.
If your data is serialized from a database and provenance information is not readily accessible, consider referencing the publication for the database, or a url pointing to the data from either a programmatically or human-readable endpoint.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
MissingAnnotationWarning
(line_number, line, position, required_annotations)[source]¶ Raised when trying to parse a BEL statement and a required annotation is not present.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
InvalidCitationType
(line_number, line, position, citation_type)[source]¶ Raised when a citation is set with an incorrect type.
Hint
Valid citation types include:
Book
PubMed
Journal
Online Resource
URL
DOI
Other
See also
OpenBEL wiki on citations
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
InvalidPubMedIdentifierWarning
(line_number, line, position, reference)[source]¶ Raised when a citation is set whose type is
PubMed
but whose database identifier is not a valid integer.Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
MalformedTranslocationWarning
(line_number, line, position, tokens)[source]¶ Raised when there is a translocation statement without location information.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
PlaceholderAminoAcidWarning
(line_number, line, position, code)[source]¶ Raised when an invalid amino acid code is given.
One example might be the usage of X, which is a colloquial signifier for a truncation in a given position. Text mining efforts for knowledge extraction make this mistake often. X might also signify a placeholder amino acid.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
NestedRelationWarning
(line_number, line, position, *args)[source]¶ Raised when encountering a nested statement.
See our the docs for an explanation of why we explicitly do not support nested statements.
Initialize the BEL parser warning.
-
exception
pybel.parser.exc.
InvalidEntity
(line_number, line, position, namespace, name)[source]¶ Raised when using a non-entity name for a name.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
InvalidFunctionSemantic
(line_number, line, position, func, namespace, name, allowed_functions)[source]¶ Raised when an invalid function is used for a given node.
For example, an HGNC symbol for a protein-coding gene YFG cannot be referenced as an miRNA with
m(HGNC:YFG)
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred
-
exception
pybel.parser.exc.
RelabelWarning
(line_number, line, position, node, old_label, new_label)[source]¶ Raised when a node is relabeled.
Initialize the BEL parser warning.
- Parameters
line_number – The line number on which this warning occurred
line – The content of the line
position – The position within the line where the warning occurred