Skip to content

Commit

Permalink
updated parameters for allele schema (#104)
Browse files Browse the repository at this point in the history
* updated parameters for allele schema

* updated changelog

* fixed error in parameter updates

* fixed misspelled param

* updated test config

* updated CLI argument

* dropped allele scheme used from the irida-next config

* updated tests to pass

* updated container default settings

* updated changelog and version
  • Loading branch information
mattheww95 authored Sep 4, 2024
1 parent 2976de7 commit 7093f01
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 76 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.4.0] - 2024-09-04

### `Changed`

Expand All @@ -16,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Updated TSeemann's MLST default container to use version 2.23.0 of `mlst`. See [PR 97](https://github.com/phac-nml/mikrokondo/pull/97)

- Moved allele schema parameters under one option in the nextflow_schema.json. See [PR 104](https://github.com/phac-nml/mikrokondo/pull/104)


### `Fixed`

Expand Down Expand Up @@ -142,6 +143,7 @@ Initial release of phac-nml/mikrokondo. Mikrokondo currently supports: read trim

- Added integration testing using [nf-test](https://www.nf-test.com/).

[0.4.0]: https://github.com/phac-nml/mikrokondo/releases/tag/0.4.0
[0.3.0]: https://github.com/phac-nml/mikrokondo/releases/tag/0.3.0
[0.2.1]: https://github.com/phac-nml/mikrokondo/releases/tag/0.2.1
[0.2.0]: https://github.com/phac-nml/mikrokondo/releases/tag/0.2.0
Expand Down
1 change: 0 additions & 1 deletion conf/irida_next.config
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ iridanext {
"IdentificationMethod",
"meta.downsampled",
"SpeciesTopHit",
"AlleleSchemeUsed",
"LocidexDatabaseInformation.db_name",
"LocidexDatabaseInformation.db_date",
"LocidexDatabaseInformation.db_version",
Expand Down
8 changes: 4 additions & 4 deletions modules/local/locidex_select.nf
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,21 @@ process LOCIDEX_SELECT {
def report_name = "${meta.id}_${params.locidex.db_config_output_name}"
output_config = task.workDir.resolve(report_name)

if(params.allele_scheme == null && params.locidex.allele_database == null){
if(params.override_allele_scheme == null && params.locidex.allele_database == null){
error("Allele calling is enabled but there is no allele scheme or locidex allele database location present.")
}

if(config){ // non null channel should evaluate to true
if(manifest){
log.warn "A database manifest file was passed along with a config file. Using the allele database specified by '--allele_scheme' "
log.warn "A database manifest file was passed along with a config file. Using the allele database specified by '--override_allele_scheme' "
}
// Create output summary data for a locidex allele database if an allele scheme is passed in directly
def jsonSlurper = new JsonSlurper()
String json_data = config.text
def locidex_config_data = jsonSlurper.parseText(json_data)
validate_locidex_db(locidex_config_data, params.allele_scheme)
validate_locidex_db(locidex_config_data, params.override_allele_scheme)
write_config_data(locidex_config_data, output_config)
scheme = params.allele_scheme // reset the schem path to the passed allele scheme
scheme = params.override_allele_scheme // reset the schem path to the passed allele scheme
paired_p = true

}else{
Expand Down
94 changes: 50 additions & 44 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ params {
// SISTR parameters
sr_full_cgmlst = true // Use full set of cgMLST alleles which can include highly similar alleles

// Allele Scheme Options
override_allele_scheme = null // Supply an allele scheme that will be used for allele calling of all samples
lx_allele_database = null // A path to the locidex manifest.json file needed for allele calling.

// Locidex Options
lx_min_evalue = 0.0001
lx_min_dna_len = 1
Expand All @@ -127,10 +131,6 @@ params {
lx_report_prop = "locus_name"
lx_report_max_ambig = 0
lx_report_max_stop = 0
lx_allele_database = null

// Overide an allele calling scheme, this will be applied globally if auto selection is not opted for
allele_scheme = null


// Boilerplate options
Expand Down Expand Up @@ -1044,58 +1044,64 @@ profiles {
cleanup = false
}
docker {
docker.enabled = true
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
docker.enabled = true
conda.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
docker.runOptions = '-u $(id -u):$(id -g)'
}
arm {
docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64'
}
singularity {
singularity.enabled = true
singularity.autoMounts = true
docker.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
singularity.enabled = true
singularity.autoMounts = true
conda.enabled = false
docker.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
}
podman {
podman.enabled = true
docker.enabled = false
singularity.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
podman.enabled = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
}
shifter {
shifter.enabled = true
docker.enabled = false
singularity.enabled = false
podman.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
shifter.enabled = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
podman.enabled = false
charliecloud.enabled = false
apptainer.enabled = false
}
charliecloud {
charliecloud.enabled = true
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
apptainer.enabled = false
charliecloud.enabled = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
apptainer.enabled = false
}
apptainer {
apptainer.enabled = true
apptainer.autoMounts = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
apptainer.enabled = true
apptainer.autoMounts = true
conda.enabled = false
docker.enabled = false
singularity.enabled = false
podman.enabled = false
shifter.enabled = false
charliecloud.enabled = false
}
gitpod {
executor.name = 'local'
Expand Down Expand Up @@ -1188,7 +1194,7 @@ manifest {
description = """Mikrokondo"""
mainScript = 'main.nf'
nextflowVersion = '!>=23.04.0'
version = '0.3.0'
version = '0.4.0'
defaultBranch = 'main'
doi = ''
}
Expand Down
39 changes: 25 additions & 14 deletions nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,6 @@
"exists": true,
"format": "directory-path",
"hidden": true
},
"allele_scheme": {
"type": "string",
"pattern": "^\\S+$",
"exists": true,
"format": "directory-path",
"description": "An allele scheme to to use for Locidex"
}
},
"required": [
Expand All @@ -126,6 +119,28 @@
],
"description": "The location of databases used by mikrokondo"
},
"allele_schema_options": {
"title": "Allele Schema Options",
"type": "object",
"description": "Specify an allele calling schema.",
"default": "",
"properties": {
"lx_allele_database": {
"type": "string",
"description": "The path to a folder containing a collection of locidex databases to allow for automatic allele database selection. The folder should contain a 'manifest.json' file created by locidex. If you wish to force a certain allele scheme to be used you can specify an option for the `override_allele_scheme` argument which will perform allele calling with the specified scheme.",
"pattern": "^\\S+$",
"exists": true,
"format": "directory-path"
},
"override_allele_scheme": {
"type": "string",
"description": "Specify the path to an allele calling schema to be used. This schema will be used for allele calling of all samples.",
"exists": true,
"pattern": "^\\S+$",
"format": "directory-path"
}
}
},
"institutional_config_options": {
"title": "Institutional config options",
"type": "object",
Expand Down Expand Up @@ -664,13 +679,6 @@
"default": 0,
"description": "Maximum number of internal stop codons allowed in a sequence.",
"minimum": 0
},
"lx_allele_database": {
"type": "string",
"description": "Folder of locidex databases. The folder should contain a 'manifest.json' file created by locidex",
"pattern": "^\\S+$",
"exists": true,
"format": "directory-path"
}
}
},
Expand Down Expand Up @@ -743,6 +751,9 @@
{
"$ref": "#/definitions/databases_and_pre_computed_files"
},
{
"$ref": "#/definitions/allele_schema_options"
},
{
"$ref": "#/definitions/institutional_config_options"
},
Expand Down
6 changes: 3 additions & 3 deletions subworkflows/local/locidex.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ workflow LOCIDEX {
paired_species = top_hit.join(contigs)
paired_dbs = Channel.empty()

if(params.allele_scheme == null && params.locidex.allele_database == null && !params.skip_allele_calling){
if(params.override_allele_scheme == null && params.locidex.allele_database == null && !params.skip_allele_calling){
error("Allele calling is enabled, but no locidex database directory has been configured.")
}

def manifest_file = [] // Default empty values for entries
def config_file = []

if(params.allele_scheme != null){
if(params.override_allele_scheme != null){
// allele scheme over rides the the manifest file
def config_file_in = [params.allele_scheme, params.locidex.config_data_file].join(File.separator)
def config_file_in = [params.override_allele_scheme, params.locidex.config_data_file].join(File.separator)
config_file = file(config_file_in, checkIfExists: true)
}else{
def manifest_file_in = [params.locidex.allele_database, params.locidex.manifest_name].join(File.separator)
Expand Down
4 changes: 2 additions & 2 deletions tests/modules/local/locidex_select/locidex_select.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ nextflow_process {
params {
outdir = "locidex_select"
lx_allele_database = null
allele_scheme = null
override_allele_scheme = null
}

}
Expand Down Expand Up @@ -351,7 +351,7 @@ nextflow_process {

params {
outdir = "locidex_select"
allele_scheme = "${projectDir}/tests/data/databases/locidex_dbs/locidex_vc"
override_allele_scheme = "${projectDir}/tests/data/databases/locidex_dbs/locidex_vc"
lx_allele_database = "${projectDir}/tests/data/databases/locidex_dbs"
}

Expand Down
6 changes: 2 additions & 4 deletions tests/pipelines/main.from_assemblies.nf.test
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ nextflow_pipeline {
skip_subtyping = false
skip_allele_calling = false

allele_scheme = "$baseDir/tests/data/databases/locidex_dbs/locidex_salm"
override_allele_scheme = "$baseDir/tests/data/databases/locidex_dbs/locidex_salm"

max_memory = "2.GB"
max_cpus = 1
Expand Down Expand Up @@ -707,7 +707,6 @@ nextflow_pipeline {
assert iridanext_samples.st_120.findAll { it.path == "Assembly/Subtyping/Locidex/Report/st_120.locidex.report.profile.mlst.subtyping.json.gz" }.size() == 1
assert iridanext_samples.st_120.findAll { it.path == "Assembly/Subtyping/Locidex/Summary/st_120.locidex.summary.json" }.size() == 1

assert vibrio_metadata.AlleleSchemeUsed.contains("locidex_dbs/locidex_vc")
assert vibrio_metadata.locidex_db_name == "Vibrio cholerae"
assert vibrio_metadata.locidex_db_date == "2024-07-30"
assert vibrio_metadata.locidex_db_version == "1.0.0"
Expand Down Expand Up @@ -740,7 +739,7 @@ nextflow_pipeline {
mash_sketch = "https://github.com/phac-nml/mikrokondo/raw/dev/tests/data/databases/mash.msh"
dehosting_idx = "https://github.com/phac-nml/mikrokondo/raw/dev/tests/data/databases/campy.mmi"
kraken2_db = "$baseDir/tests/data/kraken2/test"
allele_scheme= "$baseDir/tests/data/databases/locidex_dbs/locidex_vc"
override_allele_scheme= "$baseDir/tests/data/databases/locidex_dbs/locidex_vc"
qt_min_contig_length = 1

skip_bakta = true
Expand Down Expand Up @@ -780,7 +779,6 @@ nextflow_pipeline {
assert iridanext_samples.st_120.findAll { it.path == "Assembly/Subtyping/Locidex/Report/st_120.locidex.report.profile.mlst.subtyping.json.gz" }.size() == 1
assert iridanext_samples.st_120.findAll { it.path == "Assembly/Subtyping/Locidex/Summary/st_120.locidex.summary.json" }.size() == 1

assert vibrio_metadata.AlleleSchemeUsed.contains("locidex_dbs/locidex_vc")
assert vibrio_metadata.locidex_db_name == "Vibrio cholerae_1"
assert vibrio_metadata.locidex_db_date == "2024-08-01"
assert vibrio_metadata.locidex_db_version == "1.0.0"
Expand Down
4 changes: 2 additions & 2 deletions workflows/PostAssembly.nf
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ workflow POST_ASSEMBLY {


if(!params.skip_allele_calling){
if (!params.skip_species_classification || params.allele_scheme){
if (!params.skip_species_classification || params.override_allele_scheme){
LOCIDEX(ch_filtered_contigs, top_hit)
ch_versions = ch_versions.mix(LOCIDEX.out.versions)
ch_reports = ch_reports.mix(LOCIDEX.out.reports)
}else{
log.info "Skipping locidex since there is no '--allele_scheme' set and '--skip_species_classification' is enabled"
log.info "Skipping locidex since there is no '--override_allele_scheme' set and '--skip_species_classification' is enabled"
}
}

Expand Down

0 comments on commit 7093f01

Please sign in to comment.