Skip to content

Commit

Permalink
Merge pull request #11 from bcgsc/snakemakefile_rule_pre_polishing_fix
Browse files Browse the repository at this point in the history
Run sealer after ntJoin scaffolding
  • Loading branch information
ycecilia authored Sep 14, 2023
2 parents c193f77 + 2de8827 commit 606c52f
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions mtgrasp.smk
Original file line number Diff line number Diff line change
Expand Up @@ -244,22 +244,27 @@ 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:
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 num_gaps != 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 num_gaps == 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("Multiple contigs found, ntJoin scaffolding and Gap-filling are both needed")
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}""")




Expand Down

0 comments on commit 606c52f

Please sign in to comment.