1
0
Fork 0
mirror of https://github.com/MillironX/taxprofiler.git synced 2024-11-24 02:19:55 +00:00

Do not require fixed column order

This commit is contained in:
James Fellows Yates 2022-06-13 21:02:12 +02:00
parent e0ad49ebc9
commit c1a7d6335f

View file

@ -37,6 +37,7 @@ def print_error(error, context="Line", context_str=""):
print(error_str) print(error_str)
sys.exit(1) sys.exit(1)
def check_samplesheet(file_in, file_out): def check_samplesheet(file_in, file_out):
""" """
This function checks that the samplesheet follows the following structure: This function checks that the samplesheet follows the following structure:
@ -87,10 +88,13 @@ def check_samplesheet(file_in, file_out):
"fasta", "fasta",
] ]
header = [x.strip('"') for x in fin.readline().strip().split(",")] 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( print(
"ERROR: Please check samplesheet header -> {} != {}".format( "ERROR: Missing required column header -> {}. Note some columns can otherwise be empty. See pipeline documentation (https://nf-co.re/taxprofiler/usage).".format(
",".join(header), ",".join(HEADER) ",".join(missing_columns)
) )
) )
sys.exit(1) sys.exit(1)
@ -173,7 +177,9 @@ def check_samplesheet(file_in, file_out):
## Auto-detect paired-end/single-end ## Auto-detect paired-end/single-end
if sample and fastq_1 and fastq_2: ## Paired-end short reads if sample and fastq_1 and fastq_2: ## Paired-end short reads
sample_info.extend(["0", fastq_1, fastq_2, fasta]) 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]) sample_info.extend(["1", fastq_1, fastq_2, fasta])
elif ( elif (
sample and fasta and not fastq_1 and not fastq_2 sample and fasta and not fastq_1 and not fastq_2