#!/usr/local/bin/python3.3 import cgi import cgitb import datetime import DAPRfunctions as dapr cgitb.enable() cookie = dapr.get_cookies() #dapr.loadConfiguration() def pass_val_to_js(id,val): input_str=""" """%(val,id) return(input_str) if 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 ceid = cookie["ck_eid"].value form = cgi.FieldStorage() eid = form.getvalue('exp') nuname = form.getvalue("uname") nbid = form.getvalue("bid") proj = form.getvalue('project') study = form.getvalue('study') #if exp is set on the drop down, then filter by exp # exp in the cookie will always be set, so I need to test before the cookie value is transfered to eid # if not, but study is set, then filter by study # if not, but project is set, then filter by project # # full query: #"""select * from BEDfile b where bid in # (select bid from ExperimentBEDfile where eid in # (select eid from StudyExperiment where sid in # (select sid from ProjectStudy where prid= %s )))""" select_clause="""select b.bid, location, b.name, w.name, c.name, description1, peaknumber, uploader, upload_date, bedtoolcommand from BEDfile b """ where_clause=" " join_clause=""" join WetlabMethod w using(wmid) join ComputationalMethod c using(cmid) """ orderby_clause=""" order by upload_date desc, b.name asc""" if eid and eid!= "0" : where_clause=where_clause+"""where bid in (select bid from ExperimentBEDfile where eid = %s)"""%eid elif study and study != "0" : where_clause=where_clause+"""where bid in (select bid from ExperimentBEDfile where eid in (select eid from StudyExperiment where sid = %s))"""%study elif proj and proj != "0": where_clause=where_clause+"""where bid in (select bid from ExperimentBEDfile where eid in (select eid from StudyExperiment where sid in (select sid from ProjectStudy where prid= %s )))"""%proj #TODO: add admin filter get_bed_query=select_clause+join_clause+where_clause+orderby_clause #form eid takes precedence over cookie eid #and we want to save it to the cookie if eid and eid != "0" : cookie["ck_eid"]=eid print(cookie) else: if ceid != "0": eid=ceid else: eid_error_flag=True eid_error="there is no experiment set" # #for debugging # print("Content-type: text/html\n") # print("proj "+proj) # print("study "+study) # print("eid "+eid) # print("ceid "+ceid) db=dapr.DBConnection() qexname = "select title from Experiment where eid = '%s'" % eid exname = db.runQuery(qexname)[0][0] print("Content-type: text/html\n") print(pass_val_to_js("pass_proj",proj)) print(pass_val_to_js("pass_study",study)) print(pass_val_to_js("pass_eid",eid)) print(""" """) dapr.phead(name, admin) print("""
""") print("""

BEDtools

""") ### separate the python from the HTML # form HTML and js was copied from upload_v0.2.py print("""
Select BED files for analysis
""") res1 = db.runQuery(get_bed_query) if len(res1) > 0: print("""
""" ) n1 = len(res1) for i in range(n1): row = res1[i] 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 Info1 Peak Number Uploader Upload time bedtools command Download
%s%sDownload


") print("""

Pick your tool for analysis:


Note: Please select experiment using dropdowns at the top of the page BEFORE selecting tool!

Analysis tool:



""") ##TODO make this work for each row rather than one section at the bottom print("""

Delete a BED file:

Note: This CANNOT be undone.

Please select ONE BED file using checkboxes.


""") ## code for bed copy if nbid != None: q2 = """select wmid,cmid,name,location,description1,description2,description3,bedtoolcommand, stringency, source from BEDfile where bid = "%s";"""%bid q3 = """select bid from BEDfile order by bid DESC limit 1;""" q4 = """select eid from Experiment where title = "%s";"""%eid add_new = db.runQuery(q2) nbid = db.runQuery(q3) neid = db.runQuery(q4) name = add_new[0][2] + "_" + str(nbid) Copy(nbid,name, add_new[0][3], add_new[0][4], add_new[0][5], add_new[0][6], add_new[0][7], nuname, add_new[0][1], add_new[0][0],add_new[0][8], add_new[0][9],neid) dapr.ptail() else: print("Location: login.py") print("Content-type: text/html\n")