-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDemoScriptSequence.py
104 lines (74 loc) · 2.81 KB
/
DemoScriptSequence.py
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
##### Demonstration Script #####
import Sequence
from Sequence import Sequence as sq
import matplotlib.pyplot as plt
num_seq = int(input("Enter the number of sequences: ")) #Take the number of sequences the user wants to input
seq_list = []
#Create Multiple Class Instances
for i in range(0,num_seq):
dna = sq(str(input("Enter the DNA Sequence: ")))
print("*****CREATING NEW SEQUENCE INSTANCE*****")
seq_list.append(dna)
print("***Object Created***\n")
#Testing Base Count
len_seq = sq.base_count(seq_list[0])
print("Length of the sequence is ", len_seq)
# Testing is_dna
valid_dna = sq.is_dna(seq_list[0])
assert valid_dna == True, "This is not a valid DNA sequence"
#Testing __eq__
dna_1 = sq("ATGCTGCA")
dna_2 = sq("atgctgca")
dna_3 = sq("ATGATGCA")
true_val = (dna_1 == dna_2) #The DNA Sequences are same
true_val2 = (dna_1 == dna_3) #The DNA Sequences are different
assert true_val == True, "The DNA sequences are not equal and not of the same object type"
assert true_val2 == False, "The sequences are equal"
#Testing comp_seq
dna_input = sq("ATGCTGCT")
dna_comp = sq("TACGACGA")
compliment_seq = sq.comp_seq(dna_input)
if dna_comp == compliment_seq: #Compare the complimentary sequence generated by the method with the manually defined complimentary sequence
print("The complimentary sequences are the same \n \n")
else:
print("ERROR: The complimentary sequences are not same \n \n")
#Testing MisMatch
mismatch_index = sq.mis_match(dna_1,dna_3)
print("Mismatch found at position: ",mismatch_index)
print("\n")
#Reading genome_01.dat
print("***READING genome_01.dat***")
genome_01 = Sequence.read_genome("genome_01.dat")
#Testing gene_finder
genes_1 = sq.gene_finder(genome_01)
gene_len1 = sq.base_count(genes_1[0])
print("The length of first gene is: ", gene_len1)
print("\n")
#Testing Swap Mutation
print("***READING genome_02.dat***")
genome_02 = Sequence.read_genome("genome_02.dat")
genes_2 = sq.gene_finder(genome_02)
gene_mut = []
gene_len = []
#Count number of mutation for each gene comparison
for i in range(0,len(genes_1)):
mut_count = sq.swap_mut(genes_1[i],genes_2[i]) #Counts number of mutation for each gene comparison
gene_mut.append(mut_count)
gene_count = sq.base_count(genes_1[i])
gene_len.append(gene_count)
#GeneLength Histogram
plt.style.use(['ggplot','dark_background'])
plt.figure(0,figsize = (19,9))
plt.title("Gene Length Bar")
plt.xlabel("Gene", fontsize = "15")
plt.ylabel("Gene Length", fontsize = "15")
plt.bar(range(len(gene_len)), gene_len)
plt.savefig("GeneLength_NairKarthik.png")
#Gene Mutation vs Gene Length
plt.figure(1,figsize = (19,9))
plt.title("Gene Mutation vs Gene Length", fontsize = "20")
plt.xlabel("Gene Mutation", fontsize = "15")
plt.ylabel("Gene Length", fontsize = "15")
plt.scatter(gene_mut,gene_len,color = "red")
plt.savefig("GeneMutVsLen_NairKarthik.png")
plt.show()