Skip to content

Commit

Permalink
Merge pull request #12 from beelabhmc/fix/delete-metashape-files
Browse files Browse the repository at this point in the history
Allow Snakemake to delete the stitched.files/ directory if the stitching step fails
  • Loading branch information
aryarm authored Sep 25, 2020
2 parents 6501cec + b905c4f commit 85a6cca
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Snakefile
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,19 @@ rule stitch:
low_qual = "--fast" if check_config('low_qual_ortho', check_config('parallel')) else "",
ext = lambda wildcards: "--ext '"+SAMP_EXT[wildcards.sample][0]+"'"
output:
config['out']+"/{sample}/stitch"+("-lowQual" if check_config('low_qual_ortho', check_config('parallel')) else "")+"/stitched.psx"
project = config['out']+"/{sample}/stitch"+("-lowQual" if check_config('low_qual_ortho', check_config('parallel')) else "")+"/stitched.psx",
files = directory(config['out']+"/{sample}/stitch"+("-lowQual" if check_config('low_qual_ortho', check_config('parallel')) else "")+"/stitched.files")
conda: "envs/default.yml"
benchmark: config['out']+"/{sample}/benchmark/stitch"+("-lowQual" if check_config('low_qual_ortho', check_config('parallel')) else "")+".tsv"
shell:
"scripts/stitch.py {params} {input} {output}"
"scripts/stitch.py {params} {input} {output.project}"

rule export_ortho:
""" extract an orthomosaic image from the project file """
input:
rules.stitch.output
rules.stitch.output.project
output:
str(Path(rules.stitch.output[0]).parents[0])+"/ortho.tiff"
str(Path(rules.stitch.output.project).parents[0])+"/ortho.tiff"
conda: "envs/default.yml"
benchmark: config['out']+"/{sample}/benchmark/export_ortho.tsv"
shell:
Expand All @@ -142,7 +143,7 @@ rule segment:
rule transform:
""" transform the segments from the ortho to each image """
input:
rules.stitch.output,
rules.stitch.output.project,
lambda wildcards: rules.segment.output.high if wildcards.confidence == 'high' else rules.segment.output.low
output:
config['out']+"/{sample}/transforms/{confidence}/{image}.json"
Expand Down Expand Up @@ -193,7 +194,7 @@ rule watershed:
checkpoint rev_transform:
""" transform the segments from ortho coords to the original image coords """
input:
rules.stitch.output,
rules.stitch.output.project,
rules.watershed.output.segments
output:
directory(config['out']+"/{sample}/rev_transforms")
Expand Down

0 comments on commit 85a6cca

Please sign in to comment.