From 3e5bf09e4334f47f72e9a3a9a4daeebdd8801602 Mon Sep 17 00:00:00 2001 From: alsmith Date: Wed, 10 Jan 2024 17:19:16 +0000 Subject: [PATCH] Refactor design generation and add error handling for missing fastq files --- seqnado/cli.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/seqnado/cli.py b/seqnado/cli.py index f23bbc5f..abd15bff 100644 --- a/seqnado/cli.py +++ b/seqnado/cli.py @@ -35,22 +35,25 @@ def cli_design(method, files, output="design.csv"): """ Generates a SeqNado design file from a list of files. """ + import pathlib + import sys - assert ( - len(files) > 0 - ), "No files provided. Please provide a list of files separated by spaces." + if not files: + fastq = list(pathlib.Path(".").glob("*.fastq.gz")) + + if not fastq: + raise ValueError("No fastq files provided or found in current directory.") if not method == "chip": - from seqnado.utils import GenericFastqSamples + from seqnado.utils import Design - design = GenericFastqSamples.from_files(files).design + design = Design.from_fastq_files(files) else: - from seqnado.utils import ChipseqFastqSamples + from seqnado.utils import DesignIP - design = ChipseqFastqSamples.from_files(files).design + design = DesignIP.from_fastq_files(files) - design = design.drop(columns=["paired"], errors="ignore") - design.to_csv(output, index=False) + design.to_dataframe().to_csv(output, index=False) @click.command(context_settings=dict(ignore_unknown_options=True)) @@ -74,7 +77,6 @@ def cli_design(method, files, output="design.csv"): def cli_pipeline( method, pipeline_options, help=False, cores=1, preset="local", version=False ): - """Runs the data processing pipeline""" if version: