Commit c337624d authored by MARIJON Pierre's avatar MARIJON Pierre

correct error in add_no_chimeric_for_canu

parent dbc97153
......@@ -34,7 +34,7 @@ rule canu_paf_rename:
output:
canu_paf = canu_paf + ".paf"
shell:
package_path + "./script/basename2graphename.py gfa {input.canu_paf_canu_name} {input.readname} {output.canu_paf}"
package_path + "./script/basename2graphename.py paf {input.canu_paf_canu_name} {input.readname} {output.canu_paf}"
rule canu_paf_gfa_rename:
input:
......
......@@ -71,7 +71,7 @@ rule add_no_chimeric_for_canu:
minimap_paf_no_chimera = minimap_paf_no_chimera + ".paf",
canu_paf = canu_paf + ".paf",
minimap_paf_chimera = minimap_paf_chimera + ".paf",
yacrd_log = minimap_paf_chimera + ".paf"
yacrd_log = minimap_paf_chimera + ".yacrd"
output:
minimap_good = minimap_paf + ".paf"
shell:
......
......@@ -15,14 +15,15 @@ def main(yacrd_log, canu_paf, minimap_paf_no_chimera, minimap_paf_chimera, minim
chimeric_name = set()
with open(yacrd_log) as fh:
for line in fh:
chimeric_name.add(re.findall(r"[:,]", line)[1])
chimeric_name.add(re.split(r"[:,]", line)[1])
# canu paf
canu_name = set()
with open(canu_paf) as fh:
for line in fh:
if line.startswith("S"):
canu_name.add(line.split("\t")[1])
line = line.split("\t")
canu_name.add(line[0])
canu_name.add(line[5])
intersection = chimeric_name & canu_name
......@@ -31,7 +32,7 @@ def main(yacrd_log, canu_paf, minimap_paf_no_chimera, minimap_paf_chimera, minim
for line in no_chim:
out.write(line)
with open(minimap_good) as chim:
with open(minimap_paf_chimera) as chim:
for line in chim:
if line_in_set(line, intersection):
out.write(line)
......@@ -43,22 +43,22 @@ def clean_read_name(name):
return name.replace("read", "").lstrip('0')
@begin.subcommand
def paf(paf_file: "gfa file generate by canu",
def paf(paf_file: "paf file generate by canu",
read_name: "path to gatekeeper readName.txt",
new_gfa_file: "gfa file with node id replace by canu id",
new_paf_file: "paf file with node id replace by canu id",
invert: "set this option if you want replace the canu by node id" = False
):
id_map = build_correspondance_function(read_name, invert)
with open(new_gfa_file, "w") as output:
with open(new_paf_file, "w") as output:
paf_writer = csv.writer(output, delimiter="\t")
with open(gfa_file, "r") as gfa_input:
paf_parser = csv.reader(gfa_input, delimiter="\t")
for row in gfa_parser:
with open(paf_file, "r") as paf_input:
paf_parser = csv.reader(paf_input, delimiter="\t")
for row in paf_parser:
row[0] = id_map(row[0])
row[5] = id_map[row[5]]
gfa_writer.writerow(row)
row[5] = id_map(row[5])
paf_writer.writerow(row)
@begin.subcommand
def gfa(gfa_file: "gfa file generate by canu",
......
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