@@ -57,23 +57,29 @@ def get_seed_name(seedFile):
57
57
return (seqName )
58
58
59
59
60
- def compile_core (core_options , other_options , seeds , inFol , cpus , outpath , silentOff ):
60
+ def compile_core (core_options , other_options , seeds , inFol , cpus , outpath , silentOff , jobName ):
61
61
core_compilation_jobs = []
62
62
(coreArgs , orthoCoreArgs , otherCoreArgs ) = core_options
63
63
(refspec , reuseCore , forceCore , pathArgs , debug ) = other_options
64
64
(outpath , hmmpath , corepath , searchpath , annopath ) = pathArgs
65
65
begin = time .time ()
66
66
print ('Preparing core compilation jobs...' )
67
- for seed in seeds :
68
- seqFile = ('%s/%s' % (inFol , seed ))
69
- seqName = get_seed_name (seed )
70
- if not os .path .exists ('%s/core_orthologs/%s/hmm_dir/%s.hmm' % (outpath , seqName , seqName )) or forceCore == True :
71
- seed_id = prepare_fn .identify_seed_id (seqFile , refspec , corepath , debug , silentOff )
72
- core_compilation_jobs .append ([seqFile , seqName , refspec , seed_id ,
73
- reuseCore , forceCore , coreArgs , pathArgs , orthoCoreArgs ,
74
- otherCoreArgs , debug ])
67
+ core_job_file = '%s/%s_core_jobs.list' % (outpath , jobName )
68
+ if os .path .exists (core_job_file ) and os .stat (core_job_file ).st_size > 0 :
69
+ print ('... file contains jobs found (%s)' % core_job_file )
70
+ core_compilation_jobs = general_fn .read_pyobj_file (core_job_file )
71
+ else :
72
+ for seed in seeds :
73
+ seqFile = ('%s/%s' % (inFol , seed ))
74
+ seqName = get_seed_name (seed )
75
+ if not os .path .exists ('%s/core_orthologs/%s/hmm_dir/%s.hmm' % (outpath , seqName , seqName )) or forceCore == True :
76
+ seed_id = prepare_fn .identify_seed_id (seqFile , refspec , corepath , debug , silentOff )
77
+ core_compilation_jobs .append ([seqFile , seqName , refspec , seed_id ,
78
+ reuseCore , forceCore , coreArgs , pathArgs , orthoCoreArgs ,
79
+ otherCoreArgs , debug ])
80
+ general_fn .save_pyobj (core_compilation_jobs , core_job_file )
75
81
end = time .time ()
76
- print ('==> Preparing finished in %s\n ' % '{:5.3f}s' .format (end - begin ))
82
+ print ('==> %s jobs will be run. Preparing finished in %s' % ( len ( core_compilation_jobs ), '{:5.3f}s' .format (end - begin ) ))
77
83
if len (core_compilation_jobs ) > 0 :
78
84
pool = mp .Pool (cpus )
79
85
core_runtime = []
@@ -95,6 +101,7 @@ def search_ortholog(options, seeds, inFol, cpu, outpath):
95
101
begin = time .time ()
96
102
seqFile = [inFol + '/' + seed ]
97
103
seqName = get_seed_name (seed )
104
+ print ('... %s' % seqName )
98
105
if not os .path .exists ('%s/%s.extended.fa' % (outpath , seqName )) or force == True :
99
106
hamstr_out = ortho_fn .run_hamstr ([seqName , refspec , pathArgs , orthoArgs , otherArgs ])
100
107
output_fn .write_hamstr (hamstr_out , outpath , seqName , force , append )
@@ -323,7 +330,7 @@ def main():
323
330
otherCoreArgs = [cpus , debugCore , silentOff , noCleanup , force , append ]
324
331
core_options = [coreArgs , orthoCoreArgs , otherCoreArgs ]
325
332
other_options = [refspec , reuseCore , forceCore , pathArgs , debug ]
326
- core_runtime = compile_core (core_options , other_options , seeds , inFol , cpus , outpath , silentOff )
333
+ core_runtime = compile_core (core_options , other_options , seeds , inFol , cpus , outpath , silentOff , jobName )
327
334
end = time .time ()
328
335
multi_core_time = '{:5.3f}' .format (end - start )
329
336
print ('==> Core compilation finished in %ss\n ' % multi_core_time )
0 commit comments