def mergeBamsByRep(infiles, outfile): '''Merge all replicates of the same experiment together''' statement = '''samtools merge -f %(outfile)s %(infiles)s; checkpoint; samtools index %(outfile)s''' if len(infiles) == 1: IOTools.cloneFile(infiles[0], outfile) IOTools.cloneFile(infiles[0]+".bai", outfile+".bai") else: infiles = " ".join(infiles) P.run()