Hi all,
I used the following code to get the numbers of reads at each position mapped to the reference.
-------------------------------------------------------------------------------------------------
FileName = sys.argv[1]
samfile = pysam.AlignmentFile(FileName, "rb")
numlist=[]
for pileupcolumn in samfile.pileup("ref",start = 55, stop = 61,truncate=True, max_depth=200000,min_mapping_quality=20):
if pileupcolumn.pos>=starP and pileupcolumn.pos<endP:
numMapped=0
for pileupread in pileupcolumn.pileups:
numMapped+=1
numlist.append(numMapped)
print numlist
---------------------------------------------------------------------------------------------
I saved the above code in a file named 'test.py' and then run the script respectively using my laptop (with pysam 0.16.0.1 installed) and office computer (with pysam 0.9.1 installed) as follows:
python test.py input.bam
Then I got different results below.
the output from pysam 0.16.0.1
[15481, 15476, 15473, 15473, 15475, 15474]
the output from pysam 0.9.1
[15486, 15486, 15486, 15486, 15486, 15486]
Anyone knows why? Much appreciated for your help in advance!
Best,
Jia