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

Add auto detection of chr prefix and auto fixing #20

Merged
merged 18 commits into from
Mar 29, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Initial release of nf-core/phaseimpute, created with the [nf-core](https://nf-co
- correct meta map propagation
- Test impute and test sim works
- [#19](https://github.com/nf-core/phaseimpute/pull/19) - Changed reference panel to accept a csv, update modules and subworkflows (glimpse1/2 and shapeit5)
- [#20](https://github.com/nf-core/phaseimpute/pull/20) - Added automatic detection of vcf contigs for the reference panel and automatic renaming available

### `Fixed`

Expand Down
4 changes: 2 additions & 2 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ process {
ext.prefix = { "${meta.id}_${meta.region}" }
}

withName: BCFTOOLS_ANNOTATE {
withName: 'NFCORE_PHASEIMPUTE:PHASEIMPUTE:VCF_CHR_CHECK:VCF_CHR_RENAME:BCFTOOLS_ANNOTATE' {
ext.args = [
"-Oz",
"--no-version"
].join(' ')
ext.prefix = { "${meta.id}_chrDel_${meta.region}" }
ext.prefix = { "${meta.id}_chrrename" }
}

withName: VIEW_VCF_SNPS {
Expand Down
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

- [] 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
5 changes: 5 additions & 0 deletions modules.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
"git_sha": "de45447d060b8c8b98575bc637a4a575fd0638e1",
"installed_by": ["modules"]
},
"gawk": {
"branch": "master",
"git_sha": "dc3527855e7358c6d8400828754c0caa5f11698f",
"installed_by": ["modules"]
},
"glimpse/chunk": {
"branch": "master",
"git_sha": "7e56daae390ff896b292ddc70823447683a79936",
Expand Down
49 changes: 0 additions & 49 deletions modules/local/faitochr/main.nf

This file was deleted.

57 changes: 0 additions & 57 deletions modules/local/faitochr/tests/main.nf.test

This file was deleted.

68 changes: 0 additions & 68 deletions modules/local/faitochr/tests/main.nf.test.snap

This file was deleted.

2 changes: 0 additions & 2 deletions modules/local/faitochr/tests/tags.yml

This file was deleted.

7 changes: 7 additions & 0 deletions modules/local/vcfchrextract/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: vcfchrextract
channels:
- conda-forge
- bioconda
- defaults
dependencies:
- bioconda::bcftools=1.18
49 changes: 49 additions & 0 deletions modules/local/vcfchrextract/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
process VCFCHREXTRACT {
tag "$meta.id"
label 'process_single'

conda "${moduleDir}/environment.yml"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/bcftools:1.18--h8b25389_0':
'biocontainers/bcftools:1.18--h8b25389_0' }"

input:
tuple val(meta), path(input)

output:
tuple val(meta), path("*.txt"), emit: chr
path "versions.yml" , emit: versions

when:
task.ext.when == null || task.ext.when

script:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
bcftools \\
head \\
$input \\
\| grep -o -E '^##contig=<ID=([^,>]*)' | cut -d'=' -f3 \\
> ${prefix}.txt


cat <<-END_VERSIONS > versions.yml
"${task.process}":
bcftools: \$( bcftools --version |& sed '1!d; s/^.*bcftools //' )
grep: \$( grep --help |& grep -o -E '[0-9]+\\.[0-9]+\\.[0-9]+' )
END_VERSIONS
"""

stub:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.txt

cat <<-END_VERSIONS > versions.yml
"${task.process}":
bcftools: \$( bcftools --version |& sed '1!d; s/^.*bcftools //' )
grep: \$( grep --help |& grep -o -E '[0-9]+\\.[0-9]+\\.[0-9]+' )
END_VERSIONS
"""
}
41 changes: 41 additions & 0 deletions modules/local/vcfchrextract/meta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: vcfchrextract
description: Extract all contigs name into txt file
keywords:
- bcftools
- vcf
- head
- contig
tools:
- head:
description: Extract header from variant calling file.
homepage: http://samtools.github.io/bcftools/bcftools.html
documentation: https://samtools.github.io/bcftools/bcftools.html#head
doi: 10.1093/bioinformatics/btp352
licence: ["MIT"]
input:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- input:
type: file
description: Query VCF or BCF file, can be either uncompressed or compressed
output:
- meta:
type: map
description: |
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
- versions:
type: file
description: File containing software versions
pattern: "versions.yml"
- chr:
type: file
description: List of contigs in the VCF file
pattern: "*{txt}"
authors:
- "@louislenezet"
maintainers:
- "@louislenezet"
32 changes: 32 additions & 0 deletions modules/local/vcfchrextract/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
nextflow_process {

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

tag "modules"
tag "modules_local"
tag "vcfchrextract"

test("Extract chr from vcf") {

when {
process {
"""
input[0] = [
[ id:'test' ], // meta map
file(params.test_data['sarscov2']['illumina']['test_vcf_gz'], checkIfExists: true)
]
"""
}
}

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

}
}
35 changes: 35 additions & 0 deletions modules/local/vcfchrextract/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"Extract chr from vcf": {
"content": [
{
"0": [
[
{
"id": "test"
},
"test.txt:md5,3a9ea6d336e113a74d7fdca5e7b623fc"
]
],
"1": [
"versions.yml:md5,7e6d75a47df5ce3a975172dcd47fd247"
],
"chr": [
[
{
"id": "test"
},
"test.txt:md5,3a9ea6d336e113a74d7fdca5e7b623fc"
]
],
"versions": [
"versions.yml:md5,7e6d75a47df5ce3a975172dcd47fd247"
]
}
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-22T15:09:21.585363234"
}
}
2 changes: 2 additions & 0 deletions modules/local/vcfchrextract/tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vcfchrextract:
- "modules/local/vcfchrextract/**"
Loading
Loading