class Bio::GFF::GFF2

DESCRIPTION

Represents version 2 of GFF specification. Its behavior is somehow different from Bio::GFF, especially for attributes.

Constants

VERSION

Attributes

gff_version[R]

GFF2 version string (String or nil). nil means “2”.

metadata[RW]

Metadata (except “##gff-version”). Must be an array of Bio::GFF::GFF2::MetaData objects.

Public Class Methods

new(str = nil) click to toggle source

Creates a Bio::GFF::GFF2 object by building a collection of Bio::GFF::GFF2::Record (and metadata) objects.


Arguments:

  • str: string in GFF format

Returns

Bio::GFF::GFF2 object

# File lib/bio/db/gff.rb, line 822
def initialize(str = nil)
  @gff_version = nil
  @records = []
  @metadata = []
  parse(str) if str
end

Public Instance Methods

parse(str) click to toggle source

Parses a GFF2 entries, and concatenated the parsed data.


Arguments:

  • str: string in GFF format

Returns

self

# File lib/bio/db/gff.rb, line 842
def parse(str)
  # parses GFF lines
  str.each_line do |line|
    if /^\#\#([^\s]+)/ =~ line then
      parse_metadata($1, line)
    else
      @records << GFF2::Record.new(line)
    end
  end
  self
end
to_s() click to toggle source

string representation of the whole entry.

# File lib/bio/db/gff.rb, line 193
def to_s
  ver = @gff_version || VERSION.to_s
  ver = ver.gsub(/[\r\n]+/, ' ')
  ([ "##gff-version #{ver}\n" ] +
   @metadata.collect { |m| m.to_s } +
   @records.collect{ |r| r.to_s }).join('')
end