Bioinformatics/Sequence mutation: Difference between revisions
m
syntax highlighting fixup automation
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
|||
Line 19:
{{trans|Python}}
<
F nonrandom(n)
:seed = 1664525 * :seed + 1013904223
Line 69:
print(‘ #10 @#.’.format(kind, index))
print()
seq_pp(mseq)</
{{out}}
Line 115:
=={{header|Ada}}==
<
with Ada.Numerics.Discrete_Random;
with Ada.Text_Io;
Line 231:
Pretty_Print (Sequence);
end Mutations;</
{{out}}
<pre>Initial sequence:
Line 267:
=={{header|Arturo}}==
<
dna: map 1..200 => [sample bases]
Line 334:
print "------------------------------"
prettyPrint dna
print ""</
{{out}}
Line 373:
=={{header|C}}==
Adenine ( A ) is always swapped for Thymine ( T ) and vice versa. Similarly with Cytosine ( C ) and Guanine ( G ).
<syntaxhighlight lang=C>
#include<stdlib.h>
#include<stdio.h>
Line 585:
return 0;
}
</syntaxhighlight>
Sample run :
<pre>
Line 674:
=={{header|C++}}==
<
#include <iomanip>
#include <iostream>
Line 797:
sequence_generator::print_sequence(std::cout, sequence);
return 0;
}</
{{out}}
Line 836:
:: :genome <i><Genome Sequence></i>)
<b>All keys are optional. <i><Genome length></i> is discarded when :genome is set.</b>
<
(defun random_base ()
(random 4))
Line 910:
(t (delete_base genome)))))
(output_genome_info genome "MUTATED"))
</syntaxhighlight>
{{out}}
<pre>
Line 981:
=={{header|Factor}}==
<
macros math math.statistics namespaces prettyprint quotations
random sequences sorting ;
Line 1,054:
[ mutate ] curry times nl "MUTATED " write show-dna ;
MAIN: main</
{{out}}
<pre>
Line 1,103:
=={{header|Go}}==
<
import (
Line 1,201:
fmt.Println()
prettyPrint(dna, 50)
}</
{{out}}
Line 1,257:
</pre>
=={{header|Haskell}}==
<
import Data.List.Split (chunksOf)
import System.Random (Random, randomR, random, newStdGen, randoms, getStdRandom)
Line 1,336:
showSequence = mapM_ (uncurry (printf "%3d: %s\n")) . chunkedDNASequence
showBaseCounts = mapM_ (uncurry (printf "%s: %3d\n")) . baseCounts
showSumBaseCounts xs = putStrLn (replicate 6 '-') >> printf "Σ: %d\n\n" (length xs)</
{{out}}
<pre>Initial Sequence:
Line 1,379:
=={{header|J}}==
<
MUTS=: ;: 'del ins mut'
Line 1,414:
)
simulate=: (sim@(1 1 1&; &. |. ))`sim@.(3=#)</
{{out}}
Line 1,508:
=={{header|Java}}==
<
import java.util.Random;
Line 1,620:
private static final int OP_COUNT = 3;
private static final char[] BASES = {'A', 'C', 'G', 'T'};
}</
{{out}}
Line 1,654:
=={{header|JavaScript}}==
<
const numBases = 250
const numMutations = 30
Line 1,811:
console.log('\nMUTATED BASE COUNTS:')
printBases(mut);
</syntaxhighlight>
{{out}}
Line 1,878:
=={{header|Julia}}==
<
randpos(seq) = rand(1:length(seq)) # 1
mutateat(pos, seq) = (s = seq[:]; s[pos] = rand(dnabases); s) # 2-1
Line 1,931:
testbioseq()
</
<pre>
500nt DNA sequence:
Line 1,994:
=={{header|Lua}}==
Using the <code>prettyprint()</code> function from [[Bioinformatics/base_count#Lua]] (not replicated here)
<
bases = {"A","C","T","G"}
function randbase() return bases[math.random(#bases)] end
Line 2,022:
print("MUTATED:")
prettyprint(seq)</
{{out}}
<pre>ORIGINAL:
Line 2,056:
=={{header|Mathematica}} / {{header|Wolfram Language}}==
BioSequence is a fundamental data type in Mathematica:
<
seq = BioSequence["DNA", "ATAAACGTACGTTTTTAGGCT"];
randompos = RandomInteger[seq["SequenceLength"]];
Line 2,090:
ends = Rest[Accumulate[Prepend[StringLength /@ parts, 0]]];
StringRiffle[MapThread[ToString[#1] <> "-" <> ToString[#2] <> ": " <> #3 &, {begins, ends, parts}], "\n"]
Tally[Characters[seq["SequenceString"]]]</
{{out}}
<pre>1-50: TAGCAGGGGAATTGTCGACTCCCGGGTTTCAATTGCCAACCAAGCATATT
Line 2,106:
=={{header|Nim}}==
<
import strformat
import strutils
Line 2,222:
echo "\nMutated sequence"
echo "————————————————\n"
dnaSeq.display()</
{{out}}
Line 2,261:
=={{header|Perl}}==
{{trans|Raku}}
<
use warnings;
use feature 'say';
Line 2,305:
say "Total bases: ". length $mutate;
say "$_: $cnt{$_}" for @bases;
</syntaxhighlight>
{{out}}
<pre>Original DNA strand:
Line 2,332:
=={{header|Phix}}==
<!--<
<span style="color: #004080;">string</span> <span style="color: #000000;">dna</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">repeat</span><span style="color: #0000FF;">(</span><span style="color: #008000;">' '</span><span style="color: #0000FF;">,</span><span style="color: #000000;">200</span><span style="color: #0000FF;">+</span><span style="color: #7060A8;">rand</span><span style="color: #0000FF;">(</span><span style="color: #000000;">300</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">i</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dna</span><span style="color: #0000FF;">)</span> <span style="color: #008080;">do</span> <span style="color: #000000;">dna</span><span style="color: #0000FF;">[</span><span style="color: #000000;">i</span><span style="color: #0000FF;">]</span> <span style="color: #0000FF;">=</span> <span style="color: #008000;">"ACGT"</span><span style="color: #0000FF;">[</span><span style="color: #7060A8;">rand</span><span style="color: #0000FF;">(</span><span style="color: #000000;">4</span><span style="color: #0000FF;">)]</span> <span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
Line 2,368:
<span style="color: #000000;">mutate</span><span style="color: #0000FF;">()</span>
<span style="color: #000000;">show</span><span style="color: #0000FF;">()</span>
<!--</
{{out}}
<pre>
Line 2,410:
=={{header|PureBasic}}==
<
#SEQLEN=200
#PROTOCOL=#True
Line 2,467:
PrintN("After 10 mutations:")
pprint()
Input()</
{{out}}
<pre>Initial sequence:
Line 2,499:
Similarly parameter choice is chosen from to give the base for substitution or insertion - the more any base appears, the more likely it is to be chosen in any insertion/substitution.
<
from collections import Counter
Line 2,544:
print(f" {kind:>10} @{index}")
print()
seq_pp(mseq)</
{{out}}
Line 2,592:
<code>prettyprint</code> and <code>tallybases</code> are defined at [[Bioinformatics/base count#Quackery]].
<
[ $ "" swap times
Line 2,609:
cr cr say "Mutating..." cr
10 times mutate
dup prettyprint cr cr tallybases</
{{out}}
Line 2,643:
=={{header|Racket}}==
<
(define current-S-weight (make-parameter 1))
Line 2,720:
(define s+d (parameterize ((current-D-weight 5)) (for/fold ((s initial-sequence)) ((_ 10)) (mutate s))))
(newline)
(report-sequence s+d))</
{{out}}
Line 2,791:
<syntaxhighlight lang=raku
# The DNA strand
Line 2,822:
sub diff ($orig, $repl) {
($orig.comb Z $repl.comb).map( -> ($o, $r) { $o eq $r ?? $o !! $r.lc }).join
}</
{{out}}
<pre>ORIGINAL DNA STRAND:
Line 2,849:
=={{header|Ring}}==
<
row = 0
dnaList = []
Line 2,962:
total = dnaBase["A"] + dnaBase["T"] + dnaBase["C"] + dnaBase["G"]
see "Total: " + total+ nl + nl
</syntaxhighlight>
{{out}}
<pre>
Line 3,010:
=={{header|Ruby}}==
<
attr_accessor :seq
Line 3,044:
test.delete
puts test
</syntaxhighlight>
{{out}}
<pre> 0 TAAGGTGAGGAGTGTGATGGAGTTCGGTGGCTAGCCACAAATACAACACA
Line 3,067:
=={{header|Swift}}==
<
enum Action: CaseIterable {
Line 3,123:
}
printSeq(d)</
{{out}}
Line 3,154:
=={{header|Vlang}}==
{{trans|Go}}
<
import rand.seed
Line 3,246:
println('')
pretty_print(dna, 50)
}</
{{out}}
Line 3,306:
{{libheader|Wren-sort}}
{{libheader|Wren-fmt}}
<
import "/fmt" for Fmt
import "/sort" for Sort
Line 3,383:
for (i in 0...muts) dna = mutate.call(dna, w)
System.print()
prettyPrint.call(dna, 50)</
{{out}}
Line 3,441:
=={{header|Yabasic}}==
{{trans|Phix}}
<
// by Galileo, 07/2022
Line 3,493:
show()
mutate()
show()</
{{out}}
<pre>1: TCCATCGTGG GATCGCTCTA GCGGTATGCT ATCATTCCTA TAGCAATTCT
Line 3,528:
=={{header|zkl}}==
<
dna:=(190).pump(Data().howza(3),(0).random.fp(0,4),bases.get); // bucket of bytes
Line 3,560:
[0..*,50].zipWith(fcn(n,bases){ println("%6d: %s".fmt(n,bases.concat())) },
dna.walker().walk.fp(50)).pump(Void); // .pump forces the iterator
}</
{{out}}
<pre>
Line 3,590:
=={{header|Rust}}==
<
use rand::prelude::*;
use std::collections::HashMap;
Line 3,687:
println!("\nMutated sequence:\n{}", seq);
}
</syntaxhighlight>
{{out}}
<pre>
|