@transform(linkAlignmentFiles, suffix(".bam"), add_inputs(glob.glob("*lengths.tsv")), ".peakshape")
def buildUniformityOfCoverage(infiles, outfile):
    bam = infiles[0]
    track = P.snip(os.path.basename(bam), ".bam")
    tmp_bed = P.getTempFilename(".") + ".bed"
    tmp_bam = P.getTempFilename(".") + ".bam"

    # filter for mapped reads
    statement = '''cat %(bam)s | python %(scriptsdir)s/bam2bam.py --filter=mapped --log=/dev/null > %(tmp_bam)s
                   ; samtools index %(tmp_bam)s'''
    P.run()

    for infs in infiles[1:]:
        for inf in infs:
            if P.snip(inf, ".lengths.tsv") == track:
                length_file = inf

    statement = '''cat %(length_file)s | awk 'NR>1 {printf("%%s\\t0\\t%%s\\n", $1, $2)}' > %(tmp_bed)s'''
    P.run()

    statement = '''python %(scriptsdir)s/bam2peakshape.py 
                   --only-interval %(tmp_bam)s %(tmp_bed)s 
                   --log=%(outfile)s.log 
                   --output-filename-pattern=%(track)s.%%s'''
    P.run()
    os.unlink(tmp_bed)
    os.unlink(tmp_bam)

###################################################
###################################################
###################################################
Parse a sectioned setup file.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_metagenomebenchmark.py/buildUniformityOfCoverage--crossover with--dataset/ETHPy150Open editorconfig/editorconfig-vim/plugin/editorconfig-core-py/editorconfig/ini.py/EditorConfigParser._read