From 4f3959052a95839815066305483fb89b5cd99767 Mon Sep 17 00:00:00 2001 From: Cecilia Yang <58164243+ycecilia@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:07:14 -0700 Subject: [PATCH 1/3] Run sealer after ntJoin scaffolding --- mtgrasp.smk | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/mtgrasp.smk b/mtgrasp.smk index 39ffa1f..0827b8f 100755 --- a/mtgrasp.smk +++ b/mtgrasp.smk @@ -244,22 +244,25 @@ rule pre_polishing: bf = bf_sealer(params.r1, params.r2, wildcards.library, params.threads, params.sealer_fpr,params.k) count = sum(1 for line in open(input[0])) k = k_string_converter(params.k) - if check_gaps(input.target) != 0: + # check if input file is empty + if count == 0: + print(f"Input file {input.target} is empty, no mitochondrial sequence found.") + exit(1) + if check_gaps(input.target) != 0 and count == 2: print("---Start Sealer Gap Filling---") - if count <= 2: - shell("""abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {input.target} {params.r1} {params.r2} &> {log_sealer}""") - print("no ntJoin needed") - else: - shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads} && abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {params.ntjoin_out} {params.r1} {params.r2} &> {log_sealer}""") - print("ntJoin needed") - else: + print("One-piece contig found, no ntJoin scaffolding needed") + shell("""abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {input.target} {params.r1} {params.r2} &> {log_sealer}""") + + elif check_gaps(input.target) == 0 and count == 2: print("---No Gaps Found, Gap Filling Not Needed---") - if count <= 2: - shell("cp {input.target} {output}") - print("no ntJoin needed") - else: - shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads} && cp {params.ntjoin_out} {output}""") - print("ntJoin needed") + print("One-piece contig found, no ntJoin scaffolding needed") + shell("cp {input.target} {output}") + + # If multiple contigs are found, both ntJoin and Sealer are needed + else: + print("Mutiple contigs found, ntJoin scaffolding and Gap-filling are both needed") + shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads} && abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {params.ntjoin_out} {params.r1} {params.r2} &> {log_sealer}""") + From 80e6ac312d9deb649a9712d6fdab53a1bc8102e4 Mon Sep 17 00:00:00 2001 From: Cecilia Yang <58164243+ycecilia@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:28:32 -0700 Subject: [PATCH 2/3] Update mtgrasp.smk Co-authored-by: Lauren Coombe --- mtgrasp.smk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtgrasp.smk b/mtgrasp.smk index 0827b8f..64f3997 100755 --- a/mtgrasp.smk +++ b/mtgrasp.smk @@ -260,7 +260,7 @@ rule pre_polishing: # If multiple contigs are found, both ntJoin and Sealer are needed else: - print("Mutiple contigs found, ntJoin scaffolding and Gap-filling are both needed") + print("Multiple contigs found, ntJoin scaffolding and Gap-filling are both needed") shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads} && abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {params.ntjoin_out} {params.r1} {params.r2} &> {log_sealer}""") From 2de8827e72668f8a49cfbb6ce0739b00adc1c25c Mon Sep 17 00:00:00 2001 From: Cecilia Yang <58164243+ycecilia@users.noreply.github.com> Date: Thu, 14 Sep 2023 13:35:05 -0700 Subject: [PATCH 3/3] Update mtgrasp.smk --- mtgrasp.smk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mtgrasp.smk b/mtgrasp.smk index 64f3997..64de3d4 100755 --- a/mtgrasp.smk +++ b/mtgrasp.smk @@ -244,16 +244,17 @@ rule pre_polishing: bf = bf_sealer(params.r1, params.r2, wildcards.library, params.threads, params.sealer_fpr,params.k) count = sum(1 for line in open(input[0])) k = k_string_converter(params.k) + num_gaps = check_gaps(input.target) # check if input file is empty if count == 0: print(f"Input file {input.target} is empty, no mitochondrial sequence found.") exit(1) - if check_gaps(input.target) != 0 and count == 2: + if num_gaps != 0 and count == 2: print("---Start Sealer Gap Filling---") print("One-piece contig found, no ntJoin scaffolding needed") shell("""abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {input.target} {params.r1} {params.r2} &> {log_sealer}""") - elif check_gaps(input.target) == 0 and count == 2: + elif num_gaps == 0 and count == 2: print("---No Gaps Found, Gap Filling Not Needed---") print("One-piece contig found, no ntJoin scaffolding needed") shell("cp {input.target} {output}") @@ -261,7 +262,8 @@ rule pre_polishing: # If multiple contigs are found, both ntJoin and Sealer are needed else: print("Multiple contigs found, ntJoin scaffolding and Gap-filling are both needed") - shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads} && abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {params.ntjoin_out} {params.r1} {params.r2} &> {log_sealer}""") + shell("""bash run_ntjoin.sh {params.workdir} {target} {ref} {log_ntjoin} {params.threads}""") + shell("""abyss-sealer -b{bf} -j {params.threads} -vv {k} -P {params.p} -o {params.out} -S {params.ntjoin_out} {params.r1} {params.r2} &> {log_sealer}""")