@follows( makeMotifs, filterMotifs )
@files_re( (exportMotifSequences, exportMotifControlSequences),
           "(\S+).controlfasta",
           [ r"\1.controlfasta", r"\1.fasta",  glob.glob("*.motif")],
           r"\1.mast.gz" )
def runMAST( infiles, outfile ):
    '''run mast on all intervals and motifs.

    Collect all results for an E-value up to 10000 so that
    all sequences are output and MAST curves can be computed. 

    10000 is a heuristic.
    '''
    to_cluster = True
    job_queue = "medium_jobs.q"
    # only use new nodes, as /bin/csh is not installed
    # on the old ones.
    job_options = "-l mem_free=8000M"

    controlfile, dbfile, motiffiles  = infiles
    controlfile = dbfile[:-len(".fasta")] + ".controlfasta"
    if not os.path.exists( controlfile ):
        raise P.PipelineError( "control file %s for %s does not exist" % (controlfile, dbfile))

    if os.path.exists(outfile): os.remove( outfile )

    for motiffile in motiffiles:
        if IOTools.isEmpty( motiffile ):
            E.info( "skipping empty motif file %s" % motiffile )
            continue

        of = gzip.open(outfile, "a")
        motif, x = os.path.splitext( motiffile )
        of.write(":: motif = %s ::\n" % motif )
        of.close()

        statement = '''
        cat %(dbfile)s %(controlfile)s 
        | %(motifs_execmast)s %(motiffile)s -stdin -stdout -text -ev %(motifs_mast_evalue)f 
        | gzip 
        >> %(outfile)s
        '''
        P.run()

############################################################
############################################################
############################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD.py/runMAST/original