Class Bio::Features
In: lib/bio/compat/features.rb
Parent: Object

DESCRIPTION

This class is OBSOLETED, and will soon be removed. Instead of this class, an array is to be used.

Container for a list of Feature objects.

USAGE

 # First, create some Bio::Feature objects
 feature1 = Bio::Feature.new('intron','3627..4059')
 feature2 = Bio::Feature.new('exon','4060..4236')
 feature3 = Bio::Feature.new('intron','4237..4426')
 feature4 = Bio::Feature.new('CDS','join(2538..3626,4060..4236)',
                  [ Bio::Feature::Qualifier.new('gene', 'CYP2D6'),
                    Bio::Feature::Qualifier.new('translation','MGXXTVMHLL...')
                  ])

 # And create a container for them
 feature_container = Bio::Features.new([ feature1, feature2, feature3, feature4 ])

 # Iterate over all features and print
 feature_container.each do |feature|
   puts feature.feature + "\t" + feature.position
   feature.each do |qualifier|
     puts "- " + qualifier.qualifier + ": " + qualifier.value
   end
 end

 # Iterate only over CDS features and extract translated amino acid sequences
 features.each("CDS") do |feature|
   hash = feature.to_hash
   name = hash["gene"] || hash["product"] || hash["note"]
   aaseq  = hash["translation"]
   pos  = feature.position
   if name and seq
     puts ">#{gene} #{feature.position}"
     puts aaseq
   end
 end

Methods

[]   append   each   first   last   new   new  

Attributes

features  [RW]  Returns an Array of Feature objects.

Public Class methods

Normally, users can not call this method.

Create a new Bio::Features object.

Arguments:

  • (optional) _list of features_: list of Bio::Feature objects
Returns:Bio::Features object

[Source]

     # File lib/bio/compat/features.rb, line 111
111:   def initialize(ary = [])
112:     @features = ary
113:   end

This method should not be used. Only for backward compatibility of existing code.

Since Bio::Features is obsoleted, Bio::Features.new not returns Bio::Features object, but modifies given ary and returns the ary.

Arguments:

Returns:the given array

[Source]

     # File lib/bio/compat/features.rb, line 98
 98:   def self.new(ary = [])
 99:     warn 'Bio::Features is obsoleted. Some methods are added to given array to keep backward compatibility.'
100:     ary.extend(BackwardCompatibility)
101:     ary
102:   end

Public Instance methods

Short cut for the Features#features[n]

[Source]

     # File lib/bio/compat/features.rb, line 140
140:   def [](*arg)
141:     @features[*arg]
142:   end

Appends a Feature object to Features.

Arguments:

Returns:Bio::Features object

[Source]

     # File lib/bio/compat/features.rb, line 123
123:   def append(a)
124:     @features.push(a) if a.is_a? Feature
125:     return self
126:   end

Iterates on each feature object.

Arguments:

  • (optional) key: if specified, only iterates over features with this key

[Source]

     # File lib/bio/compat/features.rb, line 132
132:   def each(arg = nil)
133:     @features.each do |x|
134:       next if arg and x.feature != arg
135:       yield x
136:     end
137:   end

Short cut for the Features#features.first

[Source]

     # File lib/bio/compat/features.rb, line 145
145:   def first
146:     @features.first
147:   end

Short cut for the Features#features.last

[Source]

     # File lib/bio/compat/features.rb, line 150
150:   def last
151:     @features.last
152:   end

[Validate]