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

DESCRIPTION

Represents version 3 of GFF specification. For more information on version GFF3, see song.sourceforge.net/gff3.shtml

Methods

new   parse   to_s  

Included Modules

Escape

Classes and Modules

Module Bio::GFF::GFF3::Escape
Class Bio::GFF::GFF3::Record
Class Bio::GFF::GFF3::RecordBoundary
Class Bio::GFF::GFF3::SequenceRegion

Constants

VERSION = 3
MetaData = GFF2::MetaData   stores GFF3 MetaData

Attributes

gff_version  [R]  GFF3 version string (String or nil). nil means "3".
metadata  [RW]  Metadata (except "#sequence-region", "#gff-version", "###"). Must be an array of Bio::GFF::GFF3::MetaData objects.
sequence_regions  [RW]  Metadata of "#sequence-region". Must be an array of Bio::GFF::GFF3::SequenceRegion objects.
sequences  [RW]  Sequences bundled within GFF3. Must be an array of Bio::Sequence objects.

Public Class methods

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


Arguments:

  • str: string in GFF format
Returns:Bio::GFF object

[Source]

     # File lib/bio/db/gff.rb, line 875
875:       def initialize(str = nil)
876:         @gff_version = nil
877:         @records = []
878:         @sequence_regions = []
879:         @metadata = []
880:         @sequences = []
881:         @in_fasta = false
882:         parse(str) if str
883:       end

Public Instance methods

Parses a GFF3 entries, and concatenated the parsed data.

Note that after "#FASTA" line is given, only fasta-formatted text is accepted.


Arguments:

  • str: string in GFF format
Returns:self

[Source]

     # File lib/bio/db/gff.rb, line 909
909:       def parse(str)
910:         # if already after the ##FASTA line, parses fasta format and return
911:         if @in_fasta then
912:           parse_fasta(str)
913:           return self
914:         end
915: 
916:         if str.respond_to?(:gets) then
917:           # str is a IO-like object
918:           fst = nil
919:         else
920:           # str is a String
921:           gff, sep, fst = str.split(/^(\>|##FASTA.*)/n, 2)
922:           fst = sep + fst if sep == '>' and fst
923:           str = gff
924:         end
925: 
926:         # parses GFF lines
927:         str.each_line do |line|
928:           if /^\#\#([^\s]+)/ =~ line then
929:             parse_metadata($1, line)
930:             parse_fasta(str) if @in_fasta
931:           elsif /^\>/ =~ line then
932:             @in_fasta = true
933:             parse_fasta(str, line)
934:           else
935:             @records << GFF3::Record.new(line)
936:           end
937:         end
938: 
939:         # parses fasta format when str is a String and fasta data exists
940:         if fst then
941:           @in_fasta = true
942:           parse_fasta(fst)
943:         end
944: 
945:         self
946:       end

string representation of whole entry.

[Source]

     # File lib/bio/db/gff.rb, line 964
964:       def to_s
965:         ver = @gff_version || VERSION.to_s
966:         if @sequences.size > 0 then
967:           seqs = "##FASTA\n" +
968:             @sequences.collect { |s| s.to_fasta(s.entry_id, 70) }.join('')
969:         else
970:           seqs = ''
971:         end
972: 
973:         ([ "##gff-version #{escape(ver)}\n" ] +
974:          @metadata.collect { |m| m.to_s } +
975:          @sequence_regions.collect { |m| m.to_s } +
976:          @records.collect{ |r| r.to_s }).join('') + seqs
977:       end

[Validate]