[BioRuby] GFF3 attribute parser problems

Ben Woodcroft donttrustben at gmail.com
Sat Jun 28 04:20:25 UTC 2008


Hi,

I noticed there is a problem with the Bio::GFF::GFF3 class. Using bioruby 1.2.1

  class GFF3 < GFF
    VERSION = 3

    private

    def parse_attributes(attributes)
      hash = Hash.new
      attributes.split(/[^\\];/).each do |atr|
        key, value = atr.split('=', 2)
        hash[key] = value
      end
      return hash
    end

My problem is with the split([/^\\]) bit, because it chops off an
extra character at the end of the key:

irb(main):001:0> 'abc=def;one=two'.split(/[^\\];/)
=> ["abc=de", "one=two"]

where we want
=> ["abc=def", "one=two"]



I took a shortcut to solve it and ignored the escaping of the ; and
just did this

    hash = Hash.new
    attributes.split(/;/).each do |atr|
      key, value = atr.split('=', 2)
      hash[key] = value
    end
    return hash


Thanks,
ben



More information about the BioRuby mailing list