lixin6135 / pysam

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

Error in updating read.tags #92

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
As part of some custom read clipping, I remove the NM and MD tags. The 
resulting BAM file can be read by samtools and pysam but not by GATK or Picard. 
Both complain about a casting error:  "java.lang.Character cannot be cast to 
java.lang.String".

The following code reproduces the problem:

import pysam
inbam = pysam.Samfile("in.bam", 'rb')
outbam = pysam.Samfile("out.bam", 'wb', template=inbam)
for read in inbam:
    read.tags = [(tag, value) for tag, value in read.tags if tag not in {'NM', 'MD'}]
    _ = outbam.write(read)
inbam.close()
outbam.close()

I then run 'samtools index out.bam'. Any attempt to use GATK/Picard on out.bam 
fails with a casting error.

What version of the product are you using? On what operating system?

pysam 0.6
samtools 0.1.18 (r982:295)

Original issue reported on code.google.com by abhiks...@gmail.com on 3 May 2012 at 3:15

GoogleCodeExporter commented 8 years ago
I was using an older version of GATK. Tested with GATK version 1.6-2-gc2b74ec 
(the latest downloadable version) and the same error occurs.

Original comment by abhiks...@gmail.com on 3 May 2012 at 4:52

GoogleCodeExporter commented 8 years ago
Hi,

this happens with every bam file?

Best wishes,
Andreas

Original comment by andreas....@gmail.com on 7 Jul 2012 at 9:46

GoogleCodeExporter commented 8 years ago
No update - closed for now.

Original comment by andreas....@gmail.com on 27 Jun 2013 at 1:36

GoogleCodeExporter commented 8 years ago
Hey,

I'm not sure if this is still an issue but I've seen this before with Pysam 
versions <0.8 (not sure if 0.8 fixed this). What happens is that after changing 
a read's tags and writing the read, the read group tag will be changed from 
RG:Z:1 to RG:A:1 I have no idea why this happens but others have observed this 
before (see e.g. http://pythonhackers.com/p/mjafin/splitNreads)

Andreas

Original comment by andreas....@gmail.com on 25 Apr 2015 at 5:46