class Bio::Feature

DESCRIPTION

Container for the sequence annotation.

USAGE

# Create a Bio::Feature object.
# For example: the GenBank-formatted entry in genbank for accession M33388
# contains the following feature:
#    exon     1532..1799
#             /gene="CYP2D6"
#             /note="cytochrome P450 IID6; GOO-132-127"
#             /number="1"
feature = Bio::Feature.new('exon','1532..1799')
feature.append(Bio::Feature::Qualifier.new('gene', 'CYP2D6'))
feature.append(Bio::Feature::Qualifier.new('note', 'cytochrome P450 IID6'))
feature.append(Bio::Feature::Qualifier.new('number', '1'))

# or all in one go:
feature2 = Bio::Feature.new('exon','1532..1799',
  [ Bio::Feature::Qualifier.new('gene', 'CYP2D6'),
    Bio::Feature::Qualifier.new('note', 'cytochrome P450 IID6; GOO-132-127'),
    Bio::Feature::Qualifier.new('number', '1')
  ])

# Print the feature
puts feature.feature + "\t" + feature.position
feature.each do |qualifier|
  puts "- " + qualifier.qualifier + ": " + qualifier.value
end

REFERENCES

INSD feature table definition

www.ddbj.nig.ac.jp/FT/full_index.html

Attributes

feature[RW]

Returns type of feature in String (e.g 'CDS', 'gene')

position[RW]

Returns position of the feature in String (e.g. 'complement(123..146)')

qualifiers[RW]

Returns an Array of Qualifier objects.

Public Class Methods

new(feature = '', position = '', qualifiers = []) click to toggle source

Create a new Bio::Feature object. Arguments:

  • (required) feature: type of feature (e.g. “exon”)

  • (required) position: position of feature (e.g. “complement(1532..1799)”)

  • (opt) qualifiers: list of Bio::Feature::Qualifier objects (default: [])

Returns

Bio::Feature object

   # File lib/bio/feature.rb
51 def initialize(feature = '', position = '', qualifiers = [])
52   @feature, @position, @qualifiers = feature, position, qualifiers
53 end

Public Instance Methods

[](key) click to toggle source

Short cut for the Bio::Feature#to_hash[key]

    # File lib/bio/feature.rb
111 def [](key)
112   self.to_hash[key]
113 end
append(a) click to toggle source

Appends a Qualifier object to the Feature.

Arguments:

Returns

Bio::Feature object

   # File lib/bio/feature.rb
74 def append(a)
75   @qualifiers.push(a) if a.is_a? Qualifier
76   return self
77 end
assoc() click to toggle source

Returns a Hash constructed from qualifier objects.

   # File lib/bio/feature.rb
91 def assoc
92   STDERR.puts "Bio::Feature#assoc is deprecated, use Bio::Feature#to_hash instead" if $DEBUG
93   hash = Hash.new
94   @qualifiers.each do |x|
95     hash[x.qualifier] = x.value
96   end
97   return hash
98 end
each(arg = nil) { |x| ... } click to toggle source

Iterates on each qualifier object.

Arguments:

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

   # File lib/bio/feature.rb
83 def each(arg = nil)
84   @qualifiers.each do |x|
85     next if arg and x.qualifier != arg
86     yield x
87   end
88 end
locations() click to toggle source

Returns a Bio::Locations object translated from the position string.

   # File lib/bio/feature.rb
65 def locations
66   Locations.new(@position)
67 end
to_hash() click to toggle source

Returns a Hash constructed from qualifier objects.

    # File lib/bio/feature.rb
101 def to_hash
102   hash = Hash.new
103   @qualifiers.each do |x|
104     hash[x.qualifier] ||= []
105     hash[x.qualifier] << x.value
106   end
107   return hash
108 end