Closed GoogleCodeExporter closed 8 years ago
Thanks to the help of my colleague Michiel de Hoon, here is a working patch:
--- a/pysam/csamtools.pyx
+++ b/pysam/csamtools.pyx
@@ -1005,9 +1005,12 @@ cdef class Samfile:
x = {}
for field in fields[1:]:
key, value = field.split(":",1)
- if key not in VALID_HEADER_FIELDS[record]:
+ if key in VALID_HEADER_FIELDS[record]:
+ x[key] = VALID_HEADER_FIELDS[record][key](value)
+ elif not key.isupper():
+ x[key] = value
+ else:
raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
- x[key] = VALID_HEADER_FIELDS[record][key](value)
if VALID_HEADER_TYPES[record] == dict:
if record in result:
@@ -1030,6 +1033,9 @@ cdef class Samfile:
for key in VALID_HEADER_ORDER[record]:
if key in fields:
line.append( "%s:%s" % (key, str(fields[key])))
+ for key in fields:
+ if not key.isupper():
+ line.append( "%s:%s" % (key, str(fields[key])))
return "\t".join( line )
cdef bam_header_t * _buildHeader( self, new_header ):
Original comment by Charles....@gmail.com
on 11 May 2011 at 4:34
Thanks for this, I have added the patches to the source code.
Bw,
Andreas
Original comment by andreas....@gmail.com
on 4 Jun 2011 at 8:36
Original issue reported on code.google.com by
Charles....@gmail.com
on 11 May 2011 at 2:15