def genseq2(wtseq, mutations, keepdupes=False):
    ' generate a sequences library based of wtseq\n    @param: list of tupel, [ (resid, library), (resid, library), ...]\n\n    @returns: list of sequences\n    '

    def estimator(mutations):
        est = 1
        for mut in mutations:
            lib = mut[1]
            est *= (len(lib) + 1)
        return est
    logger.info('will mutate wtseq %s and create about %s mutations', wtseq, estimator(mutations))
    seqo = list(wtseq)
    sequences = [seqo]
    while (len(mutations) > 0):
        newseqs = sequences[:]
        (res, lib) = mutations.pop()
        for seqo in sequences:
            res = int(res)
            if (res < 1):
                raise ValueError('Impossible: resid < 1!', res)
            pos = (res - 1)
            for aa in lib:
                if (len(aa) != 1):
                    raise ValueError('Impossible 1-letter aminoacid', aa, 'in lib', lib)
                seqn = seqo[:]
                seqn[pos] = aa
                if (keepdupes or (seqn not in newseqs)):
                    newseqs.append(seqn)
        sequences = newseqs
    return sequences
generate a sequences library based of wtseq
@param: list of tupel, [ (resid, library), (resid, library), ...]

@returns: list of sequences
def genseq2(wtseq, mutations, keepdupes=False):
    ' generate a sequences library based of wtseq\n    @param: list of tupel, [ (resid, library), (resid, library), ...]\n\n    @returns: list of sequences\n    '

    def estimator(mutations):
        est = 1
        for mut in mutations:
            lib = mut[1]
            est *= (len(lib) + 1)
        return est
    logger.info('will mutate wtseq %s and create about %s mutations', wtseq, estimator(mutations))
    seqo = list(wtseq)
    sequences = [seqo]
    while (len(mutations) > 0):
        newseqs = sequences[:]
        (res, lib) = mutations.pop()
        for seqo in sequences:
            res = int(res)
            if (res < 1):
                raise ValueError('Impossible: resid < 1!', res)
            pos = (res - 1)
            for aa in lib:
                if (len(aa) != 1):
                    raise ValueError('Impossible 1-letter aminoacid', aa, 'in lib', lib)
                seqn = seqo[:]
                seqn[pos] = aa
                if (keepdupes or (seqn not in newseqs)):
                    newseqs.append(seqn)
        sequences = newseqs
    return sequences