Bioinformatics/Sequence mutation: Difference between revisions

Content added Content deleted
(Changing the representation of a DNA sequence from a sequence of Base to a string, as requested. Updated procedures to work with a string rather than a sequence.)
m (Replaced the ugly "ord(Base.other) - 1" by "MaxBaseVal".)
Line 1,459: Line 1,459:


of mutSwap:
of mutSwap:
let newBase = Base(rand(ord(Base.Other) - 1))
let newBase = Base(rand(MaxBaseVal))
echo fmt"Changing base at position {idx + 1} from {dnaSeq[idx]} to {newBase}"
echo fmt"Changing base at position {idx + 1} from {dnaSeq[idx]} to {newBase}"
dnaSeq[idx] = newBase.toChar
dnaSeq[idx] = newBase.toChar
Line 1,468: Line 1,468:


of mutInsert:
of mutInsert:
let newBase = Base(rand(ord(Base.Other) - 1))
let newBase = Base(rand(MaxBaseVal))
echo fmt"Inserting base {newBase} at position {idx + 1}"
echo fmt"Inserting base {newBase} at position {idx + 1}"
dnaSeq.insert($newBase, idx)
dnaSeq.insert($newBase, idx)