Method: String#mutation
- Defined in:
- lib/viral_seq/string.rb
#mutation(error_rate = 0.01) ⇒ String
mutate a nt sequence (String class) randomly
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/viral_seq/string.rb', line 23 def mutation(error_rate = 0.01) new_string = "" self.split("").each do |nt| pool = ["A","C","T","G"] pool.delete(nt) s = error_rate * 10000 r = rand(10000) if r < s nt = pool.sample end new_string << nt end return new_string end |