Method: Bio::Sequence::AA.randomize
- Defined in:
- lib/bio/sequence/compat.rb
.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 |