Skip to content

Commit

Permalink
Use hyphens instead of underscores for cli options
Browse files Browse the repository at this point in the history
  • Loading branch information
marissafujimoto committed Dec 18, 2024
1 parent c023589 commit 3ac44cd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions src/pgmap/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from pgmap.io import barcode_reader, library_reader, counts_writer
from pgmap.trimming import read_trimmer

TWO_READ_STRATEGY = "two_read"
THREE_READ_STRATEGY = "three_read"
TWO_READ_STRATEGY = "two-read"
THREE_READ_STRATEGY = "three-read"


def get_counts(args: argparse.Namespace):
Expand Down Expand Up @@ -44,11 +44,11 @@ def _parse_args(args: list[str]) -> argparse.Namespace:
parser.add_argument("-o", "--output", required=False,
help="Output file path to populate with the counts for each paired guide and sample. If not provided the counts will be output in STDOUT.")
# TODO support arbitrary trim strategies
parser.add_argument("--trim_strategy", required=True, choices=(TWO_READ_STRATEGY, THREE_READ_STRATEGY),
parser.add_argument("--trim-strategy", required=True, choices=(TWO_READ_STRATEGY, THREE_READ_STRATEGY),
help="The trim strategy used to extract guides and barcodes. The two read strategy should have fastqs R1 and I1. The three read strategy should have fastqs R1, I1, and I2") # TODO extract consts
parser.add_argument("--gRNA2_error", required=False, default=2, type=_check_nonnegative,
parser.add_argument("--gRNA2-error", required=False, default=2, type=_check_nonnegative,
help="The number of substituted base pairs to allow in gRNA2.")
parser.add_argument("--barcode_error", required=False, default=2, type=_check_nonnegative,
parser.add_argument("--barcode-error", required=False, default=2, type=_check_nonnegative,
help="The number of insertions, deletions, and subsititions of base pairs to allow in the barcodes.")
return parser.parse_args(args)

Expand Down
30 changes: 15 additions & 15 deletions tests/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ def test_arg_parse_happy_case(self):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two_read"])
"--trim-strategy", "two-read"])
self.assertEqual(args.fastq[0], TWO_READ_R1_PATH)
self.assertEqual(args.fastq[1], TWO_READ_I1_PATH)
self.assertEqual(args.library, PGPEN_ANNOTATION_PATH)
self.assertEqual(args.barcodes, TWO_READ_BARCODES_PATH)
self.assertEqual(args.trim_strategy, "two_read")
self.assertEqual(args.trim_strategy, "two-read")
self.assertEqual(args.gRNA2_error, 2)
self.assertEqual(args.barcode_error, 2)

Expand All @@ -221,60 +221,60 @@ def test_arg_parse_invalid_fastq(self):
args = cli._parse_args(["--fastq", INVALID_FILE_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two_read"])
"--trim-strategy", "two-read"])

def test_arg_parse_invalid_library(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", INVALID_FILE_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two_read"])
"--trim-strategy", "two-read"])

def test_arg_parse_invalid_barcodes(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", INVALID_FILE_PATH,
"--trim_strategy", "two_read"])
"--trim-strategy", "two-read"])

def test_arg_parse_invalid_trim_strategy(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "burger"])
"--trim-strategy", "burger"])

def test_arg_parse_negative_gRNA2_error(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two-read",
"--gRNA2_error", "-1"])
"--trim-strategy", "two-read",
"--gRNA2-error", "-1"])

def test_arg_parse_negative_barcode_error(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two-read",
"--barcode_error", "-1"])
"--trim-strategy", "two-read",
"--barcode-error", "-1"])

def test_arg_parse_invalid_type_gRNA2_error(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two-read",
"--gRNA2_error", "one"])
"--trim-strategy", "two-read",
"--gRNA2-error", "one"])

def test_arg_parse_invalid_type_barcode_error(self):
with self.assertRaises(argparse.ArgumentError):
args = cli._parse_args(["--fastq", TWO_READ_R1_PATH, TWO_READ_I1_PATH,
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--trim_strategy", "two-read",
"--barcode_error", "one"])
"--trim-strategy", "two-read",
"--barcode-error", "one"])

def setUp(self):
self.test_output_path = f"test_file_{uuid.uuid4().hex}.tsv"
Expand All @@ -288,7 +288,7 @@ def test_main_happy_case(self):
"--library", PGPEN_ANNOTATION_PATH,
"--barcodes", TWO_READ_BARCODES_PATH,
"--output", self.test_output_path,
"--trim_strategy", "two_read"])
"--trim-strategy", "two-read"])
cli.get_counts(args)

self.assertTrue(os.path.exists(self.test_output_path))
Expand Down

0 comments on commit 3ac44cd

Please sign in to comment.