MaciekAber / pysam

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

Bug in Samfile.header property #20

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
If you have any header field containing more than one colon (:) the split
command will return a sequence of >2 fields here:

# the following is clumsy as generators do not work?
x = {}
for field in fields[1:]: 
    key,value = field.split(":")
    if key not in VALID_HEADER_FIELDS[record]:
    ...
    ...

And the method will fail to produce a valid header and returns with an
'unpack' error.

Fix this by splitting differently:

splitfield = field.split(":")
key, value = splitfield[0], splitfield[1:]

Original issue reported on code.google.com by matthew....@gmail.com on 19 Nov 2009 at 10:42

GoogleCodeExporter commented 8 years ago
Thanks. I have used your suggestion, but use

key, value = field.split(":",1)

Thus, colon containing values will allow a colon as a character.

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

GoogleCodeExporter commented 8 years ago

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