Skip to content

Commit

Permalink
Merge pull request #3 from phac-nml/dev
Browse files Browse the repository at this point in the history
updated docs
  • Loading branch information
mattheww95 authored Oct 16, 2023
2 parents e2e0be7 + b265e71 commit 539517c
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 3 deletions.
49 changes: 49 additions & 0 deletions docs/troubleshooting/FAQ.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# FAQ

## How is variable type determined from command line parameters?

This may be a weird thing to but in the docs, but if you are developing the pipeline or somehow finding that a parameter passed on the command line is not working properly. For example you want a sample to have at least 1000 reads before going for assembly (`--min_reads 1000`) and samples with only one read are being assembled this may the source of your issue.

The way a variable type is determined from the command line can be found in the following [groovy code](https://github.com/nextflow-io/nextflow/blob/8c0566fc3a35c8d3a4e01a508a0667e471bab297/modules/nextflow/src/main/groovy/nextflow/cli/CmdRun.groovy#L506-L518). The snippet is also pasted below and is up to date as of 2023-10-16:

```
static protected parseParamValue(String str ) {
if ( str == null ) return null
if ( str.toLowerCase() == 'true') return Boolean.TRUE
if ( str.toLowerCase() == 'false' ) return Boolean.FALSE
if ( str==~/\d+(\.\d+)?/ && str.isInteger() ) return str.toInteger()
if ( str==~/\d+(\.\d+)?/ && str.isLong() ) return str.toLong()
if ( str==~/\d+(\.\d+)?/ && str.isDouble() ) return str.toDouble()
return str
}
```

## Common errors and how to encounter them

### Troubleshooting

Common errors and potential fixes for modules will be detailed here.

### Common spades issues

- Spades exit code 21
- One potential cause of this issue (requires looking at the log files) is due to not enough reads being present. You can avoid samples with too few reads going to assembly by adjusting the `min_reads` parameter in the `nextflow.config`. It can also be adjusted from the command line like so `--min_reads 1000`

- Spades exit code 245
- This could be due to multiple issues and typically results from a segmentation fault (OS Code 11). Try increasing the amount of memory spades (`conf/base.config`) if the issue persists try using a different Spades container/ create an issue.

### Common Kraken2 issues

- Kraken2 exit code 2
- It is still a good idea to look at the output logs to verify your issue as they may say something like: `kraken2: database ("./kraken2_database") does not contain necessary file taxo.k2d` despite the taxo.k2d file being present. This is potentially caused by symlink issues, and one possible fix is too to provide the absolute path to your Kraken2 database in the `nextflow.config` or from the command line `--kraken.db /PATH/TO/DB`


### Common Docker issues

- Exit code 137:
- Exit code 137, likely means your docker container used to much memory. You can adjust how much memory each process gets in the `conf/base.config` file, however there may be some underlying configuration you need to perform for Docker to solve this issue.

3 changes: 3 additions & 0 deletions docs/usage/Utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
The command line interface for Nextflow can become lengthy and tedious to type each time, due to the customization associated with routine pipeline runs, the lack of short form variable flags in Nextflow e.g. typing `--nanopore_chemisty` each time can be tedious.

A run script skeleton has been provided in the `utils` folder of mikrokondo (`utils/mk_run.sh`). Please customize the script to make it fit your usage, if you have issues running your modified script make sure it is executable by adding running `chmod +x mk_run.sh`.

## Parameter file -params-file
You can also add a params file to the launch of Nextflow from the command line. More information is provided [here](https://www.nextflow.io/blog/2020/cli-docs-release.html)
7 changes: 5 additions & 2 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ params {

output_idx_name = null
// TODO need to add constants section
// TODO verify that command line params are being coerced to the right type
// TODO investigate usage of template scripts to replace mash modules
// TODO Need to make sure all params in nextflow.config are reported, can be accomplished in the NfcoreSchema.groovy file

Expand Down Expand Up @@ -93,8 +94,10 @@ params {
validate_params = true
show_hidden_params = false

// No idea why QCReport-fields needs to be present...
schema_ignore_params = 'flye_read_type,genomes,shigeifinder,lissero,sistr,ectyper,bandage,bakta,unicycler,medaka,pilon_iterative,pilon,racon,samtools,minimap2,r_contaminants,mash,kraken,checkm,quast_filter,quast,fastqc,spades,flye,chopper,fastp,seqtk,kat,coreutils,opt_platforms,QCReportFields,QCReport-fields,QCReport,kraken_bin,shigatyper,spatyper,kleborate,subtyping_report,kraken_species,top_hit_species,mash_meta,mlst,raw_reads,abricate_params,target_depth'

// If a param in camel case is present nextflow automatically creates a kebab case parameter as well
schema_ignore_params = 'genomes,flye_read_type,shigeifinder,lissero,sistr,ectyper,bandage,bakta,unicycler,medaka,pilon_iterative,pilon,racon,samtools,minimap2,r_contaminants,mash,kraken,checkm,quast_filter,quast,fastqc,spades,flye,chopper,fastp,seqtk,kat,coreutils,opt_platforms,QCReportFields,QCReport-fields,QCReport,kraken_bin,shigatyper,spatyper,kleborate,subtyping_report,kraken_species,top_hit_species,mash_meta,mlst,raw_reads,abricate_params,target_depth'

stage_in_mode = 'symlink'


Expand Down
22 changes: 21 additions & 1 deletion subworkflows/local/clean_reads.nf
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,28 @@ workflow QC_READS {


fastp_data = PARSE_FASTP(ch_meta_cleaned_reads.fastp_json)

/*
* Below snippet was an experiment, need to have a discussion if nextflow should continue to handle the conversion of parameters, as it can mis cast things.
// def min_reads = null
//try{
// min_reads = params.min_reads.toLong();
// if(min_reads < 0){
// log.warn "Integer overflow for parameter min_reads. The minimum value (${params.min_reads}) is too high. Setting parameter to default value of 1000"
// min_reads = 1000;
// }
//}catch(NumberFormatException ex){
// log.warn "A valid numberic type was not passed to params.min_reads (${params.min_reads}). Setting parameter to default value of 1000"
// min_reads = 1000; // TODO add to constants file
//}
// passed_read_count = fastp_data.read_count.filter{
// it[1] >= min_reads // Read counts are at position 1
// }
*/

passed_read_count = fastp_data.read_count.filter{
it[1] >= params.min_reads // Read count are at position 1
it[1] >= params.min_reads // Read counts are at position 1
}


Expand Down

0 comments on commit 539517c

Please sign in to comment.