Class | Bio::Sequence::AA
In: | lib/bio/sequence/aa.rb lib/bio/sequence/compat.rb
Parent: | String

# DESCRIPTION

Bio::Sequence::AA represents a bare Amino Acid sequence in bioruby.

# USAGE

      # Create an Amino Acid sequence.
      aa = Bio::Sequence::AA.new('ACDEFGHIKLMNPQRSTVWYU')

      # What are the three-letter codes for all the residues?
      puts aa.codes

      # What are the names of all the residues?
      puts aa.names

      # What is the molecular weight of this peptide?
      puts aa.molecular_weight

### Methods

codes molecular_weight names new randomize to_re

### Included Modules

Bio::Sequence::Common

### Public Class methods

new(str)

Generate an amino acid sequence object from a string.

      s = Bio::Sequence::AA.new("RRLEHTFVFLRNFSLMLLRY")

or maybe (if you have an amino acid sequence in a file)

      s = Bio::Sequence:AA.new(File.open('aa.txt').read)

Amino Acid sequences are always all uppercase in bioruby

      s = Bio::Sequence::AA.new("rrLeHtfV")
      puts s                                  #=> "RRLEHTFVF"

Whitespace is stripped from the sequence

      s = Bio::Sequence::AA.new("RRL\nELA\tRG\r  RL")
      puts s                                  #=> "RRLELARGRL"

Arguments:

- (required) str: String

Returns: | Bio::Sequence::AA object

[Source]

        # File lib/bio/sequence/aa.rb, line 60
    60:   def initialize(str)
    61:     super
    62:     self.upcase!
    63:     self.tr!(" \t\n\r",'')
    64:   end

randomize(*arg, &block)

Generate a new random sequence with the given frequency of bases. The sequence length is determined by their cumulative sum. (See also Bio::Sequence::Common#randomize which creates a new randomized sequence object using the base composition of an existing sequence instance).

      counts = {'R'=>1,'L'=>2,'E'=>3,'A'=>4}
      puts Bio::Sequence::AA.randomize(counts)  #=> "AAEAELALRE" (for example)

You may also feed the output of randomize into a block

      actual_counts = {'R'=>0,'L'=>0,'E'=>0,'A'=>0}
      Bio::Sequence::AA.randomize(counts) {|x| actual_counts[x] += 1}
      actual_counts                     #=> {"A"=>4, "L"=>2, "E"=>3, "R"=>1}

Arguments:

- (optional) hash: Hash object

Returns: | Bio::Sequence::AA object

[Source]

         # File lib/bio/sequence/compat.rb, line 118
    118:   def self.randomize(*arg, &block)
    119:     self.new('').randomize(*arg, &block)
    120:   end

### Public Instance methods

codes()

Generate the list of the names of each residue along with the sequence (3 letters code). Codes used in bioruby are found in the Bio::AminoAcid::NAMES hash.

      s = Bio::Sequence::AA.new("RRLE")
      puts s.codes                        #=> ["Arg", "Arg", "Leu", "Glu"]

Returns: | Array object

[Source]

         # File lib/bio/sequence/aa.rb, line 97
     97:   def codes
     98:     array = []
     99:     self.each_byte do |x|
    100:       array.push(Bio::AminoAcid.names[x.chr])
    101:     end
    102:     return array
    103:   end

molecular_weight()

Estimate molecular weight based on Fasman1976

      s = Bio::Sequence::AA.new("RRLE")
      puts s.molecular_weight             #=> 572.655

Returns: | Float object

[Source]

        # File lib/bio/sequence/aa.rb, line 74
    74:   def molecular_weight
    75:     Bio::AminoAcid.weight(self)
    76:   end

names()

Generate the list of the names of each residue along with the sequence (full name). Names used in bioruby are found in the Bio::AminoAcid::NAMES hash.

      s = Bio::Sequence::AA.new("RRLE")
      puts s.names
                  #=> ["arginine", "arginine", "leucine", "glutamic acid"]

Returns: | Array object

[Source]

         # File lib/bio/sequence/aa.rb, line 114
    114:   def names
    115:     self.codes.map do |x|
    116:       Bio::AminoAcid.names[x]
    117:     end
    118:   end

to_re()

Create a ruby regular expression instance (Regexp)

      s = Bio::Sequence::AA.new("RRLE")
      puts s.to_re                        #=> /RRLE/

Returns: | Regexp object

[Source]

        # File lib/bio/sequence/aa.rb, line 85
    85:   def to_re
    86:     Bio::AminoAcid.to_re(self)
    87:   end

[Validate]