Skip to content

Commit

Permalink
Sort inputs when creating PED-files, so the output it always the same (
Browse files Browse the repository at this point in the history
  • Loading branch information
fellen31 authored Sep 12, 2024
1 parent 47d48a5 commit a8874db
Show file tree
Hide file tree
Showing 11 changed files with 222 additions and 71 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#352](https://github.com/genomic-medicine-sweden/nallo/pull/352) - Added (hidden) `params.extra_<tool>_options` for the test profile to modkit, vep, paraphase and hifiasm
- [#356](https://github.com/genomic-medicine-sweden/nallo/pull/356) - Added missing SNV and PED file to output documentation
- [#363](https://github.com/genomic-medicine-sweden/nallo/pull/363) - Added Zenodo link
- [#366](https://github.com/genomic-medicine-sweden/nallo/pull/366) - Added sorting of samples when creating PED files, so the output is always the same

### `Changed`

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ process CREATE_PEDIGREE_FILE {
'biocontainers/python:3.8.3' }"

input:
tuple val(project), val(samples)
tuple val(project), val(meta)

output:
tuple val(project), path("*.ped"), emit: ped
Expand All @@ -19,6 +19,9 @@ process CREATE_PEDIGREE_FILE {

script:
def out = new File(project + ".ped")
def samples = (meta.collect().size() > 1) ? meta.sort{ a, b ->
// First sort on family_id, then on sample id
a.family_id <=> b.family_id ?: a.id <=> b.id } : meta
outfile_text = ['#family_id', 'sample_id', 'father', 'mother', 'sex', 'phenotype'].join('\\t')
def samples_list = []
for(int i = 0; i<samples.size(); i++) {
Expand Down
67 changes: 67 additions & 0 deletions modules/local/create_pedigree_file/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
nextflow_process {

name "Test Process CREATE_PEDIGREE_FILE"
script "../main.nf"
process "CREATE_PEDIGREE_FILE"

tag "modules"
tag "modules_local"
tag "create_pedigree_file"

test("create_pedigree_file - one sample") {

when {
process {
"""
input[0] = Channel.of(
[ 'project',
[
[id:'HG002.Revio', family_id:'family', paternal_id:0, maternal_id:0, sex:0, phenotype:2, project:'project', n_files:1, single_end:true]
]
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.ped.get(0).get(1)).readLines(),
process.out.versions
).match() }
)
}
}

test("create_pedigree_file - multiple samples") {

when {
process {
"""
input[0] = Channel.of(
[ 'test',
[
[id:'HG002_Revio_AB', family_id:'FAM2', paternal_id:0, maternal_id:0, sex:0, phenotype:1, project:'test', n_files:1, single_end:true],
[id:'HG002_Revio_AA', family_id:'FAM2', paternal_id:0, maternal_id:0, sex:0, phenotype:1, project:'test', n_files:1, single_end:true],
[id:'HG002_Revio_B', family_id:'FAM1', paternal_id:0, maternal_id:0, sex:0, phenotype:1, project:'test', n_files:2, single_end:true],
[id:'HG002_Revio_A', family_id:'FAM1', paternal_id:0, maternal_id:0, sex:0, phenotype:2, project:'test', n_files:1, single_end:true],
[id:'HG002_Revio_B', family_id:'FAM1', paternal_id:0, maternal_id:0, sex:0, phenotype:1, project:'test', n_files:2, single_end:true]
]
])
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(
path(process.out.ped.get(0).get(1)).readLines(),
process.out.versions
).match() }
)
}
}

}
37 changes: 37 additions & 0 deletions modules/local/create_pedigree_file/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"create_pedigree_file - one sample": {
"content": [
[
"#family_id\tsample_id\tfather\tmother\tsex\tphenotype",
"family\tHG002.Revio\t0\t0\t0\t2"
],
[
"versions.yml:md5,c0d2b2d33f1c465351d65e149ae88f0c"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-12T10:24:34.60478278"
},
"create_pedigree_file - multiple samples": {
"content": [
[
"#family_id\tsample_id\tfather\tmother\tsex\tphenotype",
"FAM1\tHG002_Revio_A\t0\t0\t0\t2",
"FAM1\tHG002_Revio_B\t0\t0\t0\t1",
"FAM2\tHG002_Revio_AA\t0\t0\t0\t1",
"FAM2\tHG002_Revio_AB\t0\t0\t0\t1"
],
[
"versions.yml:md5,c0d2b2d33f1c465351d65e149ae88f0c"
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-12T10:40:54.71628575"
}
}
2 changes: 1 addition & 1 deletion nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ config {
}
testsDir "."
workDir ".nf-test"
configFile "conf/test.config"
configFile "tests/nextflow.config"
profile "docker"

}
2 changes: 1 addition & 1 deletion subworkflows/local/call_svs/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ nextflow_workflow {

name "Test Workflow CALL_SVS"
script "../main.nf"
workflow "CALL_SVS"
config "./nextflow.config"
workflow "CALL_SVS"

setup {
run("GUNZIP") {
Expand Down
22 changes: 11 additions & 11 deletions subworkflows/local/call_svs/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-06T11:29:28.671005178"
"timestamp": "2024-09-12T12:13:14.38085716"
},
"1 sample - [bam, bai], fasta, fai, [] -stub": {
"content": [
Expand Down Expand Up @@ -822,7 +822,7 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-05T19:07:34.521780648"
"timestamp": "2024-09-12T12:37:08.560198215"
},
"1 sample - [bam, bai], fasta, fai, bed -stub": {
"content": [
Expand Down Expand Up @@ -917,7 +917,7 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-05T19:07:45.413681853"
"timestamp": "2024-09-12T12:37:19.687620805"
},
"1 sample - [bam, bai], fasta, fai, bed": {
"content": [
Expand Down Expand Up @@ -1158,7 +1158,7 @@
"##INFO=<ID=PHASE,Number=.,Type=String,Description=\"Phasing information derived from supporting reads, represented as list of: HAPLOTYPE,PHASESET,HAPLOTYPE_SUPPORT,PHASESET_SUPPORT,HAPLOTYPE_FILTER,PHASESET_FILTER\">",
"##bcftools_viewVersion=1.20+htslib-1.20"
],
"13d352d7a4dd922085f653a3da950bce",
"5924013e8c1835d7bb0502ee85f2128d",
[
"##contig=<ID=chr1,length=248956422>",
"##contig=<ID=chr2,length=242193529>",
Expand Down Expand Up @@ -1396,7 +1396,7 @@
"##INFO=<ID=PHASE,Number=.,Type=String,Description=\"Phasing information derived from supporting reads, represented as list of: HAPLOTYPE,PHASESET,HAPLOTYPE_SUPPORT,PHASESET_SUPPORT,HAPLOTYPE_FILTER,PHASESET_FILTER\">",
"##bcftools_viewVersion=1.20+htslib-1.20"
],
"28ed9eefcf5bb27fed8c55f615219f33",
"8df5ad12540b4e0982bb74d5b268795d",
[
"versions.yml:md5,2188f00d20a376929f9f35f824e94667",
"versions.yml:md5,572bfd042014333af194207291d12b95",
Expand All @@ -1408,7 +1408,7 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-05T14:17:59.191541065"
"timestamp": "2024-09-12T12:12:58.045416708"
},
"2 samples - [bam, bai], fasta, fai, [] -stub": {
"content": [
Expand Down Expand Up @@ -1461,7 +1461,7 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-06T11:30:02.189652169"
"timestamp": "2024-09-12T12:13:55.632583291"
},
"1 sample - [bam, bai], fasta, fai, []": {
"content": [
Expand Down Expand Up @@ -1702,7 +1702,7 @@
"##INFO=<ID=PHASE,Number=.,Type=String,Description=\"Phasing information derived from supporting reads, represented as list of: HAPLOTYPE,PHASESET,HAPLOTYPE_SUPPORT,PHASESET_SUPPORT,HAPLOTYPE_FILTER,PHASESET_FILTER\">",
"##bcftools_viewVersion=1.20+htslib-1.20"
],
"5cdf920b1f44a66de3a28ead8d3efb24",
"79676a9dd690e37560b5841b67dfa28",
[
"##contig=<ID=chr1,length=248956422>",
"##contig=<ID=chr2,length=242193529>",
Expand Down Expand Up @@ -1940,7 +1940,7 @@
"##INFO=<ID=PHASE,Number=.,Type=String,Description=\"Phasing information derived from supporting reads, represented as list of: HAPLOTYPE,PHASESET,HAPLOTYPE_SUPPORT,PHASESET_SUPPORT,HAPLOTYPE_FILTER,PHASESET_FILTER\">",
"##bcftools_viewVersion=1.20+htslib-1.20"
],
"fe2e9b5e8f54e993c262331759006346",
"bd51c062a29bbb8823a17b95f8162f44",
[
"versions.yml:md5,2188f00d20a376929f9f35f824e94667",
"versions.yml:md5,572bfd042014333af194207291d12b95",
Expand All @@ -1952,6 +1952,6 @@
"nf-test": "0.8.4",
"nextflow": "24.04.3"
},
"timestamp": "2024-09-05T14:17:46.151263963"
"timestamp": "2024-09-12T12:12:44.978644444"
}
}
}
1 change: 1 addition & 0 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ nextflow_pipeline {
script "../main.nf"
profile "test"
tag "PIPELINE"
config "../conf/test.config"

test("test profile") {
tag "samplesheet"
Expand Down
Loading

0 comments on commit a8874db

Please sign in to comment.