def genotype_from_likelyhood_index(p,n,index):
    """
    figuring out the allele number corresponding to likelihood position
    ploidy P and N alternate alleles
    https://samtools.github.io/hts-specs/VCFv4.3.pdf
    :param p: the ploidy as int
    :param n: alt alleles as int
    :param index:
    :return: list with genotype numbers as strings (it's how pyvcf has it)
    """
    def recursive_order(_p, _n, alleles, suffix = []):
        for a in range(_n):
            if _p == 1:
                alleles.append([str(a)]+suffix)
            elif _p > 1:
                recursive_order(_p-1, a+1, alleles, [str(a)]+suffix)

    alleles_list = []
    recursive_order(p,n,alleles_list)
    return alleles_list[index]