src/pybel/utils.py
def _canonicalize_edge_modifications(edge_data: EdgeData) -> Optional[Tuple]:
    """Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple."""
    if edge_data is None:
        return

    modifier = edge_data.get(MODIFIER)
    location = edge_data.get(LOCATION)
    effect = edge_data.get(EFFECT)

    if modifier is None and location is None:
        return

    result = []

    if modifier == ACTIVITY:
        if effect:
            t = (
                ACTIVITY,
                effect[NAMESPACE],
                effect.get(IDENTIFIER),
                effect.get(NAME),
            )
        else:
            t = (ACTIVITY,)
        result.append(t)

    elif modifier == DEGRADATION:
        t = (DEGRADATION,)
        result.append(t)

    elif modifier == TRANSLOCATION:
        if effect:
            from_loc_concept = effect[FROM_LOC]
            to_loc_concept = effect[TO_LOC]

            t = (
                TRANSLOCATION,
                from_loc_concept[NAMESPACE],
                from_loc_concept.get(IDENTIFIER),
                from_loc_concept.get(NAME),
                to_loc_concept[NAMESPACE],
                to_loc_concept.get(IDENTIFIER),
                to_loc_concept.get(NAME),
            )
        else:
            t = (TRANSLOCATION,)
        result.append(t)

    if location:
        t = (
            LOCATION,
            location[NAMESPACE],
            location.get(IDENTIFIER),
            location.get(NAME),
        )
        result.append(t)

    if not result:
        raise ValueError('Invalid data: {}'.format(edge_data))

    return tuple(result)
Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple.
Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple.
Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple .
def _canonicalize_edge_modifications(edge_data: EdgeData) -> Optional[Tuple]:
    if edge_data is None:
        return
    modifier = edge_data.get(MODIFIER)
    location = edge_data.get(LOCATION)
    effect = edge_data.get(EFFECT)
    if modifier is None and location is None:
        return
    result = []
    if modifier == ACTIVITY:
        if effect:
            t = (
                ACTIVITY,
                effect[NAMESPACE],
                effect.get(IDENTIFIER),
                effect.get(NAME),
            )
        else:
            t = (ACTIVITY,)
        result.append(t)
    elif modifier == DEGRADATION:
        t = (DEGRADATION,)
        result.append(t)
    elif modifier == TRANSLOCATION:
        if effect:
            from_loc_concept = effect[FROM_LOC]
            to_loc_concept = effect[TO_LOC]
            t = (
                TRANSLOCATION,
                from_loc_concept[NAMESPACE],
                from_loc_concept.get(IDENTIFIER),
                from_loc_concept.get(NAME),
                to_loc_concept[NAMESPACE],
                to_loc_concept.get(IDENTIFIER),
                to_loc_concept.get(NAME),
            )
        else:
            t = (TRANSLOCATION,)
        result.append(t)
    if location:
        t = (
            LOCATION,
            location[NAMESPACE],
            location.get(IDENTIFIER),
            location.get(NAME),
        )
        result.append(t)
    if not result:
        raise ValueError('Invalid data: {}'.format(edge_data))
    return tuple(result)
def _canonicalize_edge_modifications ( edge_data : EdgeData ) -> Optional [ Tuple ] : if edge_data is None : return modifier = edge_data . get ( MODIFIER ) location = edge_data . get ( LOCATION ) effect = edge_data . get ( EFFECT ) if modifier is None and location is None : return result = [ ] if modifier == ACTIVITY : if effect : t = ( ACTIVITY , effect [ NAMESPACE ] , effect . get ( IDENTIFIER ) , effect . get ( NAME ) , ) else : t = ( ACTIVITY , ) result . append ( t ) elif modifier == DEGRADATION : t = ( DEGRADATION , ) result . append ( t ) elif modifier == TRANSLOCATION : if effect : from_loc_concept = effect [ FROM_LOC ] to_loc_concept = effect [ TO_LOC ] t = ( TRANSLOCATION , from_loc_concept [ NAMESPACE ] , from_loc_concept . get ( IDENTIFIER ) , from_loc_concept . get ( NAME ) , to_loc_concept [ NAMESPACE ] , to_loc_concept . get ( IDENTIFIER ) , to_loc_concept . get ( NAME ) , ) else : t = ( TRANSLOCATION , ) result . append ( t ) if location : t = ( LOCATION , location [ NAMESPACE ] , location . get ( IDENTIFIER ) , location . get ( NAME ) , ) result . append ( t ) if not result : raise ValueError ( 'Invalid data: {}' . format ( edge_data ) ) return tuple ( result )
Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple.
Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple .
"""Return the SUBJECT or OBJECT entry of a PyBEL edge data dictionary as a canonical tuple."""
edge_data
EdgeData