From 4427b4ac9044be0df5c657f094aa192e23b79a43 Mon Sep 17 00:00:00 2001 From: Marc Duez Date: Fri, 22 Apr 2016 12:08:55 +0100 Subject: [PATCH] pre-process: improve FAIL > pear.py > don't produce output file on failure > don't reschedule run if pre-process has failed --- .../web2py/applications/vidjil/models/task.py | 8 ++++++- tools/pear.py | 24 +++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/server/web2py/applications/vidjil/models/task.py b/server/web2py/applications/vidjil/models/task.py index 9d8873228..73d440c09 100755 --- a/server/web2py/applications/vidjil/models/task.py +++ b/server/web2py/applications/vidjil/models/task.py @@ -145,7 +145,7 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads, from datetime import timedelta as timed ## 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" @@ -160,6 +160,10 @@ def run_vidjil(id_file, id_config, id_data, id_fuse, grep_reads, 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 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 db.commit() raise IOError + + # Now we update the sequence file with the result of the pre-process # We forget the initial data_file (and possibly data_file2) db.sequence_file[sequence_file_id] = dict(data_file = stream, diff --git a/tools/pear.py b/tools/pear.py index 11010df15..1ad366985 100755 --- a/tools/pear.py +++ b/tools/pear.py @@ -6,6 +6,7 @@ import gzip import subprocess import argparse import shlex +import os 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", ) - -with gzip.open(f_out, 'w') as outFile: - with open(f_out+'.assembled.fastq', 'rb') as f1: - shutil.copyfileobj(f1, outFile) - if (args.keep_r1): - with open(f_out+'.unassembled.reverse.fastq', 'rb') as f2: - shutil.copyfileobj(f2, outFile) - if (args.keep_r2): - with open(f_out+'.unassembled.forward.fastq', 'rb') as f3: - shutil.copyfileobj(f3, outFile) +try : + with gzip.open(f_out, 'w') as outFile: + with open(f_out+'.assembled.fastq', 'rb') as f1: + shutil.copyfileobj(f1, outFile) + if (args.keep_r1): + with open(f_out+'.unassembled.reverse.fastq', 'rb') as f2: + shutil.copyfileobj(f2, outFile) + if (args.keep_r2): + with open(f_out+'.unassembled.forward.fastq', 'rb') as f3: + shutil.copyfileobj(f3, outFile) +except IOError : + os.remove(f_out) + raise IOError -- GitLab