+ added framework code for training modus
[qpalma.git] / scripts / grid_alignment.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import cPickle
5 import sys
6 import time
7 import pdb
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 createAlignmentFileFromPrediction import create_alignment_file
16
17 import grid_alignment
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/share/projects/qpalma/thaliana_4_lanes/lane_4/spliced/prediction'
28 result_dir = '/fml/ag-raetsch/share/projects/qpalma/thaliana_4_lanes/lane_4/spliced/alignment'
29
30 chunks_fn = []
31 for fn in os.listdir(run_dir):
32 if fn.startswith('chunk'):
33 chunks_fn.append(fn)
34
35 #chunks_fn = [\
36 #'chunk_9.predictions.pickle',\
37 #'chunk_14.predictions.pickle',\
38 #'chunk_24.predictions.pickle']
39
40 print chunks_fn
41
42 functionJobs=[]
43
44 for chunk_fn in chunks_fn:
45 chunk_name = chunk_fn[:chunk_fn.find('.')]
46 result_fn = jp(result_dir,'%s.align_remap'%chunk_name)
47 chunk_fn = jp(run_dir,chunk_fn)
48
49 #pdb.set_trace()
50
51 current_job = KybJob(grid_alignment.g_alignment,[chunk_fn,result_fn])
52 current_job.h_vmem = '15.0G'
53 current_job.express = 'True'
54
55 print "job #1: ", current_job.nativeSpecification
56
57 functionJobs = [current_job]
58 #functionJobs.append(current_job)
59 (sid, jobids) = submit_jobs(functionJobs)
60 time.sleep(10)
61
62
63 if __name__ == '__main__':
64 create_and_submit()