def fancyprint(fw, seq, width=60, chunk=10):
    from jcvi.utils.iter import grouper

    assert chunk % width == 0
    nchunks = width / chunk
    seqlen = len(seq)
    maxchar = len(str(seqlen))

    s = ["".join(x) for x in grouper(seq, chunk, fillvalue="")]
    s = [" ".join(x) for x in grouper(s, nchunks, fillvalue="")]
    for a, b in zip(range(1, len(seq), width), s):
        b = b.rstrip()
        a = str(a).rjust(maxchar, " ")
        print >> fw, "  ".join((a, b))
dataset/ETHPy150Open tanghaibao/jcvi/formats/fasta.py/fancyprint/swapped operands of `%`