#!/usr/bin/env python
# Import modules for CGI handling
import cgi, cgitb
cgitb.enable()    

print "content-type:text/html\r\n\r\n"

#print ("Hello World")

import pymysql

conn = pymysql.connect(
	host="localhost", 
	user = "root", 
	passwd="netweb",
	database="BROWSEDATA"
	)

mycursor = conn.cursor()


mycursor.execute("select * from FUNCTION_ANNOTATION LIMIT 5000")

result = mycursor.fetchall() 


print ("<table border='1'>")
print ("<tr>")

print ("<th> Protein Accession </th>")
print ("<th> Sequence MD5 digest </th>")
print ("<th> Sequence Length </th>")
print ("<th> Analysis </th>")
print ("<th> Signature Accession   </th>")
print ("<th> Signature Description </th>")
print ("<th> Start location </th>")
print ("<th> Stop location </th>")
print ("<th> Score </th>")
print ("<th> Status </th>")
print ("<th> Date </th>")
print ("<th> InterPro annotations - accession  </th>")
print ("<th>InterPro annotations - description   </th>")
print ("<th> GO annotations </th>")

print ("</tr>")


for each in result:
	print ("<tr>")
	print ("<td>{0}</td>" .format(each[0]))
	print ("<td>{0}</td>" .format(each[1]))
	print ("<td>{0}</td>" .format(each[2]))
	print ("<td>{0}</td>" .format(each[3]))
	print ("<td>{0}</td>" .format(each[4]))
	print ("<td>{0}</td>" .format(each[5]))
	print ("<td>{0}</td>" .format(each[6]))
	print ("<td>{0}</td>" .format(each[7]))
	print ("<td>{0}</td>" .format(each[8]))
	print ("<td>{0}</td>" .format(each[9]))
	print ("<td>{0}</td>" .format(each[10]))
	print ("<td>{0}</td>" .format(each[11]))
	print ("<td>{0}</td>" .format(each[12]))
	print ("<td>{0}</td>" .format(each[13]))
	
	
	

	print ("</tr>")
	
print("</table>")
