@follows( exportIntervalsAsBed, mkdir("foldchange") )
@files( [ ("macs/with_input/%s.macs" % x, 
           "foldchange/%s.foldchange" % x ) for x in TRACKS ] )
def thresholdFoldChange(infile, outfile):

    # Connect to DB
    dbhandle = sqlite3.connect( PARAMS["database"] )

    # Make bed files for different fold change thresholds
    track = P.snip( os.path.basename( infile ), ".macs" ).replace("-","_")
    macsdir = os.path.dirname(infile)
    foldchange = [4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]

    if os.path.exists(outfile):
        statement = '''rm %(outfile)s'''
        P.run()

    for fc in foldchange:
        cc = dbhandle.cursor()
        query = '''SELECT contig, start, end, interval_id, fold FROM %(track)s_macs_intervals WHERE fold > %(fc)i ORDER by contig, start;''' % locals()
        cc.execute( query )
        outbed = "foldchange/" + track + ".fc" + str(fc) + ".bed"
        outs = open( outbed, "w")

        for result in cc:
            contig, start, end, interval_id,fold = result
            outs.write( "%s\t%i\t%i\t%s\t%i\n" % (contig, start, end, str(interval_id), fold) )
        cc.close()
        outs.close()

        statement = '''echo %(fc)i >> %(outfile)s; cat %(outbed)s | wc -l >> %(outfile)s; '''
        P.run()
    
    statement = '''sed -i '{N;s/\\n/\\t/}' %(outfile)s; '''
    P.run()

############################################################
Shared storage migration
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_proj012_chipseq.py/thresholdFoldChange--crossover with--dataset/ETHPy150Open saltstack/salt/salt/modules/virt.py/migrate