MaciekAber / pysam

Automatically exported from code.google.com/p/pysam
0 stars 0 forks source link

aln.rname and aln.mrna returns reference index, not reference name #25

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Reading a BAM file like so: samfile = pysam.Samfile("my.bam", "rb" )
2. for aln in samfile.fetch(until_eof = True):
3.      print aln.rname, aln.mrnm

What is the expected output? What do you see instead?
I would expect "chr1 chr1" and get "0 0"

What version of the product are you using? On what operating system?
pysam 0.12 Mac OS X 10.6, python 2.6

Please provide any additional information below.
It's possible to create a function that converts from ref_index to ref_name 
like so:

head = samfile.header
def getRname(rname_idx):
    print head['SQ'][rname_idx]['SN']

But this is not very convenient. 

Original issue reported on code.google.com by daniel.k...@gmail.com on 14 Apr 2010 at 1:06

GoogleCodeExporter commented 8 years ago
Clarification: The manual states that

rname
      reference ID

with a link to 'Reference':

Reference
      The sequence that reads have been mapped onto. For example chr1, contig123.

which clearly isn't the index of the reference, but the actual name.

Original comment by daniel.k...@gmail.com on 14 Apr 2010 at 1:09

GoogleCodeExporter commented 8 years ago
I have this fixed in my local branch, as well as a number of other 
improvements.  I'll 
send these on to the pysam authors.

Original comment by bioinformed@gmail.com on 30 Apr 2010 at 11:15

GoogleCodeExporter commented 8 years ago

Original comment by andreas....@gmail.com on 4 May 2010 at 9:25

GoogleCodeExporter commented 8 years ago
Thanks.

Note that there is the getrname convenience function in Samfile to do the
conversion.

There is a problem with tid (the numeric identifier of the target) and rname 
(the
real name of the target). The former is part of an AlignedRead, the latter is 
part of
the Samfile, hence the need for translation. I wanted to keep the translation
transparent as AlignedReads might exist independently of a Samfile, for example
when creating a new one.

Happy to discuss this, though.

The documentation is misleading and should be changed.

Original comment by andreas....@gmail.com on 4 May 2010 at 9:39

GoogleCodeExporter commented 8 years ago
Issue 26 has been merged into this issue.

Original comment by andreas....@gmail.com on 4 May 2010 at 9:39

GoogleCodeExporter commented 8 years ago
Issue 34 has been merged into this issue.

Original comment by andreas....@gmail.com on 18 Jul 2010 at 6:17

GoogleCodeExporter commented 8 years ago
What is the status on this bug as I have installed the latest release and it is 
still there

Original comment by nathan.w...@gmail.com on 7 Feb 2012 at 11:56

GoogleCodeExporter commented 8 years ago
This issue has not been resolved. It can't be easily resolved and is not 
necesseraly
a problem in practice.

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 26 Nov 2013 at 10:16