Class: Bio::GFF::GFF2

Inherits:
Bio::GFF show all
Defined in:
lib/bio/db/gff.rb

Overview

DESCRIPTION

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

Defined Under Namespace

Modules: Escape Classes: MetaData, Record

Constant Summary collapse

VERSION =
2

Instance Attribute Summary collapse

Attributes inherited from Bio::GFF

#records

Instance Method Summary collapse

Constructor Details

#initialize(str = nil) ⇒ GFF2

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



825
826
827
828
829
830
# File 'lib/bio/db/gff.rb', line 825

def initialize(str = nil)
  @gff_version = nil
  @records = []
   = []
  parse(str) if str
end

Instance Attribute Details

#gff_versionObject (readonly)

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



833
834
835
# File 'lib/bio/db/gff.rb', line 833

def gff_version
  @gff_version
end

#metadataObject

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



837
838
839
# File 'lib/bio/db/gff.rb', line 837

def 
  
end

Instance Method Details

#parse(str) ⇒ Object

Parses a GFF2 entries, and concatenated the parsed data.


Arguments:

  • str: string in GFF format

Returns

self



845
846
847
848
849
850
851
852
853
854
855
# File 'lib/bio/db/gff.rb', line 845

def parse(str)
  # parses GFF lines
  str.each_line do |line|
    if /^\#\#([^\s]+)/ =~ line then
      ($1, line)
    else
      @records << GFF2::Record.new(line)
    end
  end
  self
end

#to_sObject

string representation of the whole entry.



194
195
196
197
198
199
200
# File 'lib/bio/db/gff.rb', line 194

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