From 9a694d04fd0cb0dee3265fddb0376951dd811f8e Mon Sep 17 00:00:00 2001 From: Marcel Martin Date: Tue, 13 Feb 2024 21:59:20 +0100 Subject: [PATCH] Add AlignedSegment.__repr__ displaying the most useful fields (PR #1267) Example output: [Use an f-string; write flags in hex too; and use 'zpos' label to emphasis this field is shown 0-based. -- JM] --- pysam/libcalignedsegment.pyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pysam/libcalignedsegment.pyx b/pysam/libcalignedsegment.pyx index d688eacd..3bf73a6c 100644 --- a/pysam/libcalignedsegment.pyx +++ b/pysam/libcalignedsegment.pyx @@ -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)