Skip to content

Commit

Permalink
Refactor design generation and add error handling
Browse files Browse the repository at this point in the history
for missing fastq files
  • Loading branch information
alsmith151 committed Jan 10, 2024
1 parent 12da875 commit 3e5bf09
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions seqnado/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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:
Expand Down

0 comments on commit 3e5bf09

Please sign in to comment.