Skip to content

Commit

Permalink
Merge pull request nf-core#1252 from maxulysse/getGenomeAttribute
Browse files Browse the repository at this point in the history
Fix genomeAttribute usage
  • Loading branch information
maxulysse authored Apr 22, 2024
2 parents dcd5659 + 17767e1 commit b67141d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 113 deletions.
60 changes: 39 additions & 21 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,37 @@

nextflow.enable.dsl = 2

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT FUNCTIONS / MODULES / SUBWORKFLOWS / WORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

include { RNASEQ } from './workflows/rnaseq'
include { PREPARE_GENOME } from './subworkflows/local/prepare_genome'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'
include { getGenomeAttribute } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'
include { checkMaxContigSize } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GENOME PARAMETER VALUES
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

params.fasta = getGenomeAttribute('fasta')
params.transcript_fasta = getGenomeAttribute('transcript_fasta')
params.additional_fasta = getGenomeAttribute('additional_fasta')
params.gtf = getGenomeAttribute('gtf')
params.gff = getGenomeAttribute('gff')
params.gene_bed = getGenomeAttribute('bed12')
params.bbsplit_index = getGenomeAttribute('bbsplit')
params.sortmerna_index = getGenomeAttribute('sortmerna')
params.star_index = getGenomeAttribute('star')
params.gene_bed = getGenomeAttribute('bed12')
params.fasta = getGenomeAttribute('fasta')
params.gff = getGenomeAttribute('gff')
params.gtf = getGenomeAttribute('gtf')
params.hisat2_index = getGenomeAttribute('hisat2')
params.kallisto_index = getGenomeAttribute('kallisto')
params.rsem_index = getGenomeAttribute('rsem')
params.salmon_index = getGenomeAttribute('salmon')
params.kallisto_index = getGenomeAttribute('kallisto')
params.sortmerna_index = getGenomeAttribute('sortmerna')
params.star_index = getGenomeAttribute('star')
params.transcript_fasta = getGenomeAttribute('transcript_fasta')

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IMPORT FUNCTIONS / MODULES / SUBWORKFLOWS / WORKFLOWS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

include { RNASEQ } from './workflows/rnaseq'
include { PREPARE_GENOME } from './subworkflows/local/prepare_genome'
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'
include { checkMaxContigSize } from './subworkflows/local/utils_nfcore_rnaseq_pipeline'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -172,6 +171,25 @@ workflow {
)
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
FUNCTIONS
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

//
// Get attribute from genome config file e.g. fasta
//

def getGenomeAttribute(attribute) {
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
if (params.genomes[ params.genome ].containsKey(attribute)) {
return params.genomes[ params.genome ][ attribute ]
}
}
return null
}

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
THE END
Expand Down
4 changes: 2 additions & 2 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ params {
featurecounts_group_type = 'gene_biotype'
gencode = false
save_reference = false
igenomes_base = 's3://ngi-igenomes/igenomes'
igenomes_base = 's3://ngi-igenomes/igenomes/'
igenomes_ignore = false

// UMI handling
Expand Down Expand Up @@ -129,7 +129,7 @@ params {
// Schema validation default options
validationFailUnrecognisedParams = false
validationLenientMode = false
validationSchemaIgnoreParams = 'genomes,igenomes_base,additional_fasta,bbsplit_index,fasta,gene_bed,gff,gtf,hisat2_index,kallisto_index,rsem_index,salmon_index,star_index,transcript_fasta'
validationSchemaIgnoreParams = 'genomes,igenomes_base'
validationShowHiddenParams = false
validate_params = true

Expand Down
2 changes: 1 addition & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
"type": "string",
"format": "directory-path",
"description": "Directory / URL base for iGenomes references.",
"default": "s3://ngi-igenomes/igenomes",
"default": "s3://ngi-igenomes/igenomes/",
"fa_icon": "fas fa-cloud-download-alt",
"hidden": true
},
Expand Down
12 changes: 0 additions & 12 deletions subworkflows/local/utils_nfcore_rnaseq_pipeline/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -257,18 +257,6 @@ def validateInputParameters() {
}
}

//
// Get attribute from genome config file e.g. fasta
//
def getGenomeAttribute(attribute) {
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
if (params.genomes[ params.genome ].containsKey(attribute)) {
return params.genomes[ params.genome ][ attribute ]
}
}
return null
}

//
// Exit pipeline if incorrect --genome key provided
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,64 +132,6 @@ nextflow_function {

}

test("Test Function getGenomeAttribute finds attribute") {

function "getGenomeAttribute"

when {
params {
genome = "myTest"
genomes {
"myTest" {
myAttribute = "myValue"
}
}
}
function {
"""
input[0] = "myAttribute"
"""
}
}

then {
assertAll(
{ assert function.success },
{ assert snapshot(function.result).match() }
)
}

}

test("Test Function getGenomeAttribute missing attribute") {

function "getGenomeAttribute"

when {
params {
genome = "myTest"
genomes {
"myTest" {
myAttribute = "myValue"
}
}
}
function {
"""
input[0] = "missingAttribute"
"""
}
}

then {
assertAll(
{ assert function.success },
{ assert snapshot(function.result).match() }
)
}

}

test("Test Function genomeExistsError finds genome") {

function "genomeExistsError"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@
},
"timestamp": "2024-03-06T14:33:26.903306"
},
"Test Function getGenomeAttribute missing attribute": {
"content": null,
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-06T14:32:55.635006"
},
"Test Function getSalmonInferredStrandedness unstranded": {
"content": [
"unstranded"
Expand Down Expand Up @@ -123,16 +115,6 @@
},
"timestamp": "2024-03-06T14:33:40.548126"
},
"Test Function getGenomeAttribute finds attribute": {
"content": [
"myValue"
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-03-06T14:32:52.593188"
},
"Test Function multiqcTsvFromList": {
"content": [
"id\tattribute\ntest\nvalue"
Expand Down Expand Up @@ -256,4 +238,4 @@
},
"timestamp": "2024-03-06T14:34:10.929416"
}
}
}

0 comments on commit b67141d

Please sign in to comment.