Class | Bio::GFF::GFF2
In: | lib/bio/db/gff.rb
Parent: | GFF

# DESCRIPTION

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

### Methods

new parse to_s

### Classes and Modules

Module Bio::GFF::GFF2::Escape
Class Bio::GFF::GFF2::MetaData
Class Bio::GFF::GFF2::Record

### Constants

VERSION | = | 2

### 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)

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

[Source]

         # File lib/bio/db/gff.rb, line 823
    823:       def initialize(str = nil)
    824:         @gff_version = nil
    825:         @records = []
    826:         @metadata = []
    827:         parse(str) if str
    828:       end

### Public Instance methods

parse(str)

Parses a GFF2 entries, and concatenated the parsed data.

Arguments:

- str: string in GFF format

Returns: | self

[Source]

         # File lib/bio/db/gff.rb, line 843
    843:       def parse(str)
    844:         # parses GFF lines
    845:         str.each_line do |line|
    846:           if /^\#\#([^\s]+)/ =~ line then
    847:             parse_metadata($1, line)
    848:           else
    849:             @records << GFF2::Record.new(line)
    850:           end
    851:         end
    852:         self
    853:       end

to_s()

string representation of the whole entry.

[Source]

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

[Validate]