src/pybel/canonicalize.py
def calculate_canonical_name(node: BaseEntity, use_identifiers: bool = True) -> str:
    """Calculate the canonical name for a given node.

    If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
    """
    if isinstance(node, (Reaction, ListAbundance, FusionBase)):
        return node.as_bel(use_identifiers=True)

    elif isinstance(node, BaseAbundance):
        if VARIANTS in node:
            return node.as_bel(use_identifiers=True)
        elif use_identifiers and node.entity.identifier and node.entity.name:
            return node.obo
        else:
            return node.curie

    else:
        raise TypeError('Unhandled node: {}'.format(node))
Calculate the canonical name for a given node.

    If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
    
Calculate the canonical name for a given node.
If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
Calculate the canonical name for a given node . If it is a simple node uses the already given name . Otherwise it uses the BEL string .
def calculate_canonical_name(node: BaseEntity, use_identifiers: bool = True) -> str:
    if isinstance(node, (Reaction, ListAbundance, FusionBase)):
        return node.as_bel(use_identifiers=True)
    elif isinstance(node, BaseAbundance):
        if VARIANTS in node:
            return node.as_bel(use_identifiers=True)
        elif use_identifiers and node.entity.identifier and node.entity.name:
            return node.obo
        else:
            return node.curie
    else:
        raise TypeError('Unhandled node: {}'.format(node))
def calculate_canonical_name ( node : BaseEntity , use_identifiers : bool = True ) -> str : if isinstance ( node , ( Reaction , ListAbundance , FusionBase ) ) : return node . as_bel ( use_identifiers = True ) elif isinstance ( node , BaseAbundance ) : if VARIANTS in node : return node . as_bel ( use_identifiers = True ) elif use_identifiers and node . entity . identifier and node . entity . name : return node . obo else : return node . curie else : raise TypeError ( 'Unhandled node: {}' . format ( node ) )
Calculate the canonical name for a given node.
Calculate the canonical name for a given node .
"""Calculate the canonical name for a given node.

    If it is a simple node, uses the already given name. Otherwise, it uses the BEL string.
    """
node
BaseEntity
use_identifiers
bool