Skip to content

Commit 36431d1

Browse files
authored
Support setting query_qualities using a string
1 parent 0eae5be commit 36431d1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

pysam/libcalignedsegment.pyx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1520,9 +1520,15 @@ cdef class AlignedSegment:
15201520
# create a python array object filling it
15211521
# with the quality scores
15221522

1523-
# NB: should avoid this copying if qual is
1523+
# Convert to a byte array if qual is a string
1524+
if isinstance(qual, str):
1525+
qual = qualitystring_to_array(qual)
1526+
1527+
# NB: avoid this copying if qual is
15241528
# already of the correct type.
1525-
cdef c_array.array result = c_array.array('B', qual)
1529+
cdef c_array.array result = (
1530+
qual if qual.typecode == 'B' else c_array.array('B', qual)
1531+
)
15261532

15271533
# copy data
15281534
memcpy(p, result.data.as_voidptr, l)

0 commit comments

Comments
 (0)