class Bio::GFF::GFF3
DESCRIPTION¶ ↑
Represents version 3 of GFF
specification. For more information on version GFF3
, see song.sourceforge.net/gff3.shtml
Constants
Attributes
GFF3
version string (String or nil). nil means “3”.
Metadata (except “##sequence-region”, “##gff-version”, “###”). Must be an array of Bio::GFF::GFF3::MetaData
objects.
Metadata of “##sequence-region”. Must be an array of Bio::GFF::GFF3::SequenceRegion
objects.
Sequences bundled within GFF3
. Must be an array of Bio::Sequence
objects.
Public Class Methods
Source
# File lib/bio/db/gff.rb 878 def initialize(str = nil) 879 @gff_version = nil 880 @records = [] 881 @sequence_regions = [] 882 @metadata = [] 883 @sequences = [] 884 @in_fasta = false 885 parse(str) if str 886 end
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
Public Instance Methods
Source
# File lib/bio/db/gff.rb 912 def parse(str) 913 # if already after the ##FASTA line, parses fasta format and return 914 if @in_fasta then 915 parse_fasta(str) 916 return self 917 end 918 919 if str.respond_to?(:gets) then 920 # str is a IO-like object 921 fst = nil 922 else 923 # str is a String 924 gff, sep, fst = str.split(/^(\>|##FASTA.*)/n, 2) 925 fst = sep + fst if sep == '>' and fst 926 str = gff 927 end 928 929 # parses GFF lines 930 str.each_line do |line| 931 if /^\#\#([^\s]+)/ =~ line then 932 parse_metadata($1, line) 933 parse_fasta(str) if @in_fasta 934 elsif /^\>/ =~ line then 935 @in_fasta = true 936 parse_fasta(str, line) 937 else 938 @records << GFF3::Record.new(line) 939 end 940 end 941 942 # parses fasta format when str is a String and fasta data exists 943 if fst then 944 @in_fasta = true 945 parse_fasta(fst) 946 end 947 948 self 949 end
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 967 def to_s 968 ver = @gff_version || VERSION.to_s 969 if @sequences.size > 0 then 970 seqs = "##FASTA\n" + 971 @sequences.collect { |s| s.to_fasta(s.entry_id, 70) }.join('') 972 else 973 seqs = '' 974 end 975 976 ([ "##gff-version #{escape(ver)}\n" ] + 977 @metadata.collect { |m| m.to_s } + 978 @sequence_regions.collect { |m| m.to_s } + 979 @records.collect{ |r| r.to_s }).join('') + seqs 980 end
string representation of whole entry.