Skip to content

Commit

Permalink
added cli option for sample sheet generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mattheww95 committed Oct 22, 2024
1 parent 4ff89a4 commit 1367769
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/mikrokondo_tools/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from mikrokondo_tools.__about__ import __version__
from mikrokondo_tools.cli.download import download
from mikrokondo_tools.cli.format import fmt
from mikrokondo_tools.cli.samplesheet import samplesheet


@click.group(context_settings={"help_option_names": ["-h", "--help"]}, invoke_without_command=True, no_args_is_help=True)
Expand All @@ -15,6 +16,7 @@ def mikrokondo_tools():

mikrokondo_tools.add_command(fmt)
mikrokondo_tools.add_command(download)
mikrokondo_tools.add_command(samplesheet)



Expand Down
23 changes: 23 additions & 0 deletions src/mikrokondo_tools/cli/samplesheet/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import click
import pathlib as p
import errno as e
import sys

from mikrokondo_tools.samplesheet import samplesheet as ss
import mikrokondo_tools.utils as u

@click.command(short_help="Generate a sample sheet for mikrokondo.", no_args_is_help=True)
@click.option("-o", "--output-sheet", "output_sheet", required=True, type=click.Path(), help="The file to write your created output sheet to, this directory must already exist.")
@click.option("-1", "--read-1-suffix", "read_1", type=click.STRING, help="A suffix to identify read 1", default="_R1_")
@click.option("-2", "--read-2-suffix", "read_2", type=click.STRING, help="A suffix to identify read 2", default="_R2_")
@click.option("-s", "--schema-input", "schema_input", type=click.Path(), default=None, help="An optional schema_input.json file pre-downloaded for mikrokondo.")
@click.argument("sample_directory", type=click.Path(exists=True))
def samplesheet(output_sheet, read_1, read_2, input_directory, schema_input):
logger = u.get_logger()
if output_sheet.is_file():
logger.error("Input sample sheet already exists, please re-name your new sheet or the existing one. %s", output_sheet)
sys.exit(e.EEXIST)

data = ss.get_samples(p.Path(input_directory))
ngs_data = ss.NGSData(data[0], data[1], read_1, read_2, p.Path(output_sheet), schema_input)
return ngs_data.create_sample_sheet()

0 comments on commit 1367769

Please sign in to comment.