+ renamed dyn_prog directory
[qpalma.git] / scripts / grid_heuristic.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # Written (W) 2008 Fabio De Bona
10 # Copyright (C) 2008 Max-Planck-Society
11
12 import cPickle
13 import sys
14 import pdb
15 import time
16 import os
17 import os.path
18 import math
19
20 from pythongrid import KybJob, Usage
21 from pythongrid import process_jobs, submit_jobs, collect_jobs, get_status
22
23 from PipelineHeuristic import *
24
25 import grid_heuristic
26
27 from Utils import split_file
28
29
30 def g_heuristic(run_fname,data_fname,param_fname,result_fname):
31 #print run_fname,data_fname,param_fname,result_fname
32 ph1 = PipelineHeuristic(run_fname,data_fname,param_fname,result_fname)
33 ph1.filter()
34
35 return 'finished filtering set %s.' % data_fname
36
37
38 def create_and_submit():
39 jp = os.path.join
40
41 num_splits = 50
42
43 run_dir = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/run_enable_quality_scores_+_enable_splice_signals_+_enable_intron_length_+'
44 #data_dir = '/fml/ag-raetsch/home/fabio/tmp/lyrata_analysis/'
45
46 data_dir = '/fml/ag-raetsch/share/projects/qpalma/thaliana_4_lanes/lane_4/main/'
47
48 run_fname = jp(run_dir,'run_obj.pickle')
49
50 original_map_fname = jp(data_dir,'map.vm')
51
52 split_file(original_map_fname,data_dir,num_splits)
53
54 param_fname = jp(run_dir,'param_526.pickle')
55
56 functionJobs=[]
57
58 for idx in range(0,num_splits):
59 data_fname = jp(data_dir,'map.part_%d'%idx)
60 result_fname = jp(data_dir,'map.vm.part_%d.heuristic'%idx)
61
62 #pdb.set_trace()
63
64 current_job = KybJob(grid_heuristic.g_heuristic,[run_fname,data_fname,param_fname,result_fname])
65 current_job.h_vmem = '25.0G'
66 #current_job.express = 'True'
67
68 print "job #1: ", current_job.nativeSpecification
69
70 functionJobs.append(current_job)
71 #break
72
73 (sid, jobids) = submit_jobs(functionJobs)
74 #print 'checking whether finished'
75 #while not get_status(sid, jobids):
76 # time.sleep(7)
77 #print 'collecting jobs'
78 #retjobs = collect_jobs(sid, jobids, functionJobs)
79 #print "ret fields AFTER execution on cluster"
80 #for (i, job) in enumerate(retjobs):
81 # print "Job #", i, "- ret: ", job.ret
82
83 #print '--------------'
84
85
86 if __name__ == '__main__':
87 #split_file_join_results('/fml/ag-raetsch/home/fabio/tmp/transcriptome_data/map.vm',10)
88 create_and_submit()