@transform( buildPolyphenInput, suffix(".input"), ".features")
def buildPolyphenFeatures( infile, outfile ):
    '''run polyphen on the cluster.

    To do this, first send uniref to all nodes:

    python ~/cgat/cluster_distribute.py 
           --collection=andreas 
           /net/cpp-group/tools/polyphen-2.0.18/nrdb/uniref100*.{pin,psd,psi,phr,psq,pal}
    '''
    
    nsnps = len([ x for x in open(infile)])

    to_cluster = True
    stepsize = max( int(nsnps / 200000.0), 1000 )
    job_array=(0, nsnps, stepsize)
    E.info("running array jobs on %i snps" % nsnps )

    scratchdir = os.path.join(os.path.abspath("."), "scratch")
    try:
        os.mkdir( scratchdir )
    except OSError:
        pass

    resultsdir = outfile + ".dir"
    try:
        os.mkdir( resultsdir )
    except __HOLE__:
        pass

    statement = '''
    /net/cpp-group/tools/polyphen-2.0.18/bin/run_pph_cpp.pl
       -s %(peptides)s
       -b %(polyphen_blastdb)s
       -d %(scratchdir)s
       %(infile)s > %(resultsdir)s/%(outfile)s.$SGE_TASK_ID 2> %(resultsdir)s/%(outfile)s.err.$SGE_TASK_ID
    '''
    P.run()

    to_cluster = False
    job_array=None

    statement = '''find %(resultsdir)s -name "*.err.*" -exec cat {} \; > %(outfile)s.log'''
    P.run()

    statement = '''find %(resultsdir)s -not -name "*.err.*" -exec cat {} \; > %(outfile)s'''
    P.run()

###################################################################
###################################################################
###################################################################
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_snps.py/buildPolyphenFeatures