Skip to content

Commit a0ffe85

Browse files
authored
Expose --use-soft-clipped-bases flag in CLI (#145)
The ReadCollector Python API supported use_soft_clipped_bases but the CLI had no way to toggle it. Add the flag to rna_args and wire it through read_collector_from_args. Fixes #134
1 parent 5b4632e commit a0ffe85

3 files changed

Lines changed: 33 additions & 3 deletions

File tree

isovar/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
# See the License for the specific language governing permissions and
1111
# limitations under the License.
1212

13-
__version__ = "1.4.8"
13+
__version__ = "1.4.9"
1414

1515

1616
from .allele_read import AlleleRead

isovar/cli/rna_args.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ def add_rna_args(
3333
--min-mapping-quality
3434
--use-duplicate-reads
3535
--drop-secondary-alignments
36+
--use-soft-clipped-bases
3637
"""
3738
rna_group = parser.add_argument_group("RNA")
3839
rna_group.add_argument(
@@ -62,6 +63,14 @@ def add_rna_args(
6263
"By default, secondary alignments are included in reads, "
6364
"use this option to instead only use primary alignments."))
6465

66+
rna_group.add_argument(
67+
"--use-soft-clipped-bases",
68+
default=False,
69+
action="store_true",
70+
help=(
71+
"By default, soft-clipped bases at the ends of reads are excluded. "
72+
"Use this option to include them."))
73+
6574
rna_group.add_argument(
6675
"--num-rna-decompression-threads",
6776
type=int,
@@ -104,7 +113,8 @@ def read_collector_from_args(args):
104113
return ReadCollector(
105114
min_mapping_quality=args.min_mapping_quality,
106115
use_duplicate_reads=args.use_duplicate_reads,
107-
use_secondary_alignments=not args.drop_secondary_alignments)
116+
use_secondary_alignments=not args.drop_secondary_alignments,
117+
use_soft_clipped_bases=args.use_soft_clipped_bases)
108118

109119

110120
def read_evidence_generator_from_args(args):

tests/test_argparser_helpers.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
from .common import eq_
2-
from isovar.cli.rna_args import make_rna_reads_arg_parser
2+
from isovar.cli.rna_args import (
3+
make_rna_reads_arg_parser,
4+
read_collector_from_args,
5+
)
36
from isovar.cli.reference_context_args import add_reference_context_args
47
from isovar.cli.protein_sequence_args import add_protein_sequence_args
58
from isovar.cli.variant_sequences_args import add_variant_sequence_args
@@ -23,3 +26,20 @@ def test_extend_parser():
2326
eq_(args.maf, ["ZZZ.maf"])
2427
eq_(args.variant, [["chr1", "39000", "C", "G"]])
2528
eq_(args.bam, "xyz.bam")
29+
30+
31+
def test_use_soft_clipped_bases_default_off():
32+
parser = make_rna_reads_arg_parser()
33+
args = parser.parse_args(["--vcf", "x.vcf", "--bam", "x.bam"])
34+
rc = read_collector_from_args(args)
35+
eq_(rc.use_soft_clipped_bases, False)
36+
37+
38+
def test_use_soft_clipped_bases_flag_on():
39+
parser = make_rna_reads_arg_parser()
40+
args = parser.parse_args([
41+
"--vcf", "x.vcf",
42+
"--bam", "x.bam",
43+
"--use-soft-clipped-bases"])
44+
rc = read_collector_from_args(args)
45+
eq_(rc.use_soft_clipped_bases, True)

0 commit comments

Comments
 (0)