Skip to content

Commit

Permalink
References can be called manually from samplesheet
Browse files Browse the repository at this point in the history
  • Loading branch information
DOH-JDJ0303 committed Jul 10, 2024
1 parent 2461b6a commit 260ccdf
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 7 deletions.
29 changes: 27 additions & 2 deletions subworkflows/local/classify.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ include { NCBI_DATASETS } from '../../modules/local/ncbi

workflow CLASSIFY {
take:
ch_reads // channel: [ val(meta), path(reads) ]
ch_reads // channel: [ val(meta), path(reads), path/val(reference ) ]
ch_refs // channel: [ val(meta), path(reference) ]

main:

ch_versions = Channel.empty()

ch_man_refs = ch_reads.map{ meta, reads, ref -> [ meta, ref] }
ch_reads = ch_reads.map{ meta, reads, ref -> [ meta, reads ] }

/*
=============================================================================================================================
Expand Down Expand Up @@ -188,7 +191,29 @@ workflow CLASSIFY {
.set{ ch_ref_list }

}


/*
=============================================================================================================================
REFERENCE SELECTION: Manual
- Adds list of references provided in the samplesheet
=============================================================================================================================
*/
ch_man_refs
.filter{ meta, ref -> ref }
.map{ meta, ref -> [ meta, ref.tokenize(';') ] }
.transpose()
.map{ meta, ref -> [ meta, file(ref).exists() ? file(ref).getSimpleName() : ref, file(ref).exists() ? file(ref) : null ] }
.set{ ch_man_refs }
ch_man_refs
.filter{ meta, ref_id, ref -> ! ref }
.map{ meta, ref_id, ref -> [ ref_id, meta ] }
.combine(ch_refs.map{ meta, segment, ref -> [ file(ref).getSimpleName(), ref ] }, by: 0)
.map{ ref_id, meta, ref -> [ meta, ref_id, ref ] }
.concat(ch_man_refs.filter{ meta, ref_id, ref -> ref })
.concat( ch_ref_list )
.unique()
.set{ ch_ref_list }

emit:
ref_list = ch_ref_list // channel: [ val(sample_meta), val(ref_id), path(ref_path) ]
sm_summary = ch_sm_summary // channel: [ val(meta), val(result) ]
Expand Down
7 changes: 5 additions & 2 deletions subworkflows/local/input_check.nf
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ def create_fastq_channel(LinkedHashMap row) {
meta.id = row.sample
meta.single_end = row.single_end.toBoolean()

// define manual references
ref = row.reference ? row.reference : null

// define validation fields
truth = row.truth ? file(row.truth, checkIfExists: true) : null
inter_group = row.inter_group ? row.inter_group : null
Expand All @@ -67,12 +70,12 @@ def create_fastq_channel(LinkedHashMap row) {
exit 1, "ERROR: Please check input samplesheet -> Read 1 FastQ file does not exist!\n${row.fastq_1}"
}
if (meta.single_end) {
fastq_meta = [ meta, [ file(row.fastq_1) ], truth, inter_group, intra_group ]
fastq_meta = [ meta, [ file(row.fastq_1) ], ref, truth, inter_group, intra_group ]
} else {
if (!file(row.fastq_2).exists()) {
exit 1, "ERROR: Please check input samplesheet -> Read 2 FastQ file does not exist!\n${row.fastq_2}"
}
fastq_meta = [ meta, [ file(row.fastq_1), file(row.fastq_2) ], truth, inter_group, intra_group ]
fastq_meta = [ meta, [ file(row.fastq_1), file(row.fastq_2) ], ref, truth, inter_group, intra_group ]
}
return fastq_meta
}
Expand Down
9 changes: 6 additions & 3 deletions workflows/vaper.nf
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ workflow VAPER {
)
ch_versions = ch_versions.mix(INPUT_CHECK.out.versions)

INPUT_CHECK.out.reads.map{ meta, reads, truth, inter_group, intra_group -> [ meta, reads ] }.set{ ch_reads }
INPUT_CHECK.out.reads.map{ meta, reads, reference, truth, inter_group, intra_group -> [ meta, reads ] }.set{ ch_reads }
INPUT_CHECK.out.refs.set{ ch_refs }

/*
Expand Down Expand Up @@ -131,7 +131,10 @@ workflow VAPER {
// SUBWORKFLOW: Classify viruses
//
CLASSIFY (
FASTP.out.reads,
FASTP
.out
.reads
.join(INPUT_CHECK.out.reads.map{ meta, reads, reference, truth, inter_group, intra_group -> [ meta, reference ] }, by: 0),
ch_refs
)

Expand Down Expand Up @@ -201,7 +204,7 @@ workflow VAPER {
*/

VALIDATE(
INPUT_CHECK.out.reads.map{ meta, reads, truth, inter_group, intra_group -> [ meta, truth, inter_group, intra_group ] },
INPUT_CHECK.out.reads.map{ meta, reads, ref, truth, inter_group, intra_group -> [ meta, truth, inter_group, intra_group ] },
ASSEMBLE.out.consensus.map{ meta, ref_id, consensus -> [ meta, consensus ] }
)

Expand Down

0 comments on commit 260ccdf

Please sign in to comment.