def split_phylogeny(p, level='s'):
    """
    Return either the full or truncated version of a QIIME-formatted
    taxonomy string.

    :type p: str
    :param p: A QIIME-formatted taxonomy string: k__Foo; p__Bar; ...

    :type level: str
    :param level: The different level of identification are kingdom (k),
                phylum (p), class (c),order (o), family (f), genus (g)
                and species (s). If level is not provided, the default level
                of identification is species.

    :rtype: str
    :return: A QIIME-formatted taxonomy string up to the classification given
            by param level.
    """
    level = level + '__'
    result = p.split(level)
    return result[0] + level + result[1].split(';')[0]
