-
Notifications
You must be signed in to change notification settings - Fork 688
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new module: jvarkit vcf2table (#6631)
* 1st * vcf2table * fix tests.snap * rm name * Apply suggestions from code review Co-authored-by: Simon Pearce <[email protected]> * test content * fix meta * update tools 3.0.0 * update env.yml --------- Co-authored-by: Simon Pearce <[email protected]>
- Loading branch information
Showing
7 changed files
with
261 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/environment-schema.json | ||
channels: | ||
- conda-forge | ||
- bioconda | ||
dependencies: | ||
- "bioconda:bcftools=1.20" | ||
- "bioconda::jvarkit=2024.08.25" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
process JVARKIT_VCF2TABLE { | ||
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/jvarkit:2024.08.25--hdfd78af_1': | ||
'biocontainers/jvarkit:2024.08.25--hdfd78af_1' }" | ||
|
||
input: | ||
tuple val(meta), path(vcf), path(tbi), path(regions_file) | ||
tuple val(meta2), path(pedigree) | ||
output: | ||
tuple val(meta), path("*.${extension}"), emit: output | ||
path "versions.yml" , emit: versions | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
def args1 = task.ext.args1 ?: '' | ||
def args2 = task.ext.args2 ?: '' | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
def ped = pedigree?"--pedigree \"${pedigree}\"":"" | ||
def regions_file = regions_file? (tbi ? " --regions-file" : " --targets-file")+" \"${regions_file}\" ":"" | ||
extension = getFileExtension(args2); /* custom function, see below */ | ||
|
||
if ("$vcf" == "${prefix}.${extension}") error "Input and output names are the same, set prefix in module configuration to disambiguate!" | ||
""" | ||
mkdir -p TMP | ||
bcftools view ${regions_file} -O v ${args1} "${vcf}" |\\ | ||
jvarkit -Xmx${task.memory.giga}g -XX:-UsePerfData -Djava.io.tmpdir=TMP vcf2table ${ped} ${args2} > "${prefix}.${extension}" | ||
rm -rf TMP | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') | ||
jvarkit: \$(jvarkit -v) | ||
END_VERSIONS | ||
""" | ||
|
||
stub: | ||
def args2 = task.ext.args2 ?: '' | ||
extension = getFileExtension(args2); /* custom function, see below */ | ||
def prefix = task.ext.prefix ?: "${meta.id}" | ||
""" | ||
touch "${prefix}.${extension}" | ||
cat <<-END_VERSIONS > versions.yml | ||
"${task.process}": | ||
bcftools: \$(bcftools --version 2>&1 | head -n1 | sed 's/^.*bcftools //; s/ .*\$//') | ||
jvarkit: \$(jvarkit -v) | ||
END_VERSIONS | ||
""" | ||
} | ||
|
||
|
||
// Custom Function to get VCF extension | ||
String getFileExtension(String args) { | ||
return args.contains("--format html") ? "html" : "txt" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
--- | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/nf-core/modules/master/modules/meta-schema.json | ||
name: "jvarkit_vcf2table" | ||
description: Convert VCF to a user friendly table | ||
keywords: | ||
- vcf | ||
- bcf | ||
- text | ||
- html | ||
- visualization | ||
tools: | ||
- "jvarkit": | ||
description: "Java utilities for Bioinformatics." | ||
homepage: "https://github.com/lindenb/jvarkit" | ||
documentation: "https://jvarkit.readthedocs.io/" | ||
tool_dev_url: "https://github.com/lindenb/jvarkit" | ||
doi: "10.6084/m9.figshare.1425030" | ||
licence: ["MIT"] | ||
args_id: "$args2" | ||
identifier: "" | ||
- "bcftools": | ||
description: | | ||
View, subset and filter VCF or BCF files by position and filtering expression. Convert between VCF and BCF | ||
homepage: "http://samtools.github.io/bcftools/bcftools.html" | ||
documentation: "http://www.htslib.org/doc/bcftools.html" | ||
doi: "10.1093/bioinformatics/btp352" | ||
licence: ["MIT"] | ||
args_id: "$args1" | ||
identifier: "biotools:samtools" | ||
input: | ||
- - "meta": | ||
type: map | ||
description: | | ||
Groovy Map containing VCF information | ||
e.g. [ id:'genome' ] | ||
- vcf: | ||
type: file | ||
description: Input vcf/bcf file | ||
pattern: "*.{vcf,bcf,vcf.gz,bcf.gz}" | ||
- tbi: | ||
type: file | ||
description: Optional index file for the VCF | ||
pattern: "*.{tbi,csi}" | ||
- regions_file: | ||
type: file | ||
description: Optional. Restrict to regions listed in a file | ||
pattern: "*.{bed,bed.gz,txt,tsv}" | ||
- - meta2: | ||
type: map | ||
description: | | ||
Groovy Map containing pedigree information | ||
- pedigree: | ||
type: file | ||
description: Optional pedigree for jvarkit | ||
pattern: "*.{ped,pedigree}" | ||
output: | ||
- output: | ||
- meta: | ||
type: map | ||
description: | | ||
Groovy Map containing VCF information | ||
e.g. [ id:'test', single_end:false ] | ||
- "*.${extension}": | ||
type: file | ||
description: Output file | ||
pattern: "*.{txt,html}" | ||
- versions: | ||
- "versions.yml": | ||
type: file | ||
description: File containing software versions | ||
pattern: "versions.yml" | ||
authors: | ||
- "@lindenb" | ||
maintainers: | ||
- "@lindenb" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
nextflow_process { | ||
|
||
name "Test Process JVARKIT_VCF2TABLE" | ||
script "../main.nf" | ||
process "JVARKIT_VCF2TABLE" | ||
config "./nextflow.config" | ||
|
||
tag "modules" | ||
tag "modules_nfcore" | ||
tag "jvarkit" | ||
tag "jvarkit/vcf2table" | ||
|
||
test("sarscov2 - vcf") { | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] =[ | ||
[id:"vcf_test"], | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf', checkIfExists: true), | ||
[], | ||
[] | ||
] | ||
input[1] = [ [] , [] ] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert path(process.out.output[0][1]).text.startsWith(">>MT192765.1:197/G (n. 1)")}, | ||
{ assert snapshot( | ||
path(process.out.output[0][1]), | ||
process.out.versions | ||
).match() | ||
} | ||
) | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
test("sarscov2 - vcf - stub") { | ||
|
||
options "-stub" | ||
|
||
when { | ||
process { | ||
""" | ||
input[0] =[ | ||
[id:"vcf_test"], | ||
file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/vcf/test.vcf', checkIfExists: true), | ||
[], | ||
[] | ||
] | ||
input[1] = [ [] , [] ] | ||
""" | ||
} | ||
} | ||
|
||
then { | ||
assertAll( | ||
{ assert process.success }, | ||
{ assert snapshot( | ||
path(process.out.output[0][1]), | ||
process.out.versions | ||
).match() | ||
} | ||
) | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"sarscov2 - vcf": { | ||
"content": [ | ||
"vcf_test.txt:md5,91513583ed7c0d0e63bb046c03419460", | ||
[ | ||
"versions.yml:md5,0c4f207f3c21b881974f056ea9f863c7" | ||
] | ||
], | ||
"meta": { | ||
"nf-test": "0.9.0", | ||
"nextflow": "24.04.4" | ||
}, | ||
"timestamp": "2024-09-03T14:00:13.118369362" | ||
}, | ||
|
||
"sarscov2 - vcf - stub": { | ||
"content": [ | ||
"vcf_test.txt:md5,d41d8cd98f00b204e9800998ecf8427e", | ||
[ | ||
"versions.yml:md5,0c4f207f3c21b881974f056ea9f863c7" | ||
] | ||
], | ||
"meta": { | ||
"nf-test": "0.9.0", | ||
"nextflow": "24.04.4" | ||
}, | ||
"timestamp": "2024-09-03T14:00:13.118369362" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
process { | ||
|
||
withName: JVARKIT_VCF2TABLE { | ||
ext.args2=" --hide NO_CALL " | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jvarkit/vcf2table: | ||
- "modules/nf-core/jvarkit/vcf2table/**" |