Commit 4427b4ac authored by marc's avatar marc

pre-process: improve FAIL

> pear.py > don't produce output file on failure
> don't reschedule run if pre-process has failed
parent b78ab357
...@@ -145,7 +145,7 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads, ...@@ -145,7 +145,7 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads,
from datetime import timedelta as timed from datetime import timedelta as timed
## re schedule if pre_process is still pending ## re schedule if pre_process is still pending
if db.sequence_file[id_file].pre_process_flag != "DONE" and db.sequence_file[id_file].pre_process_flag != None : if db.sequence_file[id_file].pre_process_flag == "WAIT" or db.sequence_file[id_file].pre_process_flag == "RUN" :
print "Pre-process is still pending, re-schedule" print "Pre-process is still pending, re-schedule"
...@@ -160,6 +160,10 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads, ...@@ -160,6 +160,10 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads,
return "SUCCESS" return "SUCCESS"
if db.sequence_file[id_file].pre_process_flag == "FAILED" :
print "Pre-process has failed"
raise ValueError('pre-process has failed')
return "FAIL"
## les chemins d'acces a vidjil / aux fichiers de sequences ## les chemins d'acces a vidjil / aux fichiers de sequences
germline_folder = defs.DIR_VIDJIL + '/germline/' germline_folder = defs.DIR_VIDJIL + '/germline/'
...@@ -702,6 +706,8 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a ...@@ -702,6 +706,8 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
db.commit() db.commit()
raise IOError raise IOError
# Now we update the sequence file with the result of the pre-process # Now we update the sequence file with the result of the pre-process
# We forget the initial data_file (and possibly data_file2) # We forget the initial data_file (and possibly data_file2)
db.sequence_file[sequence_file_id] = dict(data_file = stream, db.sequence_file[sequence_file_id] = dict(data_file = stream,
......
...@@ -6,6 +6,7 @@ import gzip ...@@ -6,6 +6,7 @@ import gzip
import subprocess import subprocess
import argparse import argparse
import shlex import shlex
import os
parser = argparse.ArgumentParser(description='Use PEAR read merger to make a new fastq file and keep unmerged reads') parser = argparse.ArgumentParser(description='Use PEAR read merger to make a new fastq file and keep unmerged reads')
...@@ -32,13 +33,16 @@ subprocess.call(["pear", ...@@ -32,13 +33,16 @@ subprocess.call(["pear",
) )
try :
with gzip.open(f_out, 'w') as outFile: with gzip.open(f_out, 'w') as outFile:
with open(f_out+'.assembled.fastq', 'rb') as f1: with open(f_out+'.assembled.fastq', 'rb') as f1:
shutil.copyfileobj(f1, outFile) shutil.copyfileobj(f1, outFile)
if (args.keep_r1): if (args.keep_r1):
with open(f_out+'.unassembled.reverse.fastq', 'rb') as f2: with open(f_out+'.unassembled.reverse.fastq', 'rb') as f2:
shutil.copyfileobj(f2, outFile) shutil.copyfileobj(f2, outFile)
if (args.keep_r2): if (args.keep_r2):
with open(f_out+'.unassembled.forward.fastq', 'rb') as f3: with open(f_out+'.unassembled.forward.fastq', 'rb') as f3:
shutil.copyfileobj(f3, outFile) shutil.copyfileobj(f3, outFile)
except IOError :
os.remove(f_out)
raise IOError
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment