Bioinformatics/Sequence mutation: Difference between revisions
Content added Content deleted
(Ada version) |
No edit summary |
||
Line 2,346: | Line 2,346: | ||
Base counts: A:128, C:110, G:119, T:123, total:480 |
Base counts: A:128, C:110, G:119, T:123, total:480 |
||
</pre> |
</pre> |
||
=={{header|PureBasic}}== |
|||
<lang PureBasic>#BASE$="ACGT" |
|||
#SEQLEN=200 |
|||
#PROTOCOL=#True |
|||
Global dna.s |
|||
Define i.i |
|||
Procedure pprint() |
|||
Define p.i, cnt.i, sum.i |
|||
For p=1 To Len(dna) Step 50 |
|||
Print(RSet(Str(p-1)+": ",5)) |
|||
PrintN(Mid(dna,p,50)) |
|||
Next |
|||
PrintN("Base counts:") |
|||
For p=1 To 4 |
|||
cnt=CountString(dna,Mid(#BASE$,p,1)) : sum+cnt |
|||
Print(Mid(#BASE$,p,1)+": "+Str(cnt)+", ") |
|||
Next |
|||
PrintN("Total: "+Str(sum)) |
|||
EndProcedure |
|||
Procedure InsertAtPos(basenr.i,position.i) |
|||
If #PROTOCOL : PrintN("Insert base "+Mid(#BASE$,basenr,1)+" at position "+Str(position)) : EndIf |
|||
dna=InsertString(dna,Mid(#BASE$,basenr,1),position) |
|||
EndProcedure |
|||
Procedure EraseAtPos(position.i) |
|||
If #PROTOCOL : PrintN("Erase base "+Mid(dna,position,1)+" at position "+Str(position)) : EndIf |
|||
If position>0 And position<=Len(dna) |
|||
dna=Left(dna,position-1)+Right(dna,Len(dna)-position) |
|||
EndIf |
|||
EndProcedure |
|||
Procedure OverwriteAtPos(basenr.i,position.i) |
|||
If #PROTOCOL : PrintN("Change base at position "+Str(position)+" from "+Mid(dna,position,1)+" to "+Mid(#BASE$,basenr,1)) : EndIf |
|||
If position>0 And position<=Len(dna) |
|||
position-1 |
|||
PokeS(@dna+2*position,Mid(#BASE$,basenr,1),-1,#PB_String_NoZero) |
|||
EndIf |
|||
EndProcedure |
|||
If OpenConsole()=0 : End 1 : EndIf |
|||
For i=1 To #SEQLEN : dna+Mid(#BASE$,Random(4,1),1) : Next |
|||
PrintN("Initial sequence:") |
|||
pprint() |
|||
For i=1 To 10 |
|||
Select Random(2) |
|||
Case 0 : InsertAtPos(Random(4,1),Random(Len(dna),1)) |
|||
Case 1 : EraseAtPos(Random(Len(dna),1)) |
|||
Case 2 : OverwriteAtPos(Random(4,1),Random(Len(dna),1)) |
|||
EndSelect |
|||
Next |
|||
PrintN("After 10 mutations:") |
|||
pprint() |
|||
Input()</lang> |
|||
{{out}} |
|||
<pre>Initial sequence: |
|||
0: AAGTTTACGTCGGACTTCATTAATCGGTTTAGTCAGACCCGATCCAAATC |
|||
50: TTGCTTTCACTCCGCATTCTTCTCATGAGTAAAAGGCTGCTCCTGCACTA |
|||
100: AAGCGTTCTCAACACCTTGGAGAGCCATCTCGGTACTCCGCGCAAAATAG |
|||
150: CCATAGAGGGTATCAGGAAACGCATCGAAGGTTTAGCCGAACTAAGGTCT |
|||
Base counts: |
|||
A: 54, C: 52, G: 42, T: 52, Total: 200 |
|||
Change base at position 7 from A to T |
|||
Insert base T at position 66 |
|||
Erase base G at position 198 |
|||
Insert base C at position 32 |
|||
Change base at position 80 from A to G |
|||
Erase base A at position 2 |
|||
Insert base C at position 33 |
|||
Insert base C at position 201 |
|||
Insert base G at position 70 |
|||
Erase base T at position 187 |
|||
After 10 mutations: |
|||
0: AGTTTTCGTCGGACTTCATTAATCGGTTTACGCTCAGACCCGATCCAAAT |
|||
50: CTTGCTTTCACTCCGCTATGTCTTCTCATGGGTAAAAGGCTGCTCCTGCA |
|||
100: CTAAAGCGTTCTCAACACCTTGGAGAGCCATCTCGGTACTCCGCGCAAAA |
|||
150: TAGCCATAGAGGGTATCAGGAAACGCATCGAAGGTTAGCCGAACTAAGTC |
|||
200: CT |
|||
Base counts: |
|||
A: 51, C: 55, G: 43, T: 53, Total: 202</pre> |
|||
=={{header|Python}}== |
=={{header|Python}}== |