Skip to content

Commit

Permalink
Add combining samples with samplesheet input
Browse files Browse the repository at this point in the history
  • Loading branch information
DarianHole committed Aug 13, 2024
1 parent e4ab97f commit f97f1d6
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 9 deletions.
12 changes: 6 additions & 6 deletions .github/test-data/nanopore/input.csv
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sample,reads
sample1,.github/test-data/nanopore/fastq_pass/barcode01
sample2,.github/test-data/nanopore/fastq_pass/barcode02
100_reads,.github/test-data/nanopore/fastq_pass/barcode03
25_reads,.github/test-data/nanopore/fastq_pass/barcode24
negative-ctrl,.github/test-data/nanopore/fastq_pass/barcode94
sample,fastq_1
sample1,.github/test-data/nanopore/fastq_pass/barcode01/barcode01.fastq.gz
sample2,.github/test-data/nanopore/fastq_pass/barcode02/barcode02.fastq.gz
100_reads,.github/test-data/nanopore/fastq_pass/barcode03/barcode03.fastq.gz
25_reads,.github/test-data/nanopore/fastq_pass/barcode24/barcode24.fastq.gz
negative-ctrl,.github/test-data/nanopore/fastq_pass/barcode94/barcode94.fastq.gz
4 changes: 3 additions & 1 deletion docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ Ex.
| sample | fastq_1 |
| - | - |
| sample1 | /path/to/sample.fastq |
| sample2 | /path/to/sample2-1.fastq |
| sample2 | /path/to/sample-2.fastq |
| ntc | /path/to/control.fastq |
| pos | /path/to/pos.fastq |

This will be expanded upon in future releases to allow more varied inputs for the input sheet.
A sample can be given multiple fastq files if it was resequenced or needed a top up run. If there are multiple fastq files for a sample they will be concatenated and gzipped. If not, the input fastq file will just be gzipped (if it isn't already).

## Variant Callers
Three different variant callers are available with slightly different options regarding running with them. For the most accurate results when running with `clair3` or `medaka` pick a model that best matches the input data!!
Expand Down
31 changes: 31 additions & 0 deletions modules/local/custom/utils.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,35 @@
// Custom Utility Modules
process CAT_FASTQ {
label 'process_single'
tag "$meta.id"

conda "conda-forge::pigz=2.3.4"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/pigz:2.3.4' :
'biocontainers/pigz:2.3.4' }"

input:
tuple val(meta), path(gzipped_reads), path(reads)

output:
tuple val(meta), path("*.merged.fastq.gz"), emit: fastq

script:
// Check if input lists are empty or not
def gzReadsExist = !gzipped_reads.empty
def readsExist = !reads.empty

def outName = "${meta.id}.merged.fastq.gz"
"""
touch $outName
if [ "$gzReadsExist" == "true" ]; then
cat $gzipped_reads >> $outName
fi
if [ "$readsExist" == "true" ]; then
cat $reads | pigz -ck >> $outName
fi
"""
}
process DOWNLOAD_SCHEME {
label 'process_single'
tag { params.scheme_repo }
Expand Down
32 changes: 30 additions & 2 deletions subworkflows/local/format_input.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/
include { samplesheetToList } from 'plugin/nf-schema'
include { CAT_FASTQ } from '../../modules/local/custom/utils.nf'

/*
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -55,11 +56,38 @@ workflow FORMAT_INPUT {
// Input CSV file with path to fastq single reads to comply with IRIDA Next (eventually)
//
else {
// Using the samplesheet thing
// Using the samplesheet thingy
Channel.fromList(samplesheetToList(params.input, "assets/schema_input.json"))
// Group by name
.groupTuple(by: 0)
.map{ meta, fastqs ->
// Set list of fastqs found
def gzfq_list = []
def fq_list = []

// Determine if gzipped or not
// The samplesheetToList part should deal with name/extension reqs
for ( fastq in fastqs ) {
if ( fastq.isFile() ) {
if ( fastq.getName().endsWith('.gz') ) {
gzfq_list << fastq
}else {
fq_list << fastq
}
}
}
return [meta, gzfq_list, fq_list]
}.set{ ch_initial_fastqs }

// Concatenate fastqs to allow gzipped and non-gzipped together
CAT_FASTQ(
ch_initial_fastqs
)

CAT_FASTQ.out.fastq
.branch{
empty: it[1].isEmpty()
pass: it[1].countFastq() >= 1
empty: it[1].countFastq() == 0
}.set{ ch_fastqs }
}

Expand Down

0 comments on commit f97f1d6

Please sign in to comment.