Bioinformatics/Sequence mutation: Difference between revisions
Content added Content deleted
(julia example) |
|||
Line 475: | Line 475: | ||
=={{header|Julia}}== |
=={{header|Julia}}== |
||
<lang julia>dnabases = ['A', 'C', 'G', 'T'] |
<lang julia>dnabases = ['A', 'C', 'G', 'T'] |
||
randpos(seq) = rand(1:length |
randpos(seq) = rand(1:length(seq) # 1 |
||
mutateat(pos, seq) = (s = seq[:]; s[pos] = rand(dnabases); s) # 2-1 |
mutateat(pos, seq) = (s = seq[:]; s[pos] = rand(dnabases); s) # 2-1 |
||
deleteat(pos, seq) = [seq[1:pos-1]; seq[pos+1:end]] # 2-2 |
deleteat(pos, seq) = [seq[1:pos-1]; seq[pos+1:end]] # 2-2 |
||
Line 489: | Line 489: | ||
function weightedrandomsitemutation(seq, weights=[1, 1, 1], verbose=true) |
function weightedrandomsitemutation(seq, weights=[1, 1, 1], verbose=true) |
||
position = |
position = randpos(seq) |
||
newseq = weightedmutation(seq, position, weights, verbose) |
newseq = weightedmutation(seq, position, weights, verbose) |
||
verbose && println(" at position $position") |
verbose && println(" at position $position") |
||
Line 587: | Line 587: | ||
Total 502 |
Total 502 |
||
</pre> |
</pre> |
||
=={{header|Perl}}== |
=={{header|Perl}}== |