-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6 - Mutation Generator.py
More file actions
34 lines (32 loc) · 954 Bytes
/
6 - Mutation Generator.py
File metadata and controls
34 lines (32 loc) · 954 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Mutation Generator
# This program takes a DNA string and randomly mutates parts of it
# It then returns the original DNA string and its mutated counterpart
# Circa February 2023
# A program by Tyler Serio
# Python 3.9.6
import random
nucleotides = ("A", "T", "C", "G")
filename = "6 - sample.fastq"
file = open(filename, "r")
seqline = 0
for line in file:
seqline += 1
if seqline == 2:
line = line.strip("\n")
mutey = list(line)
place = 0
for x in mutey:
mutation = random.randint(0, 3)
if mutation == 3:
nukey = random.randint(0, 3)
mutey[place] = nucleotides[nukey]
place += 1
line2 = ""
for x in mutey:
line2 = line2 + str(x)
print(line + " - Original DNA")
print(line2 + " - Mutant DNA")
print("")
if seqline >= 4:
seqline = 0
file.close()