#!/usr/local/bin/python3.3 import cgi import cgitb import pymysql from functions import get_cookies cgitb.enable() 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 print("Content-type: text/html\n") form = cgi.FieldStorage() eid = form.getvalue('eid') data = [] #data should be in the order: user, passwd, host, db with open('./dbinfo.txt') as f: for line in f: line = line.strip('\n') data.append(line) info = [] for item in data: item = item.split(':') info.append(item) user=info[0][1] passwd=info[1][1] host=info[2][1] db=info[3][1] qexname = "select title from Experiment where eid = '%s'" % eid def runQuery(query, user, passwd): connection = pymysql.connect(host=host,db=db,user=user,passwd=passwd) cursor = connection.cursor() cursor.execute(query) res = cursor.fetchall() cursor.close() connection.close() return res if eid != "-- please select a experiment--": exname = runQuery(qexname, user, passwd)[0][0] 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) beds = runQuery(q1, user, passwd) #print('
All BED files in experiment %s:
' % exname) print("""BED file | Wetlab method | Computational method | Description1 | Description2 | Description3 | Uploader | Upload time | BEDtool command | Download |
---|---|---|---|---|---|---|---|---|---|
%s | """ % (str(row[0]),str(row[j]))) else: print("%s | " % str(row[j])) print("""Download | """ % row[1]) print("