Method: Bio::Sequence::Common#composition
- Defined in:
- lib/bio/sequence/common.rb
#composition ⇒ Object
Returns a hash of the occurrence counts for each residue or base.
s = Bio::Sequence::NA.new('atgc')
puts s.composition #=> {"a"=>1, "c"=>1, "g"=>1, "t"=>1}
- Returns
-
Hash object
215 216 217 218 219 220 221 |
# File 'lib/bio/sequence/common.rb', line 215 def composition count = Hash.new(0) self.scan(/./) do |x| count[x] += 1 end return count end |