#!/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(""" DASR

Manage

BEDTools

Upload


""") if admin == "1" 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) 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("""
""" ) n1 = len(res1) for i in range(n1): row = res1[i] if i % 2 == 1: print('') else: print('') for j in range(len(row)): if j == 0 or j == 2: print("""""" % (str(row[0]),str(row[j]))) elif j == 1: pass else: print("" % str(row[j])) print("""""" % row[1]) print("") print("
ID BED file Wetlab method Computational method Tissue Descriptor1 Descriptor2 Descriptor3 Uploader Upload time bedtools command Download
%s%sDownload


") print("""

""" % str(datetime.datetime.now())[:-7]) else: print("Location: login.py") print("Content-type: text/html\n")