Skip to content

Commit

Permalink
Add AlignedSegment.__repr__ displaying the most useful fields (PR #1267)
Browse files Browse the repository at this point in the history
Example output:
<AlignedSegment('name', flags=16=0x10, ref='chr1', zpos=1170070, mapq=255, cigar='50M', ...)>

[Use an f-string; write flags in hex too; and use 'zpos' label to emphasis
this field is shown 0-based. -- JM]
  • Loading branch information
marcelm authored and jmarshall committed Oct 10, 2024
1 parent 79a6cd4 commit 9a694d0
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions pysam/libcalignedsegment.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,9 @@ cdef class AlignedSegment:
self.query_qualities,
self.tags)))

def __repr__(self):
return f'<{type(self).__name__}({self.query_name!r}, flags={self.flag}={self.flag:#x}, ref={self.reference_name!r}, zpos={self.reference_start}, mapq={self.mapping_quality}, cigar={self.cigarstring!r}, ...)>'

def __copy__(self):
return makeAlignedSegment(self._delegate, self.header)

Expand Down

0 comments on commit 9a694d0

Please sign in to comment.