Logging Messages

Errors

This module contains base exceptions that are shared through the package

exception pybel.exceptions.PyBelWarning[source]

The base class for warnings during compilation from which PyBEL can recover

exception pybel.exceptions.ResourceError(location)[source]

Base class for resource errors

exception pybel.exceptions.EmptyResourceError(location)[source]

Raised when downloading an empty file

exception pybel.exceptions.MissingSectionError(location)[source]

Raised when downloading a resource without a [Values] Section

Parse Exceptions

A message for “General Parser Failure” is displayed when a problem was caused due to an unforseen error. The line number and original statement are printed for the user to debug.

exception pybel.parser.parse_exceptions.PyBelParserWarning(line_number, line, position, *args)[source]

Base PyBEL parser exception, which holds the line and position where a parsing problem occurred

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.InconsistentDefinitionError(line_number, line, position, definition)[source]

Base PyBEL error for redefinition

exception pybel.parser.parse_exceptions.RedefinedNamespaceError(line_number, line, position, definition)[source]

Raised when a namespace is redefined

exception pybel.parser.parse_exceptions.RedefinedAnnotationError(line_number, line, position, definition)[source]

Raised when an annotation is redefined

exception pybel.parser.parse_exceptions.NameWarning(line_number, line, position, name, *args)[source]

The base class for errors related to nomenclature

exception pybel.parser.parse_exceptions.NakedNameWarning(line_number, line, position, name, *args)[source]

Raised when there is an identifier without a namespace. Enable lenient mode to suppress

exception pybel.parser.parse_exceptions.MissingDefaultNameWarning(line_number, line, position, name, *args)[source]

Raised if reference to value not in default namespace

exception pybel.parser.parse_exceptions.NamespaceIdentifierWarning(line_number, line, position, namespace, name)[source]

The base class for warnings related to namespace:name identifiers

Parameters:
  • line_number (int) – The line number of the line that caused the exception
  • line (str) – The line that caused the exception
  • position (int) – The line’s position of the exception
  • namespace (str) – The namespace of the identifier
  • name (str) – The name of the identifier
exception pybel.parser.parse_exceptions.UndefinedNamespaceWarning(line_number, line, position, namespace, name)[source]

Raised if reference made to undefined namespace

Parameters:
  • line_number (int) – The line number of the line that caused the exception
  • line (str) – The line that caused the exception
  • position (int) – The line’s position of the exception
  • namespace (str) – The namespace of the identifier
  • name (str) – The name of the identifier
exception pybel.parser.parse_exceptions.MissingNamespaceNameWarning(line_number, line, position, namespace, name)[source]

Raised if reference to value not in namespace

Parameters:
  • line_number (int) – The line number of the line that caused the exception
  • line (str) – The line that caused the exception
  • position (int) – The line’s position of the exception
  • namespace (str) – The namespace of the identifier
  • name (str) – The name of the identifier
exception pybel.parser.parse_exceptions.MissingNamespaceRegexWarning(line_number, line, position, namespace, name)[source]

Raised if reference not matching regex

Parameters:
  • line_number (int) – The line number of the line that caused the exception
  • line (str) – The line that caused the exception
  • position (int) – The line’s position of the exception
  • namespace (str) – The namespace of the identifier
  • name (str) – The name of the identifier
exception pybel.parser.parse_exceptions.AnnotationWarning(line_number, line, position, annotation, *args)[source]

Base exception for annotation warnings

exception pybel.parser.parse_exceptions.UndefinedAnnotationWarning(line_number, line, position, annotation, *args)[source]

Raised when an undefined annotation is used

exception pybel.parser.parse_exceptions.MissingAnnotationKeyWarning(line_number, line, position, annotation, *args)[source]

Raised when trying to unset an annotation that is not set

exception pybel.parser.parse_exceptions.AnnotationIdentifierWarning(line_number, line, position, annotation, value)[source]

Base exception for annotation:value pairs

exception pybel.parser.parse_exceptions.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.

exception pybel.parser.parse_exceptions.MissingAnnotationRegexWarning(line_number, line, position, annotation, value)[source]

Raised if annotation doesn’t match regex

exception pybel.parser.parse_exceptions.VersionFormatWarning(line_number, line, position, version_string)[source]

Raised if the version string doesn’t adhere to semantic versioning or YYYYMMDD format

exception pybel.parser.parse_exceptions.MetadataException(line_number, line, *args)[source]

Base exception for issues with document metadata

exception pybel.parser.parse_exceptions.MalformedMetadataException(line_number, line, *args)[source]

Raised when an invalid metadata line is encountered

exception pybel.parser.parse_exceptions.MissingBelResource(line_number, line, *args)[source]

Raised when a missing resource is encountered

exception pybel.parser.parse_exceptions.InvalidMetadataException(line_number, line, position, key, value)[source]

Raised when an incorrect document metadata key is used. Valid document metadata keys are:

  • Authors
  • ContactInfo
  • Copyright
  • Description
  • Disclaimer
  • Licenses
  • Name
  • Version

See also

BEL specification on the properties section

exception pybel.parser.parse_exceptions.MissingMetadataException(key)[source]

Raised when a BEL Script is missing critical metadata.

exception pybel.parser.parse_exceptions.InvalidCitationLengthException(line_number, line, position, *args)[source]

Base exception raised when the format for a citation is wrong.

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.CitationTooShortException(line_number, line, position, *args)[source]

Raised when a citation does not have the minimum of {type, name, reference}.

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.CitationTooLongException(line_number, line, position, *args)[source]

Raised when a citation has more than the allowed entries, {type, name, reference, date, authors, comments}.

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.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 absolutly sure that all UNSET statements are correctly written, you can use citation_clearing=True as a keyword argument in any of the IO functions in pybel.from_lines(), pybel.from_url(), or pybel.from_path().

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.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.

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.InvalidCitationType(line_number, line, position, citation_type)[source]

Raise when a citation is set with an incorrect type. Valid citation types include:

  • Book
  • PubMed
  • Journal
  • Online Resource
  • URL
  • DOI
  • Other

See also

OpenBEL wiki on citations

exception pybel.parser.parse_exceptions.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.

exception pybel.parser.parse_exceptions.MalformedTranslocationWarning(line_number, line, position, tokens)[source]

Raised when there is a translocation statement without location information.

exception pybel.parser.parse_exceptions.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.

exception pybel.parser.parse_exceptions.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.

Parameters:
  • line_number (int) – The line number on which this warning occurred
  • line (str) – The content of the line
  • position (int) – The position within the line where the warning occurred
  • args – Additional arguments to supply to the super class
exception pybel.parser.parse_exceptions.LexicographyWarning[source]

Raised when encountering improper capitalization of namespace/annotation names.

exception pybel.parser.parse_exceptions.InvalidFunctionSemantic(line_number, line, position, function, 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)

exception pybel.parser.parse_exceptions.RelabelWarning(line_number, line, position, node, old_label, new_label)[source]

Raised when a node is relabeled