Class: Bio::Sequence::AA
- Includes:
- Common
- Defined in:
- lib/bio/sequence/aa.rb,
lib/bio/sequence/compat.rb
Overview
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
Class Method Summary collapse
-
.randomize(*arg, &block) ⇒ Object
Generate a new random sequence with the given frequency of bases.
Instance Method Summary collapse
-
#codes ⇒ Object
Generate the list of the names of each residue along with the sequence (3 letters code).
-
#initialize(str) ⇒ AA
constructor
Generate an amino acid sequence object from a string.
-
#molecular_weight ⇒ Object
Estimate molecular weight based on Fasman1976.
-
#names ⇒ Object
Generate the list of the names of each residue along with the sequence (full name).
-
#to_re ⇒ Object
Create a ruby regular expression instance (Regexp) .
Methods included from Common
#+, #<<, #composition, #concat, #normalize!, #randomize, #seq, #splice, #subseq, #to_fasta, #to_s, #total, #window_search
Methods inherited from String
#fill, #fold, #skip, #step, #to_aaseq, #to_naseq
Constructor Details
#initialize(str) ⇒ AA
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
58 59 60 61 62 |
# File 'lib/bio/sequence/aa.rb', line 58 def initialize(str) super self.upcase! self.tr!(" \t\n\r",'') end |
Class Method Details
.randomize(*arg, &block) ⇒ Object
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
113 114 115 |
# File 'lib/bio/sequence/compat.rb', line 113 def self.randomize(*arg, &block) self.new('').randomize(*arg, &block) end |
Instance Method Details
#codes ⇒ Object
95 96 97 98 99 100 101 |
# File 'lib/bio/sequence/aa.rb', line 95 def codes array = [] self.each_byte do |x| array.push(Bio::AminoAcid.names[x.chr]) end return array end |
#molecular_weight ⇒ Object
Estimate molecular weight based on Fasman1976
s = Bio::Sequence::AA.new("RRLE")
puts s.molecular_weight #=> 572.655
- Returns
-
Float object
72 73 74 |
# File 'lib/bio/sequence/aa.rb', line 72 def molecular_weight Bio::AminoAcid.weight(self) end |