Skip to content

Commit

Permalink
fix annotation
Browse files Browse the repository at this point in the history
  • Loading branch information
maxulysse committed Jan 28, 2025
1 parent e0e6289 commit ac66238
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 131 deletions.
43 changes: 4 additions & 39 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfc
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_sarek_pipeline'
include { PREPARE_INTERVALS } from './subworkflows/local/prepare_intervals'
include { PREPARE_REFERENCE_CNVKIT } from './subworkflows/local/prepare_reference_cnvkit'
include { extract_references_file } from './subworkflows/local/yaml_references'
include { extract_references_value } from './subworkflows/local/yaml_references'
include { extract_references_vcf } from './subworkflows/local/yaml_references'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
RUN MAIN WORKFLOW
Expand Down Expand Up @@ -277,42 +281,3 @@ workflow NFCORE_SAREK {
emit:
multiqc_report = SAREK.out.multiqc_report // channel: /path/to/multiqc_report.html
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS TO EXTRACT REFERENCES FILES OR VALUES FROM THE REFERENCES YAML OR PARAMS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

def extract_references_file(references, param, attribute) {
references.map { meta, _readme ->
if (param || meta[attribute]) {
return [meta.subMap(['id']), file(param ?: meta[attribute] ?: [])]
}
else {
return null
}
}
}

def extract_references_vcf(references, param, vcf_attribute, attribute) {
references.map { meta, _readme ->
if (param || meta.vcf[vcf_attribute][attribute]) {
return [meta.subMap(['id']), file(param ?: meta.vcf[vcf_attribute][attribute] ?: [])]
}
else {
return null
}
}
}

def extract_references_value(references, param, attribute) {
references.map { meta, _readme ->
if (param || meta[attribute]) {
return [meta.subMap(['id']), param ?: meta[attribute] ?: []]
}
else {
return null
}
}
}
2 changes: 1 addition & 1 deletion subworkflows/local/vcf_annotate_all/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ workflow VCF_ANNOTATE_ALL {


if (tools.split(',').contains('merge') || tools.split(',').contains('snpeff')) {
VCF_ANNOTATE_SNPEFF(vcf, snpeff_db, snpeff_cache)
VCF_ANNOTATE_SNPEFF(vcf, snpeff_db.map { _meta, snpeff_db_ -> snpeff_db_ }, snpeff_cache)

reports = reports.mix(VCF_ANNOTATE_SNPEFF.out.reports.map { _meta, reports_ -> [reports_] })
vcf_ann = vcf_ann.mix(VCF_ANNOTATE_SNPEFF.out.vcf_tbi)
Expand Down
38 changes: 38 additions & 0 deletions subworkflows/local/yaml_references/main.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS TO EXTRACT REFERENCES FILES OR VALUES FROM THE REFERENCES YAML OR PARAMS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

def extract_references_file(references, param, attribute) {
references.map { meta, _readme ->
if (param || meta[attribute]) {
return [meta.subMap(['id']), file(param ?: meta[attribute] ?: [])]
}
else {
return null
}
}
}

def extract_references_vcf(references, param, vcf_attribute, attribute) {
references.map { meta, _readme ->
if (param || meta.vcf[vcf_attribute][attribute]) {
return [meta.subMap(['id']), file(param ?: meta.vcf[vcf_attribute][attribute] ?: [])]
}
else {
return null
}
}
}

def extract_references_value(references, param, attribute) {
references.map { meta, _readme ->
if (param || meta[attribute]) {
return [meta.subMap(['id']), param ?: meta[attribute] ?: []]
}
else {
return null
}
}
}
2 changes: 1 addition & 1 deletion tests/annotation_bcfann.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@
},
"timestamp": "2024-10-29T09:38:54.991004"
}
}
}
4 changes: 0 additions & 4 deletions tests/annotation_merge.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ nextflow_pipeline {
outdir = "$outputDir"
input = "${projectDir}/tests/csv/3.0/vcf_single.csv"
step = 'annotate'
snpeff_cache = 's3://annotation-cache/snpeff_cache/'
vep_cache = 's3://annotation-cache/vep_cache/'
tools = 'merge'
}
}
Expand Down Expand Up @@ -48,8 +46,6 @@ nextflow_pipeline {
outdir = "$outputDir"
input = "${projectDir}/tests/csv/3.0/vcf_single.csv"
step = 'annotate'
snpeff_cache = 's3://annotation-cache/snpeff_cache/'
vep_cache = 's3://annotation-cache/vep_cache/'
tools = 'merge,snpeff,vep'
}
}
Expand Down
8 changes: 4 additions & 4 deletions tests/annotation_merge.nf.test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@
]
],
"meta": {
"nf-test": "0.9.1",
"nextflow": "24.10.0"
"nf-test": "0.9.2",
"nextflow": "24.10.4"
},
"timestamp": "2024-10-29T09:56:59.385257"
"timestamp": "2025-01-28T17:58:56.512301159"
}
}
}
39 changes: 1 addition & 38 deletions tests/annotation_snpeff.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,14 @@ nextflow_pipeline {
tag "pipeline"
tag "pipeline_sarek"

test("Run with profile test | --tools snpeff --download_cache") {

when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
outdir = "$outputDir"
input = "${projectDir}/tests/csv/3.0/vcf_single.csv"
step = 'annotate'
download_cache = true
tools = 'snpeff'
}
}

then {
// stable_name: All files + folders in ${params.outdir}/ with a stable name
def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// stable_path: All files in ${params.outdir}/ with stable content
def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore')
assertAll(
{ assert workflow.success},
{ assert snapshot(
// Number of successful tasks
workflow.trace.succeeded().size(),
// pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions
removeNextflowVersion("$outputDir/pipeline_info/nf_core_sarek_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}

test("Fails with profile test | --tools snpeff --snpeff_db na --build_only_index") {
test("Fails with profile test | --tools snpeff --snpeff_db na") {
when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
outdir = "$outputDir"
input = "${projectDir}/tests/csv/3.0/vcf_single.csv"
step = 'annotate'
snpeff_cache = 's3://annotation-cache/snpeff_cache/'
snpeff_db = "na"
input = false
build_only_index = true
tools = 'snpeff'
}
}
Expand Down
38 changes: 1 addition & 37 deletions tests/annotation_vep.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,41 +5,7 @@ nextflow_pipeline {
tag "pipeline"
tag "pipeline_sarek"

test("Run with profile test | --tools vep --download_cache --vep_include_fasta") {

when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
outdir = "$outputDir"
input = "${projectDir}/tests/csv/3.0/vcf_single.csv"
step = 'annotate'
download_cache = true
tools = 'vep'
}
}

then {
// stable_name: All files + folders in ${params.outdir}/ with a stable name
def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}'])
// stable_path: All files in ${params.outdir}/ with stable content
def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore')
assertAll(
{ assert workflow.success},
{ assert snapshot(
// Number of successful tasks
workflow.trace.succeeded().size(),
// pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions
removeNextflowVersion("$outputDir/pipeline_info/nf_core_sarek_software_mqc_versions.yml"),
// All stable path name, with a relative path
stable_name,
// All files with stable contents
stable_path
).match() }
)
}
}

test("Fails with profile test | --tools vep --vep_cache_version 1 --build_only_index") {
test("Fails with profile test | --tools vep --vep_cache_version 1") {
when {
params {
modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/'
Expand All @@ -48,8 +14,6 @@ nextflow_pipeline {
step = 'annotate'
vep_cache = 's3://annotation-cache/vep_cache/'
vep_cache_version = 1
input = false
build_only_index = true
tools = 'vep'
}
}
Expand Down
7 changes: 0 additions & 7 deletions workflows/sarek/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -861,13 +861,6 @@ workflow SAREK {

vep_fasta = params.vep_include_fasta ? fasta : [[id: 'null'], []]

println("vep_fasta: ${vep_fasta}")
vep_genome.view()
vep_species.view()
vep_cache_version.view()
vep_cache.view()
println("vep_extra_files: ${vep_extra_files}")

VCF_ANNOTATE_ALL(
vcf_to_annotate.map { meta, vcf -> [meta + [file_name: vcf.baseName], vcf] },
vep_fasta,
Expand Down

0 comments on commit ac66238

Please sign in to comment.