Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading files for new integration tests #10

Merged
merged 5 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/data/irida/test2_iridanext.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"files": {
"global": [],
"samples": {
"sampleR": [
{
"path": "input/sampleR_error_report.csv"
}
]
}
},
"metadata": {
"samples": {
"sampleQ": {
"address": "1.1.3"
}
}
}
}
13 changes: 13 additions & 0 deletions tests/data/irida/test_iridanext.output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files": {
"global": [],
"samples": {}
},
"metadata": {
"samples": {
"sampleQ": {
"address": "1.1.3"
}
}
}
}
7 changes: 7 additions & 0 deletions tests/data/reports/sample7.mlst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sample7": {
"l1": "1",
"l2": "1",
"l3": "1"
}
}
7 changes: 7 additions & 0 deletions tests/data/reports/sampleF.mlst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"sampleF": {
"l1": "1",
"l2": "2",
"l3": "1"
}
}
5 changes: 5 additions & 0 deletions tests/data/samplesheets/samplesheet_test1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
sample,mlst_alleles,address
sampleQ,https://raw.githubusercontent.com/phac-nml/gasnomenclature/add_tests/tests/data/reports/sampleF.mlst.json,
sample1,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sample1.mlst.json,1.1.1
sample2,https://raw.githubusercontent.com/phac-nml/gasnomenclature/add_tests/tests/data/reports/sample7.mlst.json,1.1.1
sample3,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sample3.mlst.json,1.1.2
7 changes: 7 additions & 0 deletions tests/data/samplesheets/samplesheet_test2.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
sample,mlst_alleles,address
sampleR,https://raw.githubusercontent.com/phac-nml/gasnomenclature/add_tests/tests/data/reports/sampleF.mlst.json,
sampleQ,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sampleQ.mlst.json,
sample1,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sample1.mlst.json,1.1.1
sample2,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sample2.mlst.json,1.1.1
sample3,https://raw.githubusercontent.com/phac-nml/gasnomenclature/dev/tests/data/reports/sample3.mlst.json,1.1.2

4 changes: 4 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@ due to issues with multiprocessing in the container. A similar
error is found at https://github.com/marcelm/cutadapt/issues/583
*/
singularity.runOptions = "--contain"

/* Remove gzipping on JSON output for testing/asserts on file contents
*/
iridanext.output.path = "${params.outdir}/iridanext.output.json"
76 changes: 74 additions & 2 deletions tests/pipelines/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ nextflow_pipeline {
script "main.nf"

test("Small-scale test of full pipeline"){
tag "pipeline"
tag "pipeline_success"

when{
params {
Expand All @@ -23,7 +23,6 @@ nextflow_pipeline {
def expected_profile_tsv = path("$baseDir/tests/data/profiles/expected-profile1.tsv")
assert actual_profile_ref.text == expected_profile_tsv.text


// Check computed pairwise distances
def actual_distances = path("$launchDir/results/distances/results.text")
def expected_distances = path("$baseDir/tests/data/distances/expected_pairwise_dists.txt")
Expand All @@ -33,8 +32,81 @@ nextflow_pipeline {
def actual_calls = path("$launchDir/results/call/Called/results.text")
def expected_calls = path("$baseDir/tests/data/called/expected_results.txt")
assert actual_calls.text == expected_calls.text

// Check IRIDA Next JSON output
assert path("$launchDir/results/iridanext.output.json").json == path("$baseDir/tests/data/irida/test_iridanext.output.json").json

def iridanext_json = path("$launchDir/results/iridanext.output.json").json
def iridanext_samples = iridanext_json.files.samples
def iridanext_metadata = iridanext_json.metadata.samples

assert iridanext_metadata.size() == 1 && iridanext_metadata.containsKey("sampleQ")
assert iridanext_metadata.sampleQ."address" == "1.1.3"
apetkau marked this conversation as resolved.
Show resolved Hide resolved
}
}

test("Integration test where input contains reference sample with mismatched MLST JSON file"){
tag "pipeline_failure"

when {
params {
input = "$baseDir/tests/data/samplesheets/samplesheet_test1.csv"
outdir = "results"
}
}

then {
assert workflow.failed
assert (workflow.stdout =~ /Pipeline exiting: sample with ID sample2 does not have matching MLST JSON file./).find()

assert path("$launchDir/results").exists()
assert path("$launchDir/results/input").exists()

// Ensure that despite pipeline failure, error_reports are generated for all samples added to pipeline (i.e. sampleQ query)
def lines = []

lines = path("$launchDir/results/input/sample2_error_report.csv").readLines()
assert lines.contains("sample2,sample7,Pipeline stopped: Reference sample2's input ID and MLST JSON file key DO NOT MATCH")
}
}

test("Integration test where input contains a single query sample with mismatched MLST JSON file"){
tag "pipeline_success_after_query_removal"

when{
params {
input = "$baseDir/tests/data/samplesheets/samplesheet_test2.csv"
outdir = "results"
}
}

then {
assert workflow.success
assert path("$launchDir/results").exists()
assert path("$launchDir/results/input").exists()
assert path("$launchDir/results/filter").exists()

// Check outputs
def lines = []

// Ensure that the error_report is generated for removed query sampleR
lines = path("$launchDir/results/input/sampleR_error_report.csv").readLines()
assert lines.contains("sampleR,sampleF,Query sampleR removed from pipeline")

// Check query output csv
lines = path("$launchDir/results/filter/new_addresses.csv").readLines()
assert lines.contains("sampleQ,1.1.3")

// Check IRIDA Next JSON output
assert path("$launchDir/results/iridanext.output.json").json == path("$baseDir/tests/data/irida/test2_iridanext.output.json").json

def iridanext_json = path("$launchDir/results/iridanext.output.json").json
def iridanext_samples = iridanext_json.files.samples
def iridanext_metadata = iridanext_json.metadata.samples

assert iridanext_samples.sampleR.findAll { it.path == "input/sampleR_error_report.csv" }.size() == 1
assert iridanext_metadata.sampleQ."address" == "1.1.3"
}
}

}
Loading