Skip to content

Commit ad0dca4

Browse files
committed
No matches within either threshold. Allowing top samples parameter to be 0.
1 parent fa2c922 commit ad0dca4

3 files changed

Lines changed: 118 additions & 4 deletions

File tree

bin/process_output.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
EMPTY_STRING = ""
1818
NULL = "NULL"
19-
NO_MATCHES = "No match within threshold"
19+
NO_MATCHES = "No matches within thresholds"
20+
# The above may happen as a consequence of the distance threshold, the top matches threshold, or both.
2021

2122
class DistanceType(Enum):
2223
HAMMING = "hamming"

conf/modules.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ process {
9898
// and/or not be used by the process script.
9999
def scheduled_argument = (params.output_type == "scheduled") ? "--scheduled" : ""
100100
def date_argument = (params.output_type == "scheduled") ? "--date_string ${date_prefix}": ""
101-
def top_samples_threshold_argument = (params.output_type == "scheduled" && params.fastmatch_top_samples_threshold) ? "--top_samples_threshold ${params.fastmatch_top_samples_threshold}": ""
101+
def top_samples_threshold_argument = (params.output_type == "scheduled" && (params.fastmatch_top_samples_threshold || params.fastmatch_top_samples_threshold == 0)) ? "--top_samples_threshold ${params.fastmatch_top_samples_threshold}": ""
102102

103103
// Output File Path:
104104
// PREFIX_DATE_fastmatch -> PREFIX_DATE_fastmatch.xlsx

tests/modules/process_output/main.nf.test

Lines changed: 115 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,10 +342,10 @@ nextflow_process {
342342
assert lines.size() == 3
343343
assert lines[0] == "query_id\tfastmatch_status\tfastmatch_top_samples\tfastmatch_matched_samples_count\tfastmatch_threshold\tfastmatch_date\tfastmatch_code_match\tfastmatch_top_genomic_address\tfastmatch_results_filename"
344344

345-
def sample1_regex = /sample1\tCompleted\tNo match within threshold\t0\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\tNULL\tNULL\tfastmatch.xlsx/
345+
def sample1_regex = /sample1\tCompleted\tNo matches within thresholds\t0\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\tNULL\tNULL\tfastmatch.xlsx/
346346
assert lines[1].matches(sample1_regex)
347347

348-
def sample2_regex = /sample2\tCompleted\tNo match within threshold\t0\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\tNULL\tNULL\tfastmatch.xlsx/
348+
def sample2_regex = /sample2\tCompleted\tNo matches within thresholds\t0\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\tNULL\tNULL\tfastmatch.xlsx/
349349
assert lines[2].matches(sample2_regex)
350350

351351
lines = processed_output_tsv.text.split("\n")
@@ -466,4 +466,117 @@ nextflow_process {
466466
assert processed_output_tsv.text.contains("sample6\tsample6\tsample6\tsample6\t0\t\t\ttrue\tTrue\t\t\t\t48\t\tstring")
467467
}
468468
}
469+
470+
test("0 Top Samples") {
471+
tag "process_output"
472+
tag "process_output_0_top_samples"
473+
474+
when {
475+
process {
476+
"""
477+
input[0] = Channel.from(["$baseDir/tests/data/distances/multiple.tsv"])
478+
input[1] = Channel.from([10])
479+
"""
480+
}
481+
482+
params {
483+
outdir = "results"
484+
485+
output_type = "scheduled"
486+
487+
pd_distm = "hamming"
488+
fastmatch_top_samples_threshold = 0
489+
490+
output_prefix = ""
491+
prefix_include_date = false
492+
493+
metadata_1_header = "genomic_address_name"
494+
metadata_2_header = "national_outbreak_code"
495+
}
496+
}
497+
498+
then {
499+
assert process.success
500+
501+
assert path("$launchDir/results/process/fastmatch.tsv").exists()
502+
assert path("$launchDir/results/process/fastmatch.xlsx").exists()
503+
assert path("$launchDir/results/process/fastmatch.scheduled.tsv").exists()
504+
505+
// Check Processed Output
506+
def processed_output_tsv = path("$launchDir/results/process/fastmatch.tsv")
507+
def processed_output_xlsx = path("$launchDir/results/process/fastmatch.xlsx")
508+
def scheduled_output_tsv = path("$launchDir/results/process/fastmatch.scheduled.tsv")
509+
510+
def lines = scheduled_output_tsv.text.split("\n")
511+
assert lines[0] == "query_id\tfastmatch_status\tfastmatch_top_samples\tfastmatch_matched_samples_count\tfastmatch_threshold\tfastmatch_date\tfastmatch_code_match\tfastmatch_top_genomic_address\tfastmatch_results_filename"
512+
513+
def sample1_regex = /sample1\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
514+
assert lines[1].matches(sample1_regex)
515+
516+
def sample2_regex = /sample2\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
517+
assert lines[2].matches(sample2_regex)
518+
519+
def sample3_regex = /sample3\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
520+
assert lines[3].matches(sample3_regex)
521+
522+
def sample4_regex = /sample4\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
523+
assert lines[4].matches(sample4_regex)
524+
525+
def sample5_regex = /sample5\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
526+
assert lines[5].matches(sample5_regex)
527+
528+
def sample6_regex = /sample6\tCompleted\tNo matches within thresholds\t8\t10.0\t\d{4}-\d{2}-\d{2}T\d{2}\d{2}Z\t1,2,3,4,5,6,7,8\tNULL\tfastmatch.xlsx/
529+
assert lines[6].matches(sample6_regex)
530+
531+
assert processed_output_tsv.text.contains("Query ID\tQuery Sample Name\tReference ID\tReference Sample Name\tDistance\tgenomic_address_name\tnational_outbreak_code\tmetadata_3\tmetadata_4\tmetadata_5\tmetadata_6\tmetadata_7\tmetadata_8\tmetadata_9\tmetadata_10\tmetadata_11\tmetadata_12\tmetadata_13\tmetadata_14\tmetadata_15\tmetadata_16")
532+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample1\tsample1\t0\t1.1.1.1\t1")
533+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample2\tsample2\t0\t2.2.2.2\t2")
534+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample3\tsample3\t1\t3.3.3.3\t3")
535+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample8\tsample8\t2\t8.8.8.8\t8")
536+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample4\tsample4\t2\t4.4.4.4\t4")
537+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample5\tsample5\t2\t5.5.5.5\t5")
538+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample7\tsample7\t3\t7.7.7.7\t7")
539+
assert processed_output_tsv.text.contains("sample1\tsample1\tsample6\tsample6\t3\t6.6.6.6\t6")
540+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample1\tsample1\t0\t1.1.1.1\t1")
541+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample2\tsample2\t0\t2.2.2.2\t2")
542+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample3\tsample3\t1\t3.3.3.3\t3")
543+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample8\tsample8\t2\t8.8.8.8\t8")
544+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample4\tsample4\t2\t4.4.4.4\t4")
545+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample5\tsample5\t2\t5.5.5.5\t5")
546+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample7\tsample7\t3\t7.7.7.7\t7")
547+
assert processed_output_tsv.text.contains("sample2\tsample2\tsample6\tsample6\t3\t6.6.6.6\t6")
548+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample3\tsample3\t0\t3.3.3.3\t3")
549+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample1\tsample1\t1\t1.1.1.1\t1")
550+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample2\tsample2\t1\t2.2.2.2\t2")
551+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample6\tsample6\t2\t6.6.6.6\t6")
552+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample7\tsample7\t3\t7.7.7.7\t7")
553+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample8\tsample8\t3\t8.8.8.8\t8")
554+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample4\tsample4\t3\t4.4.4.4\t4")
555+
assert processed_output_tsv.text.contains("sample3\tsample3\tsample5\tsample5\t3\t5.5.5.5\t5")
556+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample4\tsample4\t0\t4.4.4.4\t4")
557+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample8\tsample8\t1\t8.8.8.8\t8")
558+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample5\tsample5\t1\t5.5.5.5\t5")
559+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample1\tsample1\t2\t1.1.1.1\t1")
560+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample2\tsample2\t2\t2.2.2.2\t2")
561+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample6\tsample6\t2\t6.6.6.6\t6")
562+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample7\tsample7\t3\t7.7.7.7\t7")
563+
assert processed_output_tsv.text.contains("sample4\tsample4\tsample3\tsample3\t3\t3.3.3.3\t3")
564+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample8\tsample8\t0\t8.8.8.8\t8")
565+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample5\tsample5\t0\t5.5.5.5\t5")
566+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample4\tsample4\t1\t4.4.4.4\t4")
567+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample7\tsample7\t2\t7.7.7.7\t7")
568+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample1\tsample1\t2\t1.1.1.1\t1")
569+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample2\tsample2\t2\t2.2.2.2\t2")
570+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample3\tsample3\t3\t3.3.3.3\t3")
571+
assert processed_output_tsv.text.contains("sample5\tsample5\tsample6\tsample6\t3\t6.6.6.6\t6")
572+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample6\tsample6\t0\t6.6.6.6\t6")
573+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample7\tsample7\t2\t7.7.7.7\t7")
574+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample3\tsample3\t2\t3.3.3.3\t3")
575+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample4\tsample4\t2\t4.4.4.4\t4")
576+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample8\tsample8\t3\t8.8.8.8\t8")
577+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample1\tsample1\t3\t1.1.1.1\t1")
578+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample2\tsample2\t3\t2.2.2.2\t2")
579+
assert processed_output_tsv.text.contains("sample6\tsample6\tsample5\tsample5\t3\t5.5.5.5\t5")
580+
}
581+
}
469582
}

0 commit comments

Comments
 (0)