From c1a7d6335f1b4c73067926563f8e2d7b0ba80d57 Mon Sep 17 00:00:00 2001 From: James Fellows Yates Date: Mon, 13 Jun 2022 21:02:12 +0200 Subject: [PATCH] Do not require fixed column order --- bin/check_samplesheet.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/check_samplesheet.py b/bin/check_samplesheet.py index d10ee90..d7ea5a9 100755 --- a/bin/check_samplesheet.py +++ b/bin/check_samplesheet.py @@ -37,6 +37,7 @@ def print_error(error, context="Line", context_str=""): print(error_str) sys.exit(1) + def check_samplesheet(file_in, file_out): """ This function checks that the samplesheet follows the following structure: @@ -87,10 +88,13 @@ def check_samplesheet(file_in, file_out): "fasta", ] header = [x.strip('"') for x in fin.readline().strip().split(",")] - if header[: len(HEADER)] != HEADER: + + ## Check for missing mandatory columns + missing_columns = list(set(HEADER) - set(header)) + if len(missing_columns) > 0: print( - "ERROR: Please check samplesheet header -> {} != {}".format( - ",".join(header), ",".join(HEADER) + "ERROR: Missing required column header -> {}. Note some columns can otherwise be empty. See pipeline documentation (https://nf-co.re/taxprofiler/usage).".format( + ",".join(missing_columns) ) ) sys.exit(1) @@ -173,7 +177,9 @@ def check_samplesheet(file_in, file_out): ## Auto-detect paired-end/single-end if sample and fastq_1 and fastq_2: ## Paired-end short reads sample_info.extend(["0", fastq_1, fastq_2, fasta]) - elif sample and fastq_1 and not fastq_2: ## Single-end short/long fastq reads + elif ( + sample and fastq_1 and not fastq_2 + ): ## Single-end short/long fastq reads sample_info.extend(["1", fastq_1, fastq_2, fasta]) elif ( sample and fasta and not fastq_1 and not fastq_2