mirror of
https://github.com/MillironX/taxprofiler.git
synced 2024-11-22 09:09:55 +00:00
style: use subMap and early returns
This commit is contained in:
parent
0bcea6c993
commit
d17dce5590
1 changed files with 12 additions and 21 deletions
|
@ -37,49 +37,40 @@ workflow INPUT_CHECK {
|
||||||
// Function to get list of [ meta, [ fastq_1, fastq_2 ] ]
|
// Function to get list of [ meta, [ fastq_1, fastq_2 ] ]
|
||||||
def create_fastq_channel(LinkedHashMap row) {
|
def create_fastq_channel(LinkedHashMap row) {
|
||||||
// create meta map
|
// create meta map
|
||||||
def meta = [:]
|
def meta = row.subMap(['sample', 'run_accession', 'instrument_platform'])
|
||||||
meta.id = row.sample
|
|
||||||
meta.run_accession = row.run_accession
|
|
||||||
meta.instrument_platform = row.instrument_platform
|
|
||||||
meta.single_end = row.single_end.toBoolean()
|
meta.single_end = row.single_end.toBoolean()
|
||||||
meta.is_fasta = false
|
meta.is_fasta = false
|
||||||
|
|
||||||
// add path(s) of the fastq file(s) to the meta map
|
// add path(s) of the fastq file(s) to the meta map
|
||||||
def fastq_meta = []
|
|
||||||
if (!file(row.fastq_1).exists()) {
|
if (!file(row.fastq_1).exists()) {
|
||||||
exit 1, "ERROR: Please check input samplesheet -> Read 1 FastQ file does not exist!\n${row.fastq_1}"
|
exit 1, "ERROR: Please check input samplesheet -> Read 1 FastQ file does not exist!\n${row.fastq_1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
if (meta.single_end) {
|
if (meta.single_end) {
|
||||||
fastq_meta = [ meta, [ file(row.fastq_1) ] ]
|
return [ meta, [ file(row.fastq_1) ] ]
|
||||||
} else {
|
} else {
|
||||||
if (meta.instrument_platform == 'OXFORD_NANOPORE') {
|
if (meta.instrument_platform == 'OXFORD_NANOPORE') {
|
||||||
if (row.fastq_2 != '') {
|
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}"
|
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) ] ]
|
return [ meta, [ file(row.fastq_1) ] ]
|
||||||
} else {
|
} else {
|
||||||
if (!file(row.fastq_2).exists()) {
|
if (!file(row.fastq_2).exists()) {
|
||||||
exit 1, "ERROR: Please check input samplesheet -> Read 2 FastQ file does not exist!\n${row.fastq_2}"
|
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) ] ]
|
return [ meta, [ file(row.fastq_1), file(row.fastq_2) ] ]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
// Function to get list of [ meta, fasta ]
|
||||||
return fastq_meta
|
|
||||||
}// Function to get list of [ meta, fasta ]
|
|
||||||
def create_fasta_channel(LinkedHashMap row) {
|
def create_fasta_channel(LinkedHashMap row) {
|
||||||
def meta = [:]
|
def meta = row.subMap(['sample', 'run_accession', 'instrument_platform'])
|
||||||
meta.id = row.sample
|
|
||||||
meta.run_accession = row.run_accession
|
|
||||||
meta.instrument_platform = row.instrument_platform
|
|
||||||
meta.single_end = true
|
meta.single_end = true
|
||||||
meta.is_fasta = true
|
meta.is_fasta = true
|
||||||
|
|
||||||
def array = []
|
|
||||||
if (!file(row.fasta).exists()) {
|
if (!file(row.fasta).exists()) {
|
||||||
exit 1, "ERROR: Please check input samplesheet -> FastA file does not exist!\n${row.fasta}"
|
exit 1, "ERROR: Please check input samplesheet -> FastA file does not exist!\n${row.fasta}"
|
||||||
}
|
}
|
||||||
array = [ meta, [ file(row.fasta) ] ]
|
return [ meta, [ file(row.fasta) ] ]
|
||||||
|
|
||||||
return array
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue