Skip to content

Commit 8e30c97

Browse files
committed
test (parseArriba): --skip-failed tested
1 parent 656140c commit 8e30c97

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1212

1313
## [1.4.6-rc3] - 2025-03-10
1414

15-
- Added --skip-failed flag to callVariant.
15+
- Added --skip-failed flag to callVariant, parseArriba.
1616

1717
## [1.4.6-rc2] - 2025-03-03
1818

moPepGen/cli/parse_arriba.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ def parse_arriba(args:argparse.Namespace) -> None:
136136
continue
137137
try:
138138
var_records = record.convert_to_variant_records(anno, genome)
139+
variants.extend(var_records)
139140
tally.succeed += 1
140141
except err.GeneNotFoundError:
141142
tally.skipped.invalid_gene_id += 1
@@ -145,7 +146,8 @@ def parse_arriba(args:argparse.Namespace) -> None:
145146
if args.skip_failed:
146147
tally.skipped.invalid_position += 1
147148
tally.skipped.total += 1
148-
variants.extend(var_records)
149+
else:
150+
raise
149151

150152
logger.info('Arriba output %s loaded.', fusion)
151153

test/integration/test_parse_arriba.py

+22-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import argparse
33
import subprocess as sp
44
import sys
5+
from unittest.mock import Mock
56
from test.integration import TestCaseIntegration
67
from moPepGen import cli
78

89

910
class TestParseArriba(TestCaseIntegration):
1011
""" Test cases for moPepGen parseSTARFusion """
11-
def test_parse_arriba(self):
12-
""" Test parseArriba """
12+
def create_base_args(self) -> argparse.Namespace:
13+
""" Create base args """
1314
args = argparse.Namespace()
1415
args.command = 'parseArriba'
1516
args.input_path = self.data_dir/'fusion/arriba.txt'
@@ -24,6 +25,12 @@ def test_parse_arriba(self):
2425
args.min_split_read2 = 1
2526
args.min_confidence = 'medium'
2627
args.quiet = False
28+
args.skip_failed = False
29+
return args
30+
31+
def test_parse_arriba(self):
32+
""" Test parseArriba """
33+
args = self.create_base_args()
2734
cli.parse_arriba(args)
2835
files = {str(file.name) for file in self.work_dir.glob('*')}
2936
expected = {'arriba.gvf'}
@@ -47,3 +54,16 @@ def test_parse_arriba_cli(self):
4754
print(cmd)
4855
print(res.stderr.decode('utf-8'))
4956
raise
57+
58+
def test_parse_arriba_skip_failed(self):
59+
""" Test parseArriba with skip failed """
60+
from moPepGen import parser
61+
parser.ArribaParser.ArribaRecord.convert_to_variant_records = Mock(
62+
side_effect=ValueError()
63+
)
64+
args = self.create_base_args()
65+
with self.assertRaises(ValueError):
66+
cli.parse_arriba(args)
67+
68+
args.skip_failed = True
69+
cli.parse_arriba(args)

0 commit comments

Comments
 (0)