def muscle_inputorder(inputfastafile, alnfile, trunc_name=True):
    """
    Fix for muscle -stable option according to here:
    http://drive5.com/muscle/stable.html
    """
    sh("cp {0} {0}.old".format(alnfile), log=False)
    maxi = 30 if trunc_name else 1000

    aa = AlignIO.read(alnfile, "clustal")
    alignment = dict((a.id[:maxi], a) for a in aa)
    if trunc_name and len(aa) < len(alignment):
        raise ValueError\
            ("ERROR: The first 30 chars of your seq names are not unique")

    fw = must_open(alnfile, "w")
    for rec in SeqIO.parse(inputfastafile, "fasta"):
        a = alignment[rec.id[:maxi]]
        fw.write(">{0}\n{1}\n".format(a.id[:maxi], a.seq))

    fw.close()
    sh("rm {0}.old".format(alnfile), log=False)
dataset/ETHPy150Open tanghaibao/jcvi/apps/ks.py/muscle_inputorder/swapped operands of `<`