-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvisualize.py
143 lines (115 loc) · 4.14 KB
/
visualize.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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
from Bio import SeqIO
from prody import *
from numpy import *
from matplotlib.pyplot import *
# Reading proteins from the FASTA file
temp = list()
with open("sequence-data/proteins.fasta") as handle:
for record in SeqIO.parse(handle, "fasta"):
temp.append([record.seq])
# DNA ORFs (Open Reading Frames)
dna_orf_1 = str(temp[0][0])
dna_orf_2 = str(temp[1][0])
dna_orf_3 = str(temp[2][0])
neg_dna_orf_1 = str(temp[3][0])
neg_dna_orf_2 = str(temp[4][0])
neg_dna_orf_3 = str(temp[5][0])
# RNA ORFs (Open Reading Frames)
rna_orf_1 = str(temp[6][0])
rna_orf_2 = str(temp[7][0])
rna_orf_3 = str(temp[8][0])
neg_rna_orf_1 = str(temp[9][0])
neg_rna_orf_2 = str(temp[10][0])
neg_rna_orf_3 = str(temp[10][0])
# Finding largest protein strands in each ORF under lenght<400
def maximise(e):
e = list(filter(lambda x: len(x) < 400, e.split("_")))
count = 0
for i in range(0, len(e)):
if len(e[i]) > count:
count = len(e[i])
for i in e:
if len(i) == count:
return (i)
biglist = [maximise(dna_orf_1), maximise(dna_orf_2), maximise(dna_orf_3), maximise(neg_dna_orf_1), maximise(neg_dna_orf_2), maximise(neg_dna_orf_3),
maximise(rna_orf_1), maximise(rna_orf_2), maximise(rna_orf_3), maximise(neg_rna_orf_1), maximise(neg_rna_orf_2), maximise(neg_rna_orf_3)]
# Using ESM1B to convert amino acid sequence to pdb
def esm1b(protein, filename):
import requests
url = "https://api.esmatlas.com/foldSequence/v1/pdb/"
res = requests.post(url, protein)
with open("sequence-data/{}".format(filename), "w") as f:
f.write(res.text)
# Plotting DNA Forward ORFs using matplotlib and ProDy
def plot_dna_forward_orfs():
esm1b(biglist[0], "dna-forward/dna_orf_1.pdb")
esm1b(biglist[1], "dna-forward/dna_orf_2.pdb")
esm1b(biglist[2], "dna-forward/dna_orf_3.pdb")
graph1 = parsePDB('sequence-data/dna-forward/dna_orf_1.pdb')
graph2 = parsePDB('sequence-data/dna-forward/dna_orf_2.pdb')
graph3 = parsePDB('sequence-data/dna-forward/dna_orf_3.pdb')
print(graph1)
print(graph2)
print(graph3)
showProtein(graph1)
showProtein(graph2)
showProtein(graph3)
title("DNA Forward ORFs")
legend()
show()
# Plotting DNA Reverse ORFs using matplotlib and ProDy
def plot_dna_reverse_orfs():
esm1b(biglist[0], "dna-reverse/neg_dna_orf_1.pdb")
esm1b(biglist[1], "dna-reverse/neg_dna_orf_2.pdb")
esm1b(biglist[2], "dna-reverse/neg_dna_orf_3.pdb")
graph1 = parsePDB('sequence-data/dna-reverse/neg_dna_orf_1.pdb')
graph2 = parsePDB('sequence-data/dna-reverse/neg_dna_orf_2.pdb')
graph3 = parsePDB('sequence-data/dna-reverse/neg_dna_orf_3.pdb')
print(graph1)
print(graph2)
print(graph3)
showProtein(graph1)
showProtein(graph2)
showProtein(graph3)
title("DNA Reverse ORFs")
legend()
show()
# Plotting RNA Forward ORFs using matplotlib and ProDy
def plot_rna_forward_orfs():
esm1b(biglist[0], "rna-forward/rna_orf_1.pdb")
esm1b(biglist[1], "rna-forward/rna_orf_2.pdb")
esm1b(biglist[2], "rna-forward/rna_orf_3.pdb")
graph1 = parsePDB('sequence-data/rna-forward/rna_orf_1.pdb')
graph2 = parsePDB('sequence-data/rna-forward/rna_orf_2.pdb')
graph3 = parsePDB('sequence-data/rna-forward/rna_orf_3.pdb')
print(graph1)
print(graph2)
print(graph3)
showProtein(graph1)
showProtein(graph2)
showProtein(graph3)
title("RNA Forward ORFs")
legend()
show()
# Plotting DNA Reverse ORFs using matplotlib and ProDy
def plot_rna_reverse_orfs():
esm1b(biglist[0], "rna-reverse/neg_rna_orf_1.pdb")
esm1b(biglist[1], "rna-reverse/neg_rna_orf_2.pdb")
esm1b(biglist[2], "rna-reverse/neg_rna_orf_3.pdb")
graph1 = parsePDB('sequence-data/rna-reverse/neg_rna_orf_1.pdb')
graph2 = parsePDB('sequence-data/rna-reverse/neg_rna_orf_2.pdb')
graph3 = parsePDB('sequence-data/rna-reverse/neg_rna_orf_3.pdb')
print(graph1)
print(graph2)
print(graph3)
showProtein(graph1)
showProtein(graph2)
showProtein(graph3)
title("RNA Reverse ORFs")
legend()
show()
# Uncomment to plot
plot_dna_forward_orfs()
plot_dna_reverse_orfs()
plot_rna_forward_orfs()
plot_rna_reverse_orfs()