1
1
import pytest
2
- from fgpyo .sam import extract_umis_from_read_name , _is_valid_umi , copy_umi_from_read_name , AlignedSegment
2
+
3
+ from fgpyo .sam import _is_valid_umi
4
+ from fgpyo .sam import copy_umi_from_read_name
5
+ from fgpyo .sam import extract_umis_from_read_name
3
6
from fgpyo .sam .builder import SamBuilder
4
7
5
8
@@ -51,39 +54,44 @@ def test_extract_umi_from_read_name_raises(read_name: str) -> None:
51
54
with pytest .raises (ValueError ):
52
55
extract_umis_from_read_name (read_name )
53
56
57
+
54
58
@pytest .mark .parametrize (
55
59
"read_name, extraction" ,
56
60
[
57
- ("abc:def:ghi:jfk:lmn:opq:ACGT" ,None ), # colons == 6
58
- ("abc:def:ghi:jfk:lmn:opq:rst:ACGT" ,"ACGT" ), # colons == 7
61
+ ("abc:def:ghi:jfk:lmn:opq:ACGT" , None ), # colons == 6
62
+ ("abc:def:ghi:jfk:lmn:opq:rst:ACGT" , "ACGT" ), # colons == 7
59
63
],
60
64
)
61
65
def test_strict_extract_umi_from_read_name (read_name : str , extraction : str ) -> None :
62
66
"""Test that we raise an error when strict=True and number of colons is not 7 or 8."""
63
67
assert extract_umis_from_read_name (read_name , strict = True ) == extraction
64
68
69
+
65
70
@pytest .mark .parametrize (
66
71
"read_name" ,
67
72
[
68
73
("abc:def:ghi:jfk" ),
69
74
("abc:def:ghi:jfk:lmn:opq:rst:uvw:xyz" ),
70
- ("abc:def:ghi:jfk:lmn:opq:rst:" ) # Invalid UMI
75
+ ("abc:def:ghi:jfk:lmn:opq:rst:" ), # Invalid UMI
71
76
],
72
77
)
73
78
def test_strict_extract_umi_from_read_name_raises (read_name : str ) -> None :
74
79
"""Test that we raise an error when strict=True and number of colons is not 7 or 8."""
75
80
with pytest .raises (ValueError ):
76
- extract_umis_from_read_name (read_name ,strict = True )
81
+ extract_umis_from_read_name (read_name , strict = True )
82
+
83
+
77
84
def test_copy_umi_from_read_name () -> None :
78
85
builder = SamBuilder ()
79
86
read = builder .add_single (name = "read_name:GATTACA" )
80
87
copy_umi_from_read_name (read , remove_umi = False )
81
- assert read .qname == "read_name:GATTACA"
88
+ assert read .query_name == "read_name:GATTACA"
82
89
assert read .get_tag ("RX" ) == "GATTACA"
83
90
91
+
84
92
def test_copy_remove_umi_from_read_name () -> None :
85
93
builder = SamBuilder ()
86
94
read = builder .add_single (name = "read_name:GATTACA" )
87
95
copy_umi_from_read_name (read , remove_umi = True )
88
- assert read .qname == "read_name"
89
- assert read .get_tag ("RX" ) == "GATTACA"
96
+ assert read .query_name == "read_name"
97
+ assert read .get_tag ("RX" ) == "GATTACA"
0 commit comments