Class | Bio::Feature
In: | lib/bio/feature.rb
Parent: | Object

# 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

### Methods

[] append assoc each locations new to_hash

### Classes and Modules

Class Bio::Feature::Qualifier

### 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 = [])

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

[Source]

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

### Public Instance methods

[](key)

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

[Source]

         # File lib/bio/feature.rb, line 112
    112:   def [](key)
    113:     self.to_hash[key]
    114:   end

append(a)

Appends a Qualifier object to the Feature.

Arguments:

- (required) qualifier: Bio::Feature::Qualifier object

Returns: | Bio::Feature object

[Source]

        # File lib/bio/feature.rb, line 75
    75:   def append(a)
    76:     @qualifiers.push(a) if a.is_a? Qualifier
    77:     return self
    78:   end

assoc()

Returns a Hash constructed from qualifier objects.

[Source]

        # File lib/bio/feature.rb, line 92
    92:   def assoc
    93:     STDERR.puts "Bio::Feature#assoc is deprecated, use Bio::Feature#to_hash instead" if $DEBUG
    94:     hash = Hash.new
    95:     @qualifiers.each do |x|
    96:       hash[x.qualifier] = x.value
    97:     end
    98:     return hash
    99:   end

each(arg = nil) {|x| ...}

Iterates on each qualifier object.

Arguments:

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

[Source]

        # File lib/bio/feature.rb, line 84
    84:   def each(arg = nil)
    85:     @qualifiers.each do |x|
    86:       next if arg and x.qualifier != arg
    87:       yield x
    88:     end
    89:   end

locations()

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

[Source]

        # File lib/bio/feature.rb, line 66
    66:   def locations
    67:     Locations.new(@position)
    68:   end

to_hash()

Returns a Hash constructed from qualifier objects.

[Source]

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

[Validate]