@transform( sanitiseIntervals, suffix(".merged.cleaned.bed"), ".merged.overlap")
def pairwiseIntervals(infile, outfile):
    to_cluster = True
    in_track = P.snip( os.path.basename( infile ), ".merged.cleaned.bed")
    statement = '''echo "track" > %(outfile)s; echo "overlap" >> %(outfile)s;'''
    P.run()
    for track in TRACKS:
       if (str(track) <> in_track):
           statement = '''echo %(track)s >> %(outfile)s; intersectBed -a %(infile)s -b intervals/%(track)s.merged.cleaned.bed -u | wc -l >> %(outfile)s; '''
           P.run()
    statement = '''sed -i '{N;s/\\n/\\t/}' %(outfile)s; '''
    P.run()

############################################################
identify overlapping intervals for each pair of datasets
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_proj012_chipseq.py/pairwiseIntervals