src/pybel/tokens.py
def _variant_to_dsl_helper(tokens) -> Variant:
    """Convert variant tokens to DSL objects.

    :type tokens: ParseResult
    """
    kind = tokens[KIND]

    if kind == HGVS:
        return Hgvs(tokens[HGVS])

    if kind == GMOD:
        concept = tokens[CONCEPT]
        return GeneModification(
            name=concept[NAME],
            namespace=concept[NAMESPACE],
            identifier=concept.get(IDENTIFIER),
            xrefs=tokens.get(XREFS),
        )

    if kind == PMOD:
        concept = tokens[CONCEPT]
        return ProteinModification(
            name=concept[NAME],
            namespace=concept[NAMESPACE],
            identifier=concept.get(IDENTIFIER),
            xrefs=tokens.get(XREFS),
            code=tokens.get(PMOD_CODE),
            position=tokens.get(PMOD_POSITION),
        )

    if kind == FRAGMENT:
        start, stop = tokens.get(FRAGMENT_START), tokens.get(FRAGMENT_STOP)
        return Fragment(
            start=start,
            stop=stop,
            description=tokens.get(FRAGMENT_DESCRIPTION),
        )

    raise ValueError('invalid fragment kind: {}'.format(kind))
Convert variant tokens to DSL objects.

    :type tokens: ParseResult
    
Convert variant tokens to DSL objects.
Convert variant tokens to DSL objects .
def _variant_to_dsl_helper(tokens) -> Variant:
    kind = tokens[KIND]
    if kind == HGVS:
        return Hgvs(tokens[HGVS])
    if kind == GMOD:
        concept = tokens[CONCEPT]
        return GeneModification(
            name=concept[NAME],
            namespace=concept[NAMESPACE],
            identifier=concept.get(IDENTIFIER),
            xrefs=tokens.get(XREFS),
        )
    if kind == PMOD:
        concept = tokens[CONCEPT]
        return ProteinModification(
            name=concept[NAME],
            namespace=concept[NAMESPACE],
            identifier=concept.get(IDENTIFIER),
            xrefs=tokens.get(XREFS),
            code=tokens.get(PMOD_CODE),
            position=tokens.get(PMOD_POSITION),
        )
    if kind == FRAGMENT:
        start, stop = tokens.get(FRAGMENT_START), tokens.get(FRAGMENT_STOP)
        return Fragment(
            start=start,
            stop=stop,
            description=tokens.get(FRAGMENT_DESCRIPTION),
        )
    raise ValueError('invalid fragment kind: {}'.format(kind))
def _variant_to_dsl_helper ( tokens ) -> Variant : kind = tokens [ KIND ] if kind == HGVS : return Hgvs ( tokens [ HGVS ] ) if kind == GMOD : concept = tokens [ CONCEPT ] return GeneModification ( name = concept [ NAME ] , namespace = concept [ NAMESPACE ] , identifier = concept . get ( IDENTIFIER ) , xrefs = tokens . get ( XREFS ) , ) if kind == PMOD : concept = tokens [ CONCEPT ] return ProteinModification ( name = concept [ NAME ] , namespace = concept [ NAMESPACE ] , identifier = concept . get ( IDENTIFIER ) , xrefs = tokens . get ( XREFS ) , code = tokens . get ( PMOD_CODE ) , position = tokens . get ( PMOD_POSITION ) , ) if kind == FRAGMENT : start , stop = tokens . get ( FRAGMENT_START ) , tokens . get ( FRAGMENT_STOP ) return Fragment ( start = start , stop = stop , description = tokens . get ( FRAGMENT_DESCRIPTION ) , ) raise ValueError ( 'invalid fragment kind: {}' . format ( kind ) )
Convert variant tokens to DSL objects.
Convert variant tokens to DSL objects .
"""Convert variant tokens to DSL objects.

    :type tokens: ParseResult
    """
tokens