77b93c180829c54950ff0c6090e163df33769606
[qpalma.git] / scripts / grid_heuristic.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import cPickle
5 import sys
6 import pdb
7 import time
8 import os
9 import os.path
10 import math
11
12 from pythongrid import KybJob, Usage
13 from pythongrid import process_jobs, submit_jobs, collect_jobs, get_status
14
15 from PipelineHeuristic import *
16
17 import grid_heuristic
18
19 from Utils import split_file
20
21
22 def g_heuristic(run_fname,data_fname,param_fname,result_fname):
23 #print run_fname,data_fname,param_fname,result_fname
24 ph1 = PipelineHeuristic(run_fname,data_fname,param_fname,result_fname)
25 ph1.filter()
26
27 return 'finished filtering set %s.' % data_fname
28
29
30 def create_and_submit():
31 jp = os.path.join
32
33 num_splits = 25
34
35 run_dir = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/run_enable_quality_scores_+_enable_splice_signals_+_enable_intron_length_+'
36 #data_dir = '/fml/ag-raetsch/home/fabio/tmp/lyrata_analysis/'
37
38 data_dir = '/fml/ag-raetsch/home/fabio/tmp/vmatch_evaluation/main'
39
40 run_fname = jp(run_dir,'run_obj.pickle')
41
42 #original_map_fname = '/fml/ag-raetsch/home/fabio/tmp/vmatch_evaluation/main/map.vm'
43 #split_file(original_map_fname,data_dir,num_splits)
44
45 param_fname = jp(run_dir,'param_526.pickle')
46
47 functionJobs=[]
48
49 for idx in range(0,num_splits):
50 data_fname = jp(data_dir,'map.part_%d'%idx)
51 result_fname = jp(data_dir,'map.vm.part_%d.heuristic'%idx)
52
53 #pdb.set_trace()
54
55 current_job = KybJob(grid_heuristic.g_heuristic,[run_fname,data_fname,param_fname,result_fname])
56 current_job.h_vmem = '25.0G'
57 #current_job.express = 'True'
58
59 print "job #1: ", current_job.nativeSpecification
60
61 functionJobs.append(current_job)
62 #break
63
64 (sid, jobids) = submit_jobs(functionJobs)
65 #print 'checking whether finished'
66 #while not get_status(sid, jobids):
67 # time.sleep(7)
68 #print 'collecting jobs'
69 #retjobs = collect_jobs(sid, jobids, functionJobs)
70 #print "ret fields AFTER execution on cluster"
71 #for (i, job) in enumerate(retjobs):
72 # print "Job #", i, "- ret: ", job.ret
73
74 #print '--------------'
75
76
77 if __name__ == '__main__':
78 #split_file_join_results('/fml/ag-raetsch/home/fabio/tmp/transcriptome_data/map.vm',10)
79 create_and_submit()