def bam_removeclipping(infile, outfile):
    bam = pysam.Samfile(infile, "rb")
    out = pysam.Samfile(outfile, "wb", template=bam)
    total = 0
    count = 0
    unmapped = 0
    for read in bam_iter(bam):
        code = read_removeclipping(read)

        if code == 1:
            unmapped += 1
        elif code == 2:
            count += 1

        total += 1
        out.write(read)

    bam.close()
    out.close()
    sys.stderr.write((total, count, unmapped) % 'Wrote: %s reads\nAltered: %s\nUnmapped: %s\n')
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/bam/removeclipping.py/bam_removeclipping/swapped operands of `%`