-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskewplot.py
More file actions
69 lines (49 loc) · 2.01 KB
/
skewplot.py
File metadata and controls
69 lines (49 loc) · 2.01 KB
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
import numpy as np
import matplotlib.pyplot as plt
# needs a function returns an array of skew.
# this should take in a genome string, and the location of the minimum skew as well as what the minimum skew is
def toPlot(genome, name):
skew = 0
splot = []
for i in range(len(genome)):
content = genome[i]
#print(content == 'G')
if (content == 'G'):
#print("G is on")
skew += 1
#print(skew)
elif (content == 'C'):
#print("C is on")
skew -= 1
#print(skew)
splot.append(skew)
#print(splot)
plt.plot(splot)
plt.suptitle(name)
plt.show()
if __name__ == '__main__':
# add the genomes of course
##########################################################################
# sample code
with open ("C:/Users/Tofu/Documents/B363-project/OH157-genome.txt", "r") as myfile:
data1 = myfile.readlines()
OH1507 = ' '.join([str(elem) for elem in data1])
with open ("C:/Users/Tofu/Documents/B363-project/O145-H11-genome.txt", "r") as myfile:
data2 = myfile.readlines()
O145 = ' '.join([str(elem) for elem in data2])
with open ("C:/Users/Tofu/Documents/B363-project/O121-H19-genome.txt", "r") as myfile:
data3 = myfile.readlines()
O121 = ' '.join([str(elem) for elem in data3])
with open ("C:/Users/Tofu/Documents/B363-project/O103-H2-genome.txt", "r") as myfile:
data4 = myfile.readlines()
O103 = ' '.join([str(elem) for elem in data4])
with open ("C:/Users/Tofu/Documents/B363-project/O26-H11-genome.txt", "r") as myfile:
data5 = myfile.readlines()
O26 = ' '.join([str(elem) for elem in data5])
##########################################################################
# might want to test each plot separately to save memory
#toPlot(OH1507, "O1507")
#toPlot(O145, "O145")
toPlot(O121, "O121")
#toPlot(O103, "O103")
#toPlot(O26, "O26")