Pysam is a Python package for reading, manipulating, and writing genomics data such as SAM/BAM/CRAM and VCF/BCF files. It's a lightweight wrapper of the HTSlib API, the same one that powers samtools, bcftools, and tabix.
If I read an alignment from a bam file and use the to_dict() or to_string() methods to export the alignment, the resulting AlignedSegment object created by from_dict() or fromstring() are not equivalent to the original.
example with to_string() but same happens with dictionary version
If I read an alignment from a bam file and use the
to_dict()
orto_string()
methods to export the alignment, the resulting AlignedSegment object created byfrom_dict()
orfromstring()
are not equivalent to the original.example with to_string() but same happens with dictionary version
foo_str = orig_aln.to_string() foo_header = orig_aln.header foo = pysam.AlignedSegment.fromstring(foo_str, foo_header)
this is False
foo == orig_aln
this is True
foo.to_string() == orig_aln.to_string()
I can't find what is different about them however.