#!/usr/local/bin/python3.3 import cgi import cgitb import pymysql import datetime from functions import get_cookies cgitb.enable() #unsure of purpose cookie = get_cookies() if cookie: print(cookie) fname = cookie["fname"].value lname = cookie["lname"].value name = " ".join((fname, lname)) admin = cookie["admin"].value uid = cookie["uid"].value uname = cookie["uname"].value form = cgi.FieldStorage() eid = form.getvalue('eid') qexname = "select title from Experiment where eid = '%s'" % eid user="d4prdb17" passwd="d4prp455" def runQuery(query, user, passwd): connection = pymysql.connect(host="localhost",db="group9",user=user,passwd=passwd) cursor = connection.cursor() cursor.execute(query) res = cursor.fetchall() cursor.close() connection.close() return res print("Content-type: text/html\n") print("""
All BED files:
') q1 = """ select bid, location, b.name, w.name, c.name, description1, description2, description3, uploader, upload_date, bedtoolcommand from BEDfile b join WetlabMethod w using(wmid) join ComputationalMethod c using(cmid) order by upload_date desc, b.name asc; """ elif admin == "1" and eid: exname = runQuery(qexname, user, passwd)[0][0] print('All BED files in experiment %s:
' % exname) q1 = """ select b.bid, location, b.name, w.name, c.name, description1, description2, description3, uploader, upload_date, bedtoolcommand from BEDfile b join ExperimentBEDfile using(bid) join WetlabMethod w using(wmid) join ComputationalMethod c using(cmid) where eid = "%s" order by upload_date desc, b.name asc; """ % eid elif admin == "0" and eid == None: print('All BED files:
') q1 = """ select bid, location, b.name, w.name, c.name, description1, description2, description3, uploader, upload_date, bedtoolcommand from BEDfile b join WetlabMethod w using(wmid) join ComputationalMethod c using(cmid) where uploader = "%s" order by upload_date desc, b.name asc; """ % uname else: exname = runQuery(qexname, user, passwd)[0][0] print('All BED files in experiment %s:
' % exname) q1 = """ select b.bid, location, b.name, w.name, c.name, description1, description2, description3, uploader, upload_date, bedtoolcommand from BEDfile b join ExperimentBEDfile using(bid) join WetlabMethod w using(wmid) join ComputationalMethod c using(cmid) where eid = "%s" and uploader = "%s" order by upload_date desc, b.name asc; """ % (eid,uname) res1 = runQuery(q1, user, passwd) if len(res1) > 0: print("""ID | BED file | Wetlab method | Computational method | Tissue | Descriptor1 | Descriptor2 | Descriptor3 | Uploader | Upload time | bedtools command | Download |
---|---|---|---|---|---|---|---|---|---|---|---|
%s | """ % (str(row[0]),str(row[j]))) elif j == 1: pass else: print("%s | " % str(row[j])) print("""Download | """ % row[1]) print("