Commit c15457db authored by Penom Nom's avatar Penom Nom
Browse files

hotfix for ng6test

parent 9891e3ba
......@@ -71,7 +71,7 @@ class SVDetection (NG6Workflow):
results=[delly.output_file, breakdancer.output_file, cnvnator.output_file, pindel.output_file]
translocations = [delly.translocation_file, breakdancer.translocation_file, cnvnator.translocation_file, pindel_tra.translocation_file]
arg_list = [results, self.overlap_percent, self.li_range, ["dly", "BD","CNV","Pdl"], options, translocations]
arg_list = [results, self.overlap_percent, self.li_range, ["delly", "breakdancer","cnvnator","pindel"], options, translocations]
self.add_component(component_name="Analyzebed", addto="project", args=arg_list)
def post_process(self):
......
......@@ -23,7 +23,6 @@ import numpy
import itertools
import subprocess
import re
from types import NoneType
class Analyzebed (Analysis):
......@@ -47,7 +46,7 @@ class Analyzebed (Analysis):
breakdancer_help = subprocess.Popen(["breakdancer-max"], universal_newlines=True, stderr=subprocess.PIPE)
breakdancer_version = re.search("breakdancer-max version ([0-9\.]+)", breakdancer_help.stderr.read())
v_list = [pindel_version,cnvnator_version, delly_version, breakdancer_version]
for v,i in enumerate(v_list):
for i,v in enumerate(v_list):
if v is None:
v_list[i] = 'unknonw'
else:
......@@ -155,8 +154,11 @@ class Analyzebed (Analysis):
self._add_result_element("software_merge", "venn_count", db_venn, type)
#output files
result_files = [self.output_links, self.software_merge, self.tra_files]
self._create_and_archive(result_files, "None") #TODO pass result_files
result_files = []
result_files.extend(self.output_links)
result_files.extend(self.software_merge)
result_files.extend(self.tra_files)
self._archive_files(result_files, "tar.gz")
def process(self):
#create links
......
......@@ -167,11 +167,12 @@ name_list = sys.argv[8:]
return new_sv
def filter_out(sv, size_min, size_max):
#return True if we need to keep the SV
size = float(sv[5])
if size < int(size_min) or size > int(size_max):
return True
else:
return False
else:
return True
def main(SV_file_path, good_path, translocation_file, soft, tag, len_min, len_max, indiv_list, alt_names=[]):
"""
......@@ -227,7 +228,7 @@ def main(SV_file_path, good_path, translocation_file, soft, tag, len_min, len_ma
new_sv = "\t".join(good_sv) + "\n"
if soft == "pindel_translocation" or good_sv[5] == "TRA":
tra_output_file.write(new_sv)
elif filter_out(new_sv, len_min, len_max):
elif filter_out(good_sv, len_min, len_max):
good_output_file.write(new_sv)
else:
pass
......
......@@ -40,15 +40,18 @@ def main(input_f, out, tag, len_min, len_max):
with open(input_f, 'r') as SV_list, open(out,'w') as output_file:
for c,line in enumerate(SV_list):
call_id = tag + "-" + str(c+1)
results = re.match("([a-z]+)\s(?:chr)?([0-9A-Z\.]+):([0-9]+)-([0-9]+)\s([0-9e\.\+]+)\s([0-9.]+)", line)
if results:
sv_type, chromosome, start, end, length, support = results.groups()
new_sv = [chromosome, start, end, call_id, sv_type, length, "/", support]
if filter_out(new_sv, len_min, len_max):
pass
else:
new_sv = "\t".join(new_sv) + "\n"
output_file.write(new_sv)
results = line.split()
sv_type, pos, length, support = results[:4]
chromosome, pos = pos.split(":")
if chromosome[:3] == "chr":
chromosome = chromosome[3:]
start, end = pos.split("-")
new_sv = [chromosome, start, end, call_id, sv_type, length, support, "/"]
if filter_out(new_sv, len_min, len_max):
pass
else:
new_sv = "\t".join(new_sv) + "\n"
output_file.write(new_sv)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
......
......@@ -133,6 +133,7 @@ def write_sv_list(filename, sv_list, indiv_list):
# construct line
line.extend(bed_infos)
line.append(g.size())
line.append("/")
line.append(";".join(member_table))
line.extend(support_table)
line = map(str,line)
......
......@@ -37,6 +37,8 @@ class Standardisation (Component):
self.add_parameter_list("indiv_list", "String list of studied individuals name", default=indiv_list, type=str, required=True)
def process(self):
sort = ShellFunction(self.get_exec_path("sort") + " -k1,1n -k2,2n $1 > $2", cmd_format='{EXE} {IN} {OUT}')
unsorted_out = self.get_temporary_file(".bed")
if self.mode != "cnvnator":
#FIX
breakdancer_fix = " ".join(self.input_bam)
......@@ -55,7 +57,8 @@ class Standardisation (Component):
--min_length {0} --max_length {1} ".format(self.min_len, self.max_len) + \
breakdancer_fix,
cmd_format='{EXE} {IN} {OUT} {ARG}')
std(inputs=self.input_file, outputs=[self.output_file, self.translocation_file], arguments=self.indiv_list) # Here, the mode is also used as a tag for the SVs (ID prefix)
std(inputs=self.input_file, outputs=[unsorted_out, self.translocation_file], arguments=self.indiv_list) # Here, the mode is also used as a tag for the SVs (ID prefix)
sort(unsorted_out, self.output_file)
else :
tmp_out = [file_path + ".bed" for file_path in self.input_file]
#CNV2BED
......@@ -65,11 +68,9 @@ class Standardisation (Component):
--tag $3 \
--min_length {0} --max_length {1}".format(self.min_len, self.max_len),
cmd_format='{EXE} {IN} {OUT} {ARG}')
sort = ShellFunction(self.get_exec_path("sort") + " -k1,1n -k2,2n $1 > $2", cmd_format='{EXE} {IN} {OUT}')
if len(self.input_file) > 1:
for i in range(len(self.input_file)):
std(inputs=self.input_file[i], outputs=tmp_out[i], arguments=self.indiv_list[i])
unsorted_out = self.get_temporary_file(".bed")
#MERGE_SV
mrg = ShellFunction(self.get_exec_path("merge_sv.py") + \
" --output $1 \
......
Supports Markdown
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