Class | Bio::GFF::GFF3 |
In: |
lib/bio/db/gff.rb
|
Parent: | GFF |
Represents version 3 of GFF specification. For more information on version GFF3, see song.sourceforge.net/gff3.shtml
VERSION | = | 3 | ||
MetaData | = | GFF2::MetaData | stores GFF3 MetaData |
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. |
Creates a Bio::GFF::GFF3 object by building a collection of Bio::GFF::GFF3::Record (and metadata) objects.
Arguments:
Returns: | Bio::GFF object |
# File lib/bio/db/gff.rb, line 874 874: def initialize(str = nil) 875: @gff_version = nil 876: @records = [] 877: @sequence_regions = [] 878: @metadata = [] 879: @sequences = [] 880: @in_fasta = false 881: parse(str) if str 882: end
Parses a GFF3 entries, and concatenated the parsed data.
Note that after "#FASTA" line is given, only fasta-formatted text is accepted.
Arguments:
Returns: | self |
# File lib/bio/db/gff.rb, line 908 908: def parse(str) 909: # if already after the ##FASTA line, parses fasta format and return 910: if @in_fasta then 911: parse_fasta(str) 912: return self 913: end 914: 915: if str.respond_to?(:gets) then 916: # str is a IO-like object 917: fst = nil 918: else 919: # str is a String 920: gff, sep, fst = str.split(/^(\>|##FASTA.*)/n, 2) 921: fst = sep + fst if sep == '>' and fst 922: str = gff 923: end 924: 925: # parses GFF lines 926: str.each_line do |line| 927: if /^\#\#([^\s]+)/ =~ line then 928: parse_metadata($1, line) 929: parse_fasta(str) if @in_fasta 930: elsif /^\>/ =~ line then 931: @in_fasta = true 932: parse_fasta(str, line) 933: else 934: @records << GFF3::Record.new(line) 935: end 936: end 937: 938: # parses fasta format when str is a String and fasta data exists 939: if fst then 940: @in_fasta = true 941: parse_fasta(fst) 942: end 943: 944: self 945: end
string representation of whole entry.
# File lib/bio/db/gff.rb, line 963 963: def to_s 964: ver = @gff_version || VERSION.to_s 965: if @sequences.size > 0 then 966: seqs = "##FASTA\n" + 967: @sequences.collect { |s| s.to_fasta(s.entry_id, 70) }.join('') 968: else 969: seqs = '' 970: end 971: 972: ([ "##gff-version #{escape(ver)}\n" ] + 973: @metadata.collect { |m| m.to_s } + 974: @sequence_regions.collect { |m| m.to_s } + 975: @records.collect{ |r| r.to_s }).join('') + seqs 976: end