+ added alignment reconstruction function
[qpalma.git] / scripts / grid_alignment.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import cPickle
5 import sys
6 import pdb
7 import os
8 import os.path
9 import math
10
11 from pythongrid import Job, KybJob, MethodJob, processJobs, Usage, processJobsLocally
12
13 from createAlignmentFileFromPrediction import *
14
15 import grid_alignment
16
17 from Utils import split_file_join_results
18
19
20 def g_alignment(chunk_fn,result_fn):
21 create_alignment_file(chunk_fn,result_fn)
22
23
24 def create_and_submit():
25 jp = os.path.join
26
27 #run_dir = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/run_enable_quality_scores_+_enable_splice_signals_+_enable_intron_length_+'
28 run_dir = '/fml/ag-raetsch/home/fabio/tmp/newest_run/alignment/saved_run'
29
30 data_dir = '/fml/ag-raetsch/home/fabio/tmp/transcriptome_data'
31
32 chunks_fn = []
33 for fn in os.listdir(run_dir):
34 if fn.startswith('chunk'):
35 chunks_fn.append(fn)
36
37
38 chunks_fn = [\
39 'chunk_17.predictions.pickle',\
40 'chunk_18.predictions.pickle',\
41 'chunk_19.predictions.pickle',\
42 'chunk_20.predictions.pickle',\
43 'chunk_21.predictions.pickle',\
44 'chunk_23.predictions.pickle',\
45 'chunk_24.predictions.pickle'
46 ]
47
48 print chunks_fn
49
50
51 functionJobs=[]
52
53 for chunk_fn in chunks_fn:
54 chunk_name = chunk_fn[:chunk_fn.find('.')]
55 result_fn = jp(data_dir,'%s.align_remap'%chunk_name)
56 chunk_fn = jp(run_dir,chunk_fn)
57
58 #pdb.set_trace()
59
60 current_job = KybJob(grid_alignment.g_alignment,[chunk_fn,result_fn])
61 current_job.h_vmem = '15.0G'
62 #current_job.express = 'True'
63
64 print "job #1: ", current_job.nativeSpecification
65
66 functionJobs.append(current_job)
67
68 processedFunctionJobs = processJobs(functionJobs)
69 print "ret fields AFTER execution on cluster"
70 for (i, job) in enumerate(processedFunctionJobs):
71 print "Job with id: ", i, "- ret: ", job.ret
72
73
74 if __name__ == '__main__':
75 #split_file_join_results('/fml/ag-raetsch/home/fabio/tmp/transcriptome_data/map.vm',10)
76 create_and_submit()