Module: Bio::GFFbrowser::FastLineParser
Overview
The fast line parse takes the least number of actions to parse a GFF3 line (record).
Instance Method Summary collapse
- #parse_attributes_fast(attribstring, options = {}) ⇒ Object
-
#parse_line_fast(string, options = {}) ⇒ Object
Returns a (partial) record, assuming it is a valid GFF3 format, no validation takes place, other than field counting (!).
Methods included from Helpers::Error
Instance Method Details
#parse_attributes_fast(attribstring, options = {}) ⇒ Object
55 56 57 58 59 |
# File 'lib/bio/db/gff/gff3parserec.rb', line 55 def parse_attributes_fast attribstring, = {} Hash[attribstring.split(/;/).map { | a | a.split(/=/,2) }] end |
#parse_line_fast(string, options = {}) ⇒ Object
Returns a (partial) record, assuming it is a valid GFF3 format, no validation takes place, other than field counting (!)
Start and End are always set to int values. ID and Parent are returned in features.
The options define further parsing of fields. Options are
An array is returned, with appropriate fields
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/bio/db/gff/gff3parserec.rb', line 40 def parse_line_fast string, = {} fs = string.split(/\t/) if fs.size != 9 error "Record should have 9 fields, but has #{fs.size} <#{string}>" return nil end fs[GFF3_START] = fs[GFF3_START].to_i fs[GFF3_END] = fs[GFF3_END].to_i fs[GFF3_SCORE] = fs[GFF3_SCORE].to_f fs[GFF3_PHASE] = fs[GFF3_PHASE].to_i fs[GFF3_ATTRIBUTES] = parse_attributes_fast(fs[GFF3_ATTRIBUTES],) fs end |