src/pybel/struct/filters/edge_predicates.py
def edge_has_annotation(edge_data: EdgeData, key: str) -> Optional[Any]:
    """Check if an edge has the given annotation.

    :param edge_data: The data dictionary from a BELGraph's edge
    :param key: An annotation key
    :return: If the annotation key is present in the current data dictionary

    For example, it might be useful to print all edges that are annotated with 'Subgraph':

    >>> from pybel.examples import sialic_acid_graph
    >>> from pybel.examples.sialic_acid_example import sialic_acid_cd33_complex, cd33
    >>> edges = {
    ...     (u, v)
    ...     for u, v, data in sialic_acid_graph.edges(data=True)
    ...     if edge_has_annotation(data, 'Species')
    ... }
    >>> assert (sialic_acid_cd33_complex, cd33) in edges
    """
    annotations = edge_data.get(ANNOTATIONS)

    if annotations is None:
        return None

    return annotations.get(key)
Check if an edge has the given annotation.

    :param edge_data: The data dictionary from a BELGraph's edge
    :param key: An annotation key
    :return: If the annotation key is present in the current data dictionary

    For example, it might be useful to print all edges that are annotated with 'Subgraph':

    >>> from pybel.examples import sialic_acid_graph
    >>> from pybel.examples.sialic_acid_example import sialic_acid_cd33_complex, cd33
    >>> edges = {
    ...     (u, v)
    ...     for u, v, data in sialic_acid_graph.edges(data=True)
    ...     if edge_has_annotation(data, 'Species')
    ... }
    >>> assert (sialic_acid_cd33_complex, cd33) in edges
    
Check if an edge has the given annotation.
Check if an edge has the given annotation .
def edge_has_annotation(edge_data: EdgeData, key: str) -> Optional[Any]:
    annotations = edge_data.get(ANNOTATIONS)
    if annotations is None:
        return None
    return annotations.get(key)
def edge_has_annotation ( edge_data : EdgeData , key : str ) -> Optional [ Any ] : annotations = edge_data . get ( ANNOTATIONS ) if annotations is None : return None return annotations . get ( key )
Check if an edge has the given annotation.
Check if an edge has the given annotation .
"""Check if an edge has the given annotation.

    :param edge_data: The data dictionary from a BELGraph's edge
    :param key: An annotation key
    :return: If the annotation key is present in the current data dictionary

    For example, it might be useful to print all edges that are annotated with 'Subgraph':

    >>> from pybel.examples import sialic_acid_graph
    >>> from pybel.examples.sialic_acid_example import sialic_acid_cd33_complex, cd33
    >>> edges = {
    ...     (u, v)
    ...     for u, v, data in sialic_acid_graph.edges(data=True)
    ...     if edge_has_annotation(data, 'Species')
    ... }
    >>> assert (sialic_acid_cd33_complex, cd33) in edges
    """
If the annotation key is present in the current data dictionary
For example, it might be useful to print all edges that are annotated with 'Subgraph'.

>>> from pybel.examples import sialic_acid_graph
>>> from pybel.examples.sialic_acid_example import sialic_acid_cd33_complex, cd33
>>> edges = {
(u, v)
for u, v, data in sialic_acid_graph.edges(data=True)
if edge_has_annotation(data, 'Species')
}
>>> assert (sialic_acid_cd33_complex, cd33) in edges
If the annotation key is present in the current data dictionary For example it might be useful to print all edges that are annotated with ' Subgraph ' . >>> from pybel . examples import sialic_acid_graph >>> from pybel . examples . sialic_acid_example import sialic_acid_cd33_complex cd33 >>> edges = { ( u v ) for u v data in sialic_acid_graph . edges ( data = True ) if edge_has_annotation ( data ' Species ' ) } >>> assert ( sialic_acid_cd33_complex cd33 ) in edges
edge_data
EdgeData
The data dictionary from a BELGraph's edge
The data dictionary from a BELGraph ' s edge
key
str
An annotation key
An annotation key