-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
950546a
commit 6f91af7
Showing
6 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env python | ||
|
||
import sys | ||
import tifftools | ||
import re | ||
import os | ||
|
||
input = sys.argv[1] | ||
|
||
os.rename(input, input + ".original") | ||
|
||
date_pattern = r"(<Date>((\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(\.\d+)?Z?))</Date>" | ||
date_replacement = "<Date />" | ||
|
||
|
||
sample_pattern = r"<SampleDescription>.+</SampleDescription>" | ||
sample_replacement = "<SampleDescription />" | ||
|
||
qptiff_info = tifftools.read_tiff(input + ".original") | ||
|
||
for i, ifd in enumerate(qptiff_info["ifds"]): | ||
for tag in ifd["tags"]: | ||
if tag == tifftools.Tag.IMAGEDESCRIPTION: | ||
old_description = ifd["tags"][tifftools.Tag.IMAGEDESCRIPTION.value]["data"] | ||
new_description = re.sub(date_pattern, date_replacement, old_description) | ||
new_description = re.sub(sample_pattern, sample_replacement, new_description) | ||
if new_description != old_description: | ||
print(f"Redacting date in IFD {i}, tag {tag}") | ||
qptiff_info["ifds"][i]["tags"][tifftools.Tag.IMAGEDESCRIPTION.value][ | ||
"data" | ||
] = new_description | ||
|
||
tifftools.write_tiff(qptiff_info, input, allowExisting=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
process clean_qptiff { | ||
input: | ||
tuple val(meta), file(image) | ||
output: | ||
tuple val(meta), file(image) | ||
stub: | ||
""" | ||
touch image_cleaned.svs | ||
""" | ||
script: | ||
""" | ||
clean_qptiff.py $image | ||
""" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
//include { remove_qptiff_label } from "../modules/remove_qptiff_label.nf" | ||
//include { remove_qptiff_macro } from "../modules/remove_qptiff_macro.nf" | ||
include { clean_qptiff } from "../modules/clean_qptiff.nf" | ||
|
||
|
||
workflow CLEAN_QPTIFF { | ||
take: | ||
images | ||
|
||
main: | ||
|
||
clean_qptiff(images) | ||
clean_qptiff.out.set{cleaned} | ||
|
||
emit: | ||
cleaned | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,16 @@ | ||
include { SAMPLESHEET_SPLIT } from '../subworkflows/samplesheet_split.nf' | ||
include { CLEAN_OME } from '../subworkflows/clean_ome.nf' | ||
include { CLEAN_SVS } from '../subworkflows/clean_svs.nf' | ||
include { CLEAN_QPTIFF } from '../subworkflows/clean_qptiff.nf' | ||
include { CLEAN_TIFF } from '../subworkflows/clean_tiff.nf' | ||
|
||
workflow CLEANER { | ||
SAMPLESHEET_SPLIT (params.input) | ||
CLEAN_OME ( SAMPLESHEET_SPLIT.out.ome ) | ||
CLEAN_SVS ( SAMPLESHEET_SPLIT.out.svs ) | ||
CLEAN_OME ( SAMPLESHEET_SPLIT.out.ome ) | ||
CLEAN_SVS ( SAMPLESHEET_SPLIT.out.svs ) | ||
CLEAN_QPTIFF ( SAMPLESHEET_SPLIT.out.qptiff ) | ||
SAMPLESHEET_SPLIT.out.other | ||
.mix ( CLEAN_OME.out.cleaned, CLEAN_SVS.out.cleaned ) | ||
.mix ( CLEAN_OME.out.cleaned, CLEAN_SVS.out.cleaned, CLEAN_QPTIFF.out.cleaned ) | ||
.set { combined } | ||
CLEAN_TIFF ( combined ) | ||
} |