Permalink
Browse files

Add IgReC support

  • Loading branch information...
eodus committed Apr 13, 2018
1 parent 7e097da commit 830361b3f8b69c9cefb67c92348a1560df59817f
@@ -40,6 +40,7 @@
DIR_VIDJIL = '/usr/bin/'
DIR_FUSE = '../../tools'
DIR_MIXCR = '/usr/bin'
DIR_IGREC = '/usr/local/bin/'
DIR_GERMLINE = '/usr/share/vidjil/germline'
### Port on which to run the fuse server
### Used in models/task.py and in /server/fuse_server.py
@@ -39,6 +39,7 @@
DIR_VIDJIL = '/usr/bin/'
DIR_FUSE = '../../tools'
DIR_MIXCR = '../../'
DIR_IGREC = '../../'
DIR_GERMLINE = '/usr/share/vidjil/germline'
### Port on which to run the fuse server
### Used in models/task.py and in /server/fuse_server.py
@@ -299,6 +299,97 @@ def run_vidjil(id_file, id_config, id_data, grep_reads,
return "SUCCESS"
def run_igrec(id_file, id_config, id_data, clean_before=False, clean_after=False):
from subprocess import Popen, PIPE, STDOUT, os
import time
import json
upload_folder = defs.DIR_SEQUENCES
out_folder = defs.DIR_OUT_VIDJIL_ID % id_data
# FIXME Use shutil instead
cmd = "rm -rf "+out_folder
p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True)
p.wait()
## filepath du fichier de séquence
row = db(db.sequence_file.id==id_file).select()
filename = row[0].data_file
output_filename = defs.BASENAME_OUT_VIDJIL_ID % id_data
seq_file = upload_folder+filename
## config de vidjil
arg_cmd = db.config[id_config].command
os.makedirs(out_folder)
out_log = out_folder + '/vidjil-igrec.log'
log_file = open(out_log, 'w')
out_results = out_folder + "/out/igrec.vidjil"
## commande complete
try:
igrec = defs.DIR_IGREC + '/igrec.py'
if not os.path.isfile(igrec):
print("!!! IgReC binary file not found")
cmd = "%s -s %s -o %s/out %s" % (igrec, seq_file, out_folder, arg_cmd)
## execute la commande IgReC
print("=== Launching IgReC ===")
print(cmd)
print("========================")
sys.stdout.flush()
p = Popen(cmd, shell=True, stdin=PIPE, stdout=log_file, stderr=STDOUT, close_fds=True)
p.wait()
print("Output log in " + out_log)
sys.stdout.flush()
## Get result file
print("===>", out_results)
results_filepath = os.path.abspath(out_results)
stream = open(results_filepath, 'rb')
stream.close()
except:
print("!!! IgReC failed, no result file")
res = {"message": "[%s] c%s: IgReC FAILED - %s" % (id_data, id_config, out_folder)}
log.error(res)
raise
original_name = row[0].data_file
with open(results_filepath, 'r') as json_file:
my_json = json.load(json_file)
fill_field(my_json, original_name, "original_names", "samples")
fill_field(my_json, cmd, "commandline", "samples")
# TODO fix this dirty hack to get around bad file descriptor error
new_file = open(results_filepath, 'w')
json.dump(my_json, new_file)
new_file.close()
## insertion dans la base de donnée
ts = time.time()
stream = open(results_filepath, 'rb')
db.results_file[id_data] = dict(status = "ready",
run_date = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S'),
data_file = stream
)
db.commit()
config_name = db.config[id_config].name
res = {"message": "[%s] c%s: IgReC - %s" % (id_data, id_config, out_folder)}
log.info(res)
for row in db(db.sample_set_membership.sequence_file_id==id_file).select() :
sample_set_id = row.sample_set_id
print(row.sample_set_id)
run_fuse(id_file, id_config, id_data, sample_set_id, clean_before = False)
return "SUCCESS"
def run_mixcr(id_file, id_config, id_data, clean_before=False, clean_after=False):
from subprocess import Popen, PIPE, STDOUT, os
import time
@@ -789,6 +880,7 @@ def run_pre_process(pre_process_id, sequence_file_id, clean_before=True, clean_a
scheduler = Scheduler(db, dict(vidjil=run_vidjil,
compute_contamination=compute_contamination,
mixcr=run_mixcr,
igrec=run_igrec,
none=run_copy,
pre_process=run_pre_process,
refuse=run_refuse),
@@ -42,6 +42,7 @@ DIR_VIDJIL = '../../'
DIR_VIDJIL_NEXT = '../../'
DIR_FUSE = '../../tools'
DIR_MIXCR = '../../'
DIR_IGREC = '../../'
DIR_PEAR = '../../'
DIR_CLONEDB = '../../../clonedb'
@@ -13,6 +13,7 @@
<td><select id="config_program" name="config_program">
<option value="none">none</option>
<option value="vidjil">vidjil</option>
<option value="igrec">igrec</option>
<option value="euro-mrd pipeline">euro-mrd pipeline</option>
<option value="mixcr">mixcr</option>
</select></td>
@@ -18,6 +18,7 @@
<td><select id="config_program" name="config_program">
<option value="none" {{if info.program == "none":}}selected="selected"{{pass}}>none</option>
<option value="vidjil" {{if info.program == "vidjil":}}selected="selected"{{pass}}>vidjil</option>
<option value="igrec" {{if info.program == "igrec":}}selected="selected"{{pass}}>igrec</option>
<option value="mixcr" {{if info.program == "mixcr":}}selected="selected"{{pass}}>mixcr</option>
<option value="euro-mrd pipeline" {{if info.program == "euro-mrd pipeline":}}selected="selected"{{pass}}>euro-mrd pipeline</option>
</select></td>

0 comments on commit 830361b

Please sign in to comment.