Skip to content

Commit

Permalink
updated cli:
Browse files Browse the repository at this point in the history
* Added clean_symlinks
* Design looks in more places for files
  • Loading branch information
alsmith151 committed Apr 9, 2024
1 parent 11a2bc7 commit bde04e9
Showing 1 changed file with 36 additions and 4 deletions.
40 changes: 36 additions & 4 deletions seqnado/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,31 @@ def cli_design(method, files, output="design.csv"):
"""
import pathlib
from seqnado.design import Design, DesignIP, FastqFile, FastqFileIP

from loguru import logger

if not files:
files = list(pathlib.Path(".").glob("*.fastq.gz"))
potential_file_locations = [
".",
"fastqs",
"fastq",
"data",
"data/fastqs",
]

for location in potential_file_locations:
files = list(pathlib.Path(location).glob("*.fastq.gz"))
if files:
break

if not files:
raise ValueError("No fastq files provided or found in current directory.")
logger.error("No fastq files provided or found in current directory")
logger.error(f"""
Fastq files can be provided as arguments or found in the following directories:
{potential_file_locations}
""")
raise ValueError("No fastq files provided or found in current directory" )



if not method == "chip":
design = Design.from_fastq_files([FastqFile(path=fq) for fq in files])
Expand Down Expand Up @@ -92,14 +111,19 @@ def cli_design(method, files, output="design.csv"):
""",
type=click.Choice(choices=["lc", "ls", "ss"]),
)
@click.option(
"--clean-symlinks",
is_flag=True,
help="Remove symlinks created by previous runs. Useful for re-running pipeline after misconfiguration.",
)
@click.argument("pipeline_options", nargs=-1, type=click.UNPROCESSED)
def cli_pipeline(
method,
pipeline_options,
help=False,
preset="local",
version=False,
apptainer_args="",
clean_symlinks=False,
):
"""Runs the data processing pipeline"""

Expand All @@ -116,6 +140,14 @@ def cli_pipeline(

pipeline_options, cores = extract_cores_from_options(pipeline_options)

# Removes old symlinks if requested
if clean_symlinks:
logger.info("Cleaning symlinks")
links = pathlib.Path("seqnado_output/fastqs").glob("*")
for link in links:
if link.is_symlink():
link.unlink()

cmd = [
"snakemake",
"-c",
Expand Down

0 comments on commit bde04e9

Please sign in to comment.