class Bio::GFF::Record

Represents a single line of a GFF-formatted file. See Bio::GFF for more information.

Attributes

attributes[RW]

List of tag=value pairs (e.g. to store name of the feature: ID=my_id)

comment[RW]

Comments for the GFF record

end[RW]

End position of feature on reference sequence

feature[RW]

Name of the feature

frame[RW]

For features of type 'exon': indicates where feature begins in the reading frame

score[RW]

Score of annotation (e.g. e-value for BLAST search)

seqname[RW]

Name of the reference sequence

source[RW]

Name of the source of the feature (e.g. program that did prediction)

start[RW]

Start position of feature on reference sequence

strand[RW]

Strand that feature is located on

Public Class Methods

new(str) click to toggle source

Creates a Bio::GFF::Record object. Is typically not called directly, but is called automatically when creating a Bio::GFF object.


Arguments:

  • str: a tab-delimited line in GFF format

    # File lib/bio/db/gff.rb
125 def initialize(str)
126   @comment = str.chomp[/#.*/]
127   return if /^#/.match(str)
128   @seqname, @source, @feature, @start, @end, @score, @strand, @frame,
129     attributes, = str.chomp.split("\t")
130   @attributes = parse_attributes(attributes) if attributes
131 end

Public Instance Methods

comments() click to toggle source

“comments” is deprecated. Instead, use “comment”.

    # File lib/bio/db/gff.rb
109 def comments
110   #warn "#{self.class.to_s}#comments is deprecated. Instead, use \"comment\"." if $VERBOSE
111   self.comment
112 end
comments=(str) click to toggle source

“comments=” is deprecated. Instead, use “comment=”.

    # File lib/bio/db/gff.rb
115 def comments=(str)
116   #warn "#{self.class.to_s}#comments= is deprecated. Instead, use \"comment=\"." if $VERBOSE
117   self.comment = str
118 end

Private Instance Methods

parse_attributes(attributes) click to toggle source
    # File lib/bio/db/gff.rb
135 def parse_attributes(attributes)
136   hash = Hash.new
137 
138   sc = StringScanner.new(attributes)
139   attrs = []
140   token = ''
141   while !sc.eos?
142     if sc.scan(/[^\\\;\"]+/) then
143       token.concat sc.matched
144     elsif sc.scan(/\;/) then
145       attrs.push token unless token.empty?
146       token = ''
147     elsif sc.scan(/\"/) then
148       origtext = sc.matched
149       while !sc.eos?
150         if sc.scan(/[^\\\"]+/) then
151           origtext.concat sc.matched
152         elsif sc.scan(/\"/) then
153           origtext.concat sc.matched
154           break
155         elsif sc.scan(/\\([\"\\])/) then
156           origtext.concat sc.matched
157         elsif sc.scan(/\\/) then
158           origtext.concat sc.matched
159         else
160           raise 'Bug: should not reach here'
161         end
162       end
163       token.concat origtext
164     elsif sc.scan(/\\\;/) then
165       token.concat sc.matched
166     elsif sc.scan(/\\/) then
167       token.concat sc.matched
168     else
169       raise 'Bug: should not reach here'
170     end #if
171   end #while
172   attrs.push token unless token.empty?
173 
174   attrs.each do |x|
175     key, value = x.split(' ', 2)
176     key.strip!
177     value.strip! if value
178     hash[key] = value
179   end
180   hash
181 end