src/pybel/canonicalize.py
def _decanonicalize_edge_node(
    node: BaseEntity,
    edge_data: EdgeData,
    node_position: str,
    *,
    use_identifiers: bool = True
) -> str:
    """Canonicalize a node with its modifiers stored in the given edge to a BEL string.

    :param node: A PyBEL node data dictionary
    :param edge_data: A PyBEL edge data dictionary
    :param node_position: Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`
    :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
    """
    node_str = node.as_bel(use_identifiers=use_identifiers)

    if node_position not in edge_data:
        return node_str

    node_edge_data = edge_data[node_position]

    if LOCATION in node_edge_data:
        node_str = postpend_location(node_str, node_edge_data[LOCATION])

    modifier = node_edge_data.get(MODIFIER)

    if modifier is None:
        return node_str

    if DEGRADATION == modifier:
        warnings.warn('degradation is deprecated', DeprecationWarning)
        return f'deg({node_str})'

    effect = node_edge_data.get(EFFECT)

    if ACTIVITY == modifier:
        if effect is None:
            return f'act({node_str})'
        return f'act({node_str}, ma({effect}))'

    if TRANSLOCATION == modifier:
        if effect is None:
            return f'tloc({node_str})'

        to_loc_data: Entity = effect[TO_LOC]
        from_loc_data: Entity = effect[FROM_LOC]
        return f"tloc({node_str}, fromLoc({from_loc_data}), toLoc({to_loc_data}))"

    raise ValueError('invalid modifier: {}'.format(modifier))
Canonicalize a node with its modifiers stored in the given edge to a BEL string.

    :param node: A PyBEL node data dictionary
    :param edge_data: A PyBEL edge data dictionary
    :param node_position: Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`
    :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
    
Canonicalize a node with its modifiers stored in the given edge to a BEL string.
Canonicalize a node with its modifiers stored in the given edge to a BEL string .
def _decanonicalize_edge_node(
    node: BaseEntity,
    edge_data: EdgeData,
    node_position: str,
    *,
    use_identifiers: bool = True
) -> str:
    node_str = node.as_bel(use_identifiers=use_identifiers)
    if node_position not in edge_data:
        return node_str
    node_edge_data = edge_data[node_position]
    if LOCATION in node_edge_data:
        node_str = postpend_location(node_str, node_edge_data[LOCATION])
    modifier = node_edge_data.get(MODIFIER)
    if modifier is None:
        return node_str
    if DEGRADATION == modifier:
        warnings.warn('degradation is deprecated', DeprecationWarning)
        return f'deg({node_str})'
    effect = node_edge_data.get(EFFECT)
    if ACTIVITY == modifier:
        if effect is None:
            return f'act({node_str})'
        return f'act({node_str}, ma({effect}))'
    if TRANSLOCATION == modifier:
        if effect is None:
            return f'tloc({node_str})'
        to_loc_data: Entity = effect[TO_LOC]
        from_loc_data: Entity = effect[FROM_LOC]
        return f"tloc({node_str}, fromLoc({from_loc_data}), toLoc({to_loc_data}))"
    raise ValueError('invalid modifier: {}'.format(modifier))
def _decanonicalize_edge_node ( node : BaseEntity , edge_data : EdgeData , node_position : str , * , use_identifiers : bool = True ) -> str : node_str = node . as_bel ( use_identifiers = use_identifiers ) if node_position not in edge_data : return node_str node_edge_data = edge_data [ node_position ] if LOCATION in node_edge_data : node_str = postpend_location ( node_str , node_edge_data [ LOCATION ] ) modifier = node_edge_data . get ( MODIFIER ) if modifier is None : return node_str if DEGRADATION == modifier : warnings . warn ( 'degradation is deprecated' , DeprecationWarning ) return f'deg({node_str})' effect = node_edge_data . get ( EFFECT ) if ACTIVITY == modifier : if effect is None : return f'act({node_str})' return f'act({node_str}, ma({effect}))' if TRANSLOCATION == modifier : if effect is None : return f'tloc({node_str})' to_loc_data : Entity = effect [ TO_LOC ] from_loc_data : Entity = effect [ FROM_LOC ] return f"tloc({node_str}, fromLoc({from_loc_data}), toLoc({to_loc_data}))" raise ValueError ( 'invalid modifier: {}' . format ( modifier ) )
Canonicalize a node with its modifiers stored in the given edge to a BEL string.
Canonicalize a node with its modifiers stored in the given edge to a BEL string .
"""Canonicalize a node with its modifiers stored in the given edge to a BEL string.

    :param node: A PyBEL node data dictionary
    :param edge_data: A PyBEL edge data dictionary
    :param node_position: Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`
    :param use_identifiers: Enables extended `BEP-0008 <http://bep.bel.bio/published/BEP-0008.html>`_ syntax
    """
node
BaseEntity
A PyBEL node data dictionary
A PyBEL node data dictionary
edge_data
EdgeData
A PyBEL edge data dictionary
A PyBEL edge data dictionary
node_position
str
Either :data:`pybel.constants.SUBJECT` or :data:`pybel.constants.OBJECT`
Either : data : ` pybel . constants . SUBJECT ` or : data : ` pybel . constants . OBJECT `
use_identifiers
bool
Enables extended `BEP-0008 `_ syntax
Enables extended ` BEP - 0008 ` _ syntax