From 9483c8b5085ad690009e3d90cef8e4000ef0a62e Mon Sep 17 00:00:00 2001 From: Abhinav Sharma Date: Tue, 28 Jul 2020 10:07:57 +0530 Subject: [PATCH] sync with develop (#7) * general formatting * add the usage doc, update the code * add stub for the snippy core --- LICENSE | 2 +- README.md | 64 +++++++++++++++++++++++++++++++++++++++- main.nf | 87 ++++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 127 insertions(+), 26 deletions(-) diff --git a/LICENSE b/LICENSE index c9e63b4..2d1d3f0 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2020 BioDragao-Org +Copyright (c) 2020 Abhinav Sharma (@abhi18av) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 20c7881..fc78b9f 100644 --- a/README.md +++ b/README.md @@ -1 +1,63 @@ -# nf_process +# Nextflow wrapper for `snippy` process. + +## Pre-requisites + +- Nextflow +- Docker + +**NOTE** If you plan to setup a basic server, then you can refer [minimal-nextflow-setup](https://github.com/nextflow-hub/minimal-nextflow-setup) + +## Usage + +``` +nextflow run https://github.com/nextflow-hub/snippy +``` + +## Options + +- `refGbk` + +By default, the process assumes the reference file to be `NC000962_3.gbk` which could be customized using this option + +``` +nextflow run https://github.com/nextflow-hub/snippy --refGbk NCxxxxxx.gbk +``` + +- `filePattern` + +By default, the process assumes the files to follow the `*_{R1,R2}.fastq.gz` pattern, which could be customized using this option + +``` +nextflow run https://github.com/nextflow-hub/snippy --filePattern './*_{1,2}.fastq.gz' +``` + +- `resultsDir` + +By default, it stores the result files locally inside the `results` directory. + +``` +nextflow run https://github.com/nextflow-hub/snippy --resultsDir /path/to/custom/resultsDir +``` + +- `saveMode` + +By default, the pipeline publishes the results in the `resultsDir` by copying the relevant output. + +You can update this behavior by simply specifying the alternative such as `move` or `link` etc. + +``` +nextflow run https://github.com/nextflow-hub/snippy --saveMode move +``` + +For more information please refer [Nextflow documentation](https://www.nextflow.io/docs/latest/process.html#publishdir) + +## Customizing the script + +The sole purpose of process wrappers in `nextflow-hub` is to keep the code small, clean and hackable with some basic knowledge of `nextflow` scripting. + +If you have specific requirements, you are encouraged to fork/clone and update your version to accomodate your needs. + + +## Contribution + +Contribution, in all forms, is most welcome! diff --git a/main.nf b/main.nf index 5b0007f..7768830 100644 --- a/main.nf +++ b/main.nf @@ -1,40 +1,46 @@ #!/usr/bin/env nextflow + /* -################ +#============================================== +code documentation +#============================================== +*/ + +/* +#============================================== params -################ +#============================================== */ -params.trimmed= true -params.saveBy= 'copy' -params.ram= 7 -params.cpus= 4 +params.resultsDir = 'results/snippy' +params.filePattern = "./*_{R1,R2}.fastq.gz" +params.saveMode = 'copy' +params.ram = 4 +params.cpus = 4 +params.snippyCore = false -params.refGbk = "NC000962_3.gbk" -inputUntrimmedRawFilePattern = "./*_{R1,R2}.fastq.gz" -inputTrimmedRawFilePattern = "./*_{R1,R2}.p.fastq.gz" - -inputRawFilePattern = params.trimmed ? inputTrimmedRawFilePattern : inputUntrimmedRawFilePattern +params.refGbk = "NC000962_3.gbk" -Channel.fromFilePairs(inputRawFilePattern) +Channel.fromFilePairs(params.filePattern) .set { ch_in_snippy } Channel.value("$workflow.launchDir/NC000962_3.gbk") - .set {ch_refGbk} + .set { ch_refGbk } /* -############### -snippy_command -############### +#============================================== +snippy +#============================================== */ process snippy { - container 'ummidock/snippy_tseemann:4.6.0-02' - publishDir 'results/snippy', mode: params.saveBy + container 'quay.io/biocontainers/snippy:4.6.0--0' + publishDir params.resultsDir, mode: params.saveMode stageInMode 'symlink' - errorStrategy 'ignore' + errorStrategy 'retry' + maxRetries 3 input: @@ -44,15 +50,48 @@ process snippy { output: path("""${genomeName}""") into ch_out_snippy + when: + !params.snippyCore + script: - genomeName= genomeFileName.toString().split("\\_")[0] + genomeName = genomeFileName.toString().split("\\_")[0] """ - snippy --cpus ${params.cpus} --ram ${params.ram} --outdir $genomeName --ref $refGbk --R1 ${genomeReads[0]} --R2 ${genomeReads[1]} """ - + } -// alternative container -// container 'quay.io/biocontainers/snippy:4.6.0--0' +// TODO implement the snippy-core process +process snippyCore { + container 'ummidock/snippy_tseemann:4.6.0-02' + publishDir params.resultsDir, mode: params.saveBy + + when: + params.snippyCore + + input: + path refGbk from ch_refGbk + set genomeFileName, file(genomeReads) from ch_in_snippy + + output: + path("""${genomeName}""") into ch_out_snippy + + script: + + """ + snippy-core + """ + +} + + +/* +#============================================== +# extra +#============================================== +*/ + + +// alternative container +//container 'ummidock/snippy_tseemann:4.6.0-02'