Class: Bio::GFF::GFF2
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
- VERSION =
2
Instance Attribute Summary (collapse)
-
- (Object) gff_version
readonly
GFF2 version string (String or nil).
-
- (Object) metadata
Metadata (except "##gff-version").
Attributes inherited from Bio::GFF
Instance Method Summary (collapse)
-
- (GFF2) initialize(str = nil)
constructor
Creates a Bio::GFF::GFF2 object by building a collection of Bio::GFF::GFF2::Record (and metadata) objects.
-
- (Object) parse(str)
Parses a GFF2 entries, and concatenated the parsed data.
-
- (Object) to_s
string representation of the whole entry.
Constructor Details
- (GFF2) initialize(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 |
822 823 824 825 826 827 |
# File 'lib/bio/db/gff.rb', line 822 def initialize(str = nil) @gff_version = nil @records = [] @metadata = [] parse(str) if str end |
Instance Attribute Details
- (Object) gff_version (readonly)
GFF2 version string (String or nil). nil means "2".
830 831 832 |
# File 'lib/bio/db/gff.rb', line 830 def gff_version @gff_version end |
- (Object) metadata
Metadata (except "##gff-version"). Must be an array of Bio::GFF::GFF2::MetaData objects.
834 835 836 |
# File 'lib/bio/db/gff.rb', line 834 def @metadata end |
Instance Method Details
- (Object) parse(str)
Parses a GFF2 entries, and concatenated the parsed data.
Arguments:
-
str: string in GFF format
Returns |
self |
842 843 844 845 846 847 848 849 850 851 852 |
# File 'lib/bio/db/gff.rb', line 842 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 |
- (Object) to_s
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" ] + @metadata.collect { |m| m.to_s } + @records.collect{ |r| r.to_s }).join('') end |