@follows( normaliseBAMs )
@files( [ (("%s/bam/%s.norm.bam" % (x, x.asFile()), "%s/bam/%s.norm.bam" % (getControl(x), getControl(x).asFile())), 
           "%s/sicer/%s.sicer" % (x, x.asFile()) ) for x in TRACKS ] )
def runSICER( infiles, outfile ):
    '''Run SICER for peak detection.'''
    infile, controlfile = infiles
    to_cluster = False

    track = P.snip( os.path.basename(infile), ".norm.bam" )
    control = P.snip( os.path.basename(controlfile), ".norm.bam" )
    inputdir = os.path.dirname(outfile)
    try: os.mkdir( track )
    except __HOLE__: pass
    try: os.mkdir( '''%(track)s/sicer''' % locals() )
    except OSError: pass

    # convert bam to bed
    statement = '''bamToBed -i %(infile)s > %(track)s/sicer/%(track)s.bed; 
                   bamToBed -i %(controlfile)s > %(track)s/sicer/%(control)s.bed; '''

    # Run SICER
    statement += '''cd %(inputdir)s; SICER.sh . %(track)s.bed %(control)s.bed . %(genome)s %(sicer_params)s >& %(track)s.sicer''' 
    P.run() 
    
############################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/zinba.py/runSICER