-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFAD.py
More file actions
144 lines (122 loc) · 4.15 KB
/
FAD.py
File metadata and controls
144 lines (122 loc) · 4.15 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
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
144
#!/usr/bin/python
# Import modules for CGI handling
import cgi, cgitb
import urllib
import requests
import re
import sys, os
url="https://files.rcsb.org/view/"
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from field
if form.getvalue('textcontent'):
text_content = form.getvalue('textcontent')
else:
text_content = "Not entered"
print "Content-type:text/html\r\n\r\n"
print "<html>"
print "<head>"
#HTML style details for web page
print "<style>"
print "ul{list-style-type: none;margin: 0;padding: 0; overflow: hidden;background-color: #333333;}"
print "li{float:left;}"
print "li a {display: block;color: white;text-align: center;padding: 16px;font-size:20px; text-decoration: none;}"
print "li a:hover { background-color: #111111;}"
print "table, th, td { border: 2px solid black;}"
print ".footer { position: absolute; left: 0; bottom: 0; width: 100%; height:60px; background-color: #808080; color: white; text-align: center; }"
print "</style>"
#Style ends here
print "<title>LiBiSCo</title>"
print "</head>"
#print "<h1>CoFact<style=color:blue;>Comp</style></h1>"
print "<div align='center'>"
print "<img src='Pic.gif' align='middle' width='80%' height='500'"
print "</div>"
print "<body>"
print "<ul>"
print "<li><a href='HomePage.py'>Home</a></li>"
print "<li><a href=''>Contact</a></li>"
print "</ul>"
print "<div align='center'>"
print "<h2> Below is shown Bound Ligand information for the PDB IDs entered: %s</h2>" % text_content
print "<p> Select ligand of interest for the PDB IDs listed to compare the binding sites</p>"
#Capturing URL address to get the ligand name for further processing
url1 = os.environ['HTTP_HOST']
uri = os.environ['REQUEST_URI']
filename= url1+uri
take=filename.split('/')
take2= take[-1]
take3=take2.split('.')
final_filename= take3[0]
#URL address capturing finishes
#capturing the entered pdb ids into list
for i in text_content:
text_content1=text_content.replace(' ', '')
l=text_content1.split(',')
f2_list=[]
combined_list=[]
#print "entered id's",l
pdbid_list=[]
url_list=[]
mydict={}
count=1
for i in l:
# print "looping over the entered pdb ids:",i
each= i # i am removing the +"="+"[]"
pdbid_list.append(each)
#print "list generated for individual PDB id entered:", pdbid_list
#linking the PDB url address to the selected PDB ids
for x in l:
# print "linking each id to its url address(below each id is its url address):",x
# print "<br/>"
pdbid=url+x+".pdb"
# print pdbid
url_list.append(pdbid)
#print "url list content is :",url_list
#Listing the PDB ids and their bound ligands
for link,id in zip(url_list,pdbid_list):
# print "This is the %d st/nd number of url %s"% (count,link)
count=count+1
f=urllib.urlopen(link)
f=f.readlines()
# print f
#! f='\n'.join(f)
for e in f:
# print "this is:",e.split()
if e.startswith('FORMUL'):
e= e.split()
# print e
if e[2]!="HOH":
f2=e[2]
# print "ligands extacted %s from %s:"% (f2,link)
# id_list.append(f2)
# print id_list
mydict.setdefault('%s'%id,[]).append(f2)
#print "<br/>"
#print "Dictionary od PDBIDS", mydict
# Form for selecting the ligands for interest for the USER
print "<form action='%s_Result.py' method = 'post' target = '_blank'>"% final_filename
print "<table style=width:50%>"
print "<tr>"
print "<th>PDB ID</th>"
print "<th colspan=2>LIGANDS</th>"
for k,dk in mydict.iteritems():
count= len(dk)
print "<tr>"
print "<th rowspan='%d'>"% count,k,"</th>"
#print "</tr>"
for x in dk:
print "<td align=center>", "%s" % x,"</td>"
print "<td align=center>"
print "<input type='checkbox' name='%s' value='%s'/>" % (k,x)
print "</td>"
print "</tr>"
# print "<br/>"
# print "<br/>"
print "</table>"
print "<br/>"
print "<input type = 'submit' value = 'Submit' />"
print "</form>"
print "</div>"
print "</body>"
print "</html>"