def parse_seqid(record):
    """Parses sequence and taxids from fasta

    UniRef records have the format 'UniRefxx_Q6GZX3' where xx is one of 100, 90 or 50. The fasta description for
    these entries contain the lowest common taxonomic id for all sequences belonging to each uniref id:

    Example:
    >UniRef50_Q6GZX3 Uncharacterized protein 002L n=51 Tax=Iridoviridae TaxID=10486 RepID=002L_FRG3G

    This function trims the 'UniRefxx' part and extracts the taxonomy id from the fasta description.

    If the format doesn't correspond to UniRef (e.g. when the records are from 'nr' instead) the original sequence id
    is returned instead.

    Parameters
    ----------
    record: Bio.SeqRecord.SeqRecord
        Sequence record as parsed using Bio.SeqIO.parse

    Returns
    -------
    newid: str
        Sequence identifier string
    taxid: str
        Taxonomy identifier string
    db_type: str
        Text string showing whether sequence is from a UniRef fasta file or not
    """

    taxid = None
    if "UniRef" in record.id:
        db_type = "uniref"
        newid = (record.id).split("_")[-1]  # Remove the 'UniRefxx_' string
        try:
            taxid = [x.split("=")[1] for x in (record.description).split(" ") if "TaxID" in x][0]
        except IndexError:
            taxid = None
    else:
        db_type = "non_uniref"
        newid = record.id
    return newid, taxid, db_type