class Gff_dataset
Attributes
index[RW]
master_features[RW]
Public Class Methods
new()
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 6 def initialize @master_features={} @index={} end
Public Instance Methods
add_feature(source, type, start, stop, score, strand, phase, attribs)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 44 def add_feature(source, type, start, stop, score, strand, phase, attribs) feature=@index[attribs['Parent']].add_child(source, type, start, stop, score, strand, phase, attribs) if !attribs['ID'].nil? @index[attribs['ID']]=feature else @index[feature.attrib('Parent')+'_'+@@undefined_features.to_s]=feature @@undefined_features+=1 end return feature end
add_master_feature(master_seq_id, source, type, start, stop, score, strand, phase, attribs)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 20 def add_master_feature(master_seq_id, source, type, start, stop, score, strand, phase, attribs) master=nil if @index.key?(master_seq_id)#Check that feature region exists, if exists add master feature like a child of that region attribs['Parent']=master_seq_id master=add_feature(source, type, start, stop, score, strand, phase, attribs) @index[attribs['ID']]=master if stop.to_i > @master_features[master_seq_id].stop #Redefine master_feature with new child @master_features[master_seq_id].stop=stop.to_i end elsif attribs['ID']==master_seq_id #Check that exists a parent region for master_feature master=Master_feature.new(source, type, start, stop, score, strand, phase, attribs) @master_features[master_seq_id]=master @index[master_seq_id]=master else #Creates a master feature with his child if it'sn defined master_feature master=Master_feature.new(source, 'region', 1, stop, '.', '.', '.', {'ID'=> master_seq_id}) @master_features[master_seq_id]=master @index[master_seq_id]=master attribs['Parent']=master_seq_id child=master.add_child(source, type, start, stop, score, strand, phase, attribs) @index[attribs['ID']]=child end return master end
add_parent_to(type_parent,type_child)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 137 def add_parent_to(type_parent,type_child) each_id_feat {|id,feature| if feature.type==type_child new_feature=Feature.new(feature.source, type_parent, feature.start, feature.stop, '.', feature.strand, '.', feature.attribs.dup) feature.change_to_type_id_recursive new_feature.transfer_child(feature.attrib('ID'),feature) @index[feature.attrib('Parent')].child[id]=new_feature @index[id]=new_feature new_feature.each_child {|child| child.attribs['Parent']=new_feature.attrib('ID') #Define new parent } end } end
each_feature() { |feature| ... }
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 55 def each_feature @index.each_value do |feature| yield feature end end
each_id_feat() { |id,feature| ... }
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 67 def each_id_feat @index.each do |id,feature| yield id,feature end end
each_id_master() { |id,master| ... }
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 73 def each_id_master @master_features.each do |id,master| yield id,master end end
each_master_feature() { |master_feature| ... }
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 61 def each_master_feature @master_features.each_value do |master_feature| yield master_feature end end
feature(hash_key)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 85 def feature(hash_key) return @index[hash_key] end
get(source=FALSE, type=FALSE)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 111 def get(source=FALSE, type=FALSE) features=[] @index.each_value do |feature| s=TRUE if source s=feature.is_source?(source) end t=TRUE if type t=feature.is_type?(type) end if s&t==TRUE features << feature end end return features end
has_source?(source)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 100 def has_source?(source) has_source=FALSE @index.each_value do |feature| if feature.source==source has_source=TRUE break end end return has_source end
has_type?(type)
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 89 def has_type?(type) has_type=FALSE @index.each_value do |feature| if feature.type==type has_type=TRUE break end end return has_type end
inspects()
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 79 def inspects @master_features.each do |item| item[1].inspects end end
tree()
click to toggle source
# File lib/gene_assembler/gff_dataset.rb, line 130 def tree @master_features.each_value do |master| master.tree puts "\n",'--------------------------------' end end