2022-02-18 06:55:14 +00:00
|
|
|
//
|
|
|
|
// Check input samplesheet and get read channels
|
|
|
|
//
|
|
|
|
|
|
|
|
include { SAMPLESHEET_CHECK } from '../../modules/local/samplesheet_check'
|
2022-08-16 19:46:22 +00:00
|
|
|
include { EIDO_VALIDATE } from '../../modules/nf-core/modules/eido/validate/main'
|
|
|
|
include { EIDO_CONVERT } from '../../modules/nf-core/modules/eido/convert/main'
|
2022-02-18 06:55:14 +00:00
|
|
|
|
|
|
|
workflow INPUT_CHECK {
|
|
|
|
take:
|
2022-08-16 19:46:22 +00:00
|
|
|
samplesheet_or_pep_config // file: /path/to/samplesheet.csv or /path/to/pep/config.yaml
|
2022-09-19 13:51:25 +00:00
|
|
|
pep_input_base_dir
|
2022-02-18 06:55:14 +00:00
|
|
|
|
|
|
|
main:
|
2022-09-19 13:51:25 +00:00
|
|
|
EIDO_VALIDATE ( samplesheet_or_pep_config, file("$projectDir/assets/samplesheet_schema.yaml"), pep_input_base_dir )
|
|
|
|
converted_samplesheet = EIDO_CONVERT ( samplesheet_or_pep_config, "csv", pep_input_base_dir )
|
2022-08-16 19:46:22 +00:00
|
|
|
parsed_samplesheet = SAMPLESHEET_CHECK ( converted_samplesheet.samplesheet_converted )
|
2022-02-18 06:55:14 +00:00
|
|
|
.csv
|
|
|
|
.splitCsv ( header:true, sep:',' )
|
2022-02-18 15:51:01 +00:00
|
|
|
.branch {
|
|
|
|
fasta: it['fasta'] != ''
|
2022-03-18 09:45:06 +00:00
|
|
|
nanopore: it['instrument_platform'] == 'OXFORD_NANOPORE'
|
2022-02-18 15:51:01 +00:00
|
|
|
fastq: true
|
|
|
|
}
|
|
|
|
|
|
|
|
parsed_samplesheet.fastq
|
2022-03-18 09:47:41 +00:00
|
|
|
.map { create_fastq_channel(it) }
|
2022-02-18 15:51:01 +00:00
|
|
|
.set { fastq }
|
|
|
|
|
2022-03-18 09:47:41 +00:00
|
|
|
parsed_samplesheet.nanopore
|
|
|
|
.map { create_fastq_channel(it) }
|
|
|
|
.set { nanopore }
|
|
|
|
|
2022-02-18 15:51:01 +00:00
|
|
|
parsed_samplesheet.fasta
|
2022-03-21 19:28:09 +00:00
|
|
|
.map { create_fasta_channel(it) }
|
2022-02-18 15:51:01 +00:00
|
|
|
.set { fasta }
|
2022-02-18 06:55:14 +00:00
|
|
|
|
|
|
|
emit:
|
2022-03-18 19:50:18 +00:00
|
|
|
fastq = fastq ?: [] // channel: [ val(meta), [ reads ] ]
|
|
|
|
nanopore = nanopore ?: [] // channel: [ val(meta), [ reads ] ]
|
|
|
|
fasta = fasta ?: [] // channel: [ val(meta), fasta ]
|
2022-02-18 06:55:14 +00:00
|
|
|
versions = SAMPLESHEET_CHECK.out.versions // channel: [ versions.yml ]
|
|
|
|
}
|
|
|
|
|
|
|
|
// Function to get list of [ meta, [ fastq_1, fastq_2 ] ]
|
2022-03-21 19:28:09 +00:00
|
|
|
def create_fastq_channel(LinkedHashMap row) {
|
2022-03-15 21:05:37 +00:00
|
|
|
// create meta map
|
2022-02-18 06:55:14 +00:00
|
|
|
def meta = [:]
|
2022-02-18 15:51:01 +00:00
|
|
|
meta.id = row.sample
|
|
|
|
meta.run_accession = row.run_accession
|
|
|
|
meta.instrument_platform = row.instrument_platform
|
|
|
|
meta.single_end = row.single_end.toBoolean()
|
2022-04-18 05:35:19 +00:00
|
|
|
meta.is_fasta = false
|
2022-02-18 06:55:14 +00:00
|
|
|
|
2022-03-15 21:05:37 +00:00
|
|
|
// add path(s) of the fastq file(s) to the meta map
|
|
|
|
def fastq_meta = []
|
2022-02-18 06:55:14 +00:00
|
|
|
if (!file(row.fastq_1).exists()) {
|
|
|
|
exit 1, "ERROR: Please check input samplesheet -> Read 1 FastQ file does not exist!\n${row.fastq_1}"
|
|
|
|
}
|
|
|
|
if (meta.single_end) {
|
2022-03-15 21:05:37 +00:00
|
|
|
fastq_meta = [ meta, [ file(row.fastq_1) ] ]
|
2022-02-18 06:55:14 +00:00
|
|
|
} else {
|
2022-03-18 09:47:41 +00:00
|
|
|
if (meta.instrument_platform == 'OXFORD_NANOPORE') {
|
|
|
|
if (row.fastq_2 != '') {
|
|
|
|
exit 1, "ERROR: Please check input samplesheet -> For Oxford Nanopore reads Read 2 FastQ should be empty!\n${row.fastq_2}"
|
|
|
|
}
|
|
|
|
fastq_meta = [ meta, [ file(row.fastq_1) ] ]
|
|
|
|
} 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}"
|
|
|
|
}
|
2022-03-24 11:51:45 +00:00
|
|
|
fastq_meta = [ meta, [ file(row.fastq_1), file(row.fastq_2) ] ]
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|
2022-03-24 11:51:45 +00:00
|
|
|
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|
2022-03-15 21:05:37 +00:00
|
|
|
return fastq_meta
|
2022-04-04 11:51:51 +00:00
|
|
|
}// Function to get list of [ meta, fasta ]
|
2022-03-21 19:28:09 +00:00
|
|
|
def create_fasta_channel(LinkedHashMap row) {
|
2022-02-18 15:51:01 +00:00
|
|
|
def meta = [:]
|
|
|
|
meta.id = row.sample
|
|
|
|
meta.run_accession = row.run_accession
|
|
|
|
meta.instrument_platform = row.instrument_platform
|
|
|
|
meta.single_end = true
|
2022-04-18 05:35:19 +00:00
|
|
|
meta.is_fasta = true
|
2022-02-18 15:51:01 +00:00
|
|
|
|
|
|
|
def array = []
|
|
|
|
if (!file(row.fasta).exists()) {
|
|
|
|
exit 1, "ERROR: Please check input samplesheet -> FastA file does not exist!\n${row.fasta}"
|
|
|
|
}
|
|
|
|
array = [ meta, [ file(row.fasta) ] ]
|
|
|
|
|
|
|
|
return array
|
|
|
|
}
|