@merge( importExpressionDifferences, "expression_differences_%s.bed" % PARAMS["version"] )
def viewExpressionDifferences( infiles, outfile ):
    '''export a bed file with genes called as differentially expressed.'''
    dbhandle = sqlite3.connect( PARAMS["database"] )

    outs = open( outfile, "w" )

    for infile in infiles:
        track, method, control = PExpression.getExpressionMatch( infile[:-len(".import")] )
        if track == control: continue
        table = locals() % "%(track)s_vs_%(control)s_%(method)s"
        
        statement = """SELECT DISTINCT g.contig, g.start, g.end, exp.probeset
                          FROM %(table)s AS exp, probeset_gtf AS g
                          WHERE g.gene_id = exp.probeset AND \
                          exp.pvalue < 0.10
                   """ % locals()
        cc = dbhandle.cursor()
        cc.execute(statement)

        outs.write( '''track name="%(track)s_%(method)s" description="%(track)s - %(method)s" visibility=2\n''' % locals() )
        for contig, start, end, probeset in cc:
            if contig == "chrMT": contig = "chrM"
            bed = Bed.Bed()
            bed.contig, bed.start, bed.end = contig, start, end
            bed.fields = [ probeset ]
            outs.write( "%s\n" % str(bed) )

    outs.close()

    dest = os.path.join( PARAMS["ucsc_dir"], outfile ) 
    shutil.copyfile( outfile, dest )
    print "paste the following into the UCSC browser:"
    print '''http://wwwfgu.anat.ox.ac.uk/~andreas/ucsc_tracks/%(outfile)s''' % locals()

############################################################
############################################################
############################################################
## export intervals
############################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD.py/viewExpressionDifferences/swapped operands of `%`