import re


def parse_variant(variant):
    """
    Parse specified genomic variant.

    Generally speaking, the input string should consist of chromosome,
    position, reference allele, and alternative allele separated by any one
    or combination of the following delimiters: ``-``, ``:``, ``>`` (e.g.
    '22-42127941-G-A'). The method will return parsed variant as a tuple with
    a shape of ``(chrom, pos, ref, alt)`` which has data types of ``(str,
    int, str, str)``.

    Note that it's possible to omit reference allele and alternative allele
    from the input string to indicate position-only data (e.g.
    '22-42127941'). In this case, the method will return empty string for
    the alleles -- i.e. ``(str, int, '', '')`` if both are omitted and
    ``(str, int, str, '')`` if only alternative allele is omitted.

    Parameters
    ----------
    variant : str
        Genomic variant.

    Returns
    -------
    tuple
        Parsed variant.

    Examples
    --------

    >>> from fuc import common
    >>> common.parse_variant('22-42127941-G-A')
    ('22', 42127941, 'G', 'A')
    >>> common.parse_variant('22:42127941-G>A')
    ('22', 42127941, 'G', 'A')
    >>> common.parse_variant('22-42127941')
    ('22', 42127941, '', '')
    >>> common.parse_variant('22-42127941-G')
    ('22', 42127941, 'G', '')
    """
    fields = re.split('-|:|>', variant)
    chrom = fields[0]
    pos = int(fields[1])

    try:
        ref = fields[2]
    except IndexError:
        ref = ''

    try:
        alt = fields[3]
    except IndexError:
        alt = ''

    return (chrom, pos, ref, alt)