Skip to content

Commit

Permalink
Add more test to vcf_chr tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisLeNezet committed Mar 25, 2024
1 parent 823e91b commit 4a4e73d
Show file tree
Hide file tree
Showing 5 changed files with 173 additions and 15 deletions.
3 changes: 2 additions & 1 deletion docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

## Features and tasks

- [x] Add automatic detection of chromosome name to create a renaming file for the vcf
- [x] Add automatic detection of chromosome name to create a renaming file for the vcf files
- [] Add automatic detection of chromosome name to create a renaming file for the bam files
- [] Make the different tests workflows work
- [] Simulation
- [] Validation
Expand Down
4 changes: 2 additions & 2 deletions modules/local/faitochr/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ process FAITOCHR {
# Take the fai file and add/remove the chr prefix to the chromosome names
# Keep only first column, remove chr prefix if present, add chr prefix if needed
# chr prefix is added only on number only chromosome names
# chr prefix is added only on number only chromosome names or XYMT
awk -F'\t' '{print \$1}' ${fai} | \
sed 's/^chr//g' | \
awk -v col1=\${col1} -v col2=\${col2} \
'BEGIN {OFS=" "} {if (\$1 ~ /^[0-9]+\$/) print col1\$1, col2\$1; else print \$1, \$1}' \
'BEGIN {OFS=" "} {if (\$1 ~ /^[0-9]+|[XYMT]\$/) print col1\$1, col2\$1; else print \$1, \$1}' \
> ${prefix}.txt
# We should have a file with the chromosome names in the second column corresponding to the fai format
Expand Down
1 change: 0 additions & 1 deletion subworkflows/local/vcf_chr_check/tests/main.function.test

This file was deleted.

76 changes: 70 additions & 6 deletions subworkflows/local/vcf_chr_check/tests/main.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,39 @@ nextflow_workflow {
tag "bcftools/index"
tag "faitochr"

test("Should run without error") {
test("Rename: panel chr + fasta chr") {
config "./nextflow_rename.config"
when {
workflow {
"""
fai_file = Channel.of('chr22\t10000\t7\t60\t61', 'chr21\t10000\t7\t60\t61').collectFile(name: 'chr21_22.fai', newLine: true)
input[0] = Channel.fromList([
[
[id: "chr22"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz",checkIfExist:true),
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz.tbi",checkIfExist:true)
],
[
[id: "chr21"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz",checkIfExist:true),
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz.tbi",checkIfExist:true)
]
])
input[1] = Channel.of([[id:"GRCh37"],[]])
.combine(fai_file)
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
)
}
}

test("Rename: panel chr + fasta no chr") {
config "./nextflow_rename.config"
when {
workflow {
Expand Down Expand Up @@ -46,7 +78,41 @@ nextflow_workflow {
)
}
}
test("Should run with error due to missing renaming params") {

test("Rename: panel no chr + fasta chr") {
config "./nextflow_rename.config"
when {
workflow {
"""
fai_file = Channel.of(
'chr1\t10000\t7\t60\t61','chr2\t10000\t7\t60\t61','chr3\t10000\t7\t60\t61','chr4\t10000\t7\t60\t61','chr5\t10000\t7\t60\t61','chr6\t10000\t7\t60\t61',
'chr7\t10000\t7\t60\t61','chr8\t10000\t7\t60\t61','chr9\t10000\t7\t60\t61','chr10\t10000\t7\t60\t61','chr11\t10000\t7\t60\t61','chr12\t10000\t7\t60\t61',
'chr13\t10000\t7\t60\t61','chr14\t10000\t7\t60\t61','chr15\t10000\t7\t60\t61','chr16\t10000\t7\t60\t61','chr17\t10000\t7\t60\t61','chr18\t10000\t7\t60\t61',
'chr19\t10000\t7\t60\t61','chr20\t10000\t7\t60\t61','chr21\t10000\t7\t60\t61','chr22\t10000\t7\t60\t61',
'chrX\t10000\t7\t60\t61','chrY\t10000\t7\t60\t61', 'chrMT\t10000\t7\t60\t61'
).collectFile(name: 'chr.fai', newLine: true)
input[0] = Channel.fromList([
[
[id: "22"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/test_models.vcf.gz",checkIfExist:true),
[]
]
])
input[1] = Channel.of([[id:"GRCh37"],[]])
.combine(fai_file)
"""
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(workflow.out).match() }
)
}
}

test("Error : missing renaming params") {
config "./nextflow.config"
when {
workflow {
Expand All @@ -63,9 +129,7 @@ nextflow_workflow {
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz.tbi",checkIfExist:true)
]
])
input[1] = Channel.of([
[id:"GRCh37"],
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genome.fasta",checkIfExist:true),
input[1] = Channel.of([[id:"GRCh37"],[],
file("https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/genome.fasta.fai",checkIfExist:true)
])
"""
Expand All @@ -79,7 +143,7 @@ nextflow_workflow {
)
}
}
test("Should run with error after renaming"){
test("Error : still difference after renaming"){
config "./nextflow_rename.config"
when {
workflow {
Expand Down
104 changes: 99 additions & 5 deletions subworkflows/local/vcf_chr_check/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -1,5 +1,95 @@
{
"Should run without error": {
"Rename: panel chr + fasta chr": {
"content": [
{
"0": [
[
{
"id": "chr21"
},
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz",
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz.tbi"
],
[
{
"id": "chr22"
},
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz",
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz.tbi"
]
],
"1": [
"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1"
],
"vcf": [
[
{
"id": "chr21"
},
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz",
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/illumina/vcf/chr21/simulated_sv.vcf.gz.tbi"
],
[
{
"id": "chr22"
},
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz",
"/nf-core/test-datasets/modules/data/genomics/homo_sapiens/genome/vcf/dbsnp_146.hg38.vcf.gz.tbi"
]
],
"versions": [
"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-25T20:52:06.173493472"
},
"Rename: panel no chr + fasta chr": {
"content": [
{
"0": [
[
{
"id": "22"
},
"22_chrrename.vcf.gz:md5,070a96d1053a64f2de2132ee8800847c",
"22_chrrename.vcf.gz.csi:md5,e190b690b4b0a4d088231862e5408582"
]
],
"1": [
"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1",
"versions.yml:md5,e576f40503c3506c782228485d06fbf1"
],
"vcf": [
[
{
"id": "22"
},
"22_chrrename.vcf.gz:md5,070a96d1053a64f2de2132ee8800847c",
"22_chrrename.vcf.gz.csi:md5,e190b690b4b0a4d088231862e5408582"
]
],
"versions": [
"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1",
"versions.yml:md5,e576f40503c3506c782228485d06fbf1"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-25T20:50:17.522495093"
},
"Rename: panel chr + fasta no chr": {
"content": [
{
"0": [
Expand All @@ -19,7 +109,9 @@
]
],
"1": [

"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1",
"versions.yml:md5,e576f40503c3506c782228485d06fbf1"
],
"vcf": [
[
Expand All @@ -38,14 +130,16 @@
]
],
"versions": [

"versions.yml:md5,395e1cde3f38a30f5d80769972ba23d8",
"versions.yml:md5,472924b76f1737f4b6c7708ddd4f88b1",
"versions.yml:md5,e576f40503c3506c782228485d06fbf1"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-24T14:19:22.618820686"
"timestamp": "2024-03-25T20:50:05.571457009"
}
}
}

0 comments on commit 4a4e73d

Please sign in to comment.