def main(): print "This line will be printed." request = "35872" pop = "ALL" #reference = request.args.get('reference', False) print 'pop: ' + pop print 'request: ' + request snplst = tmp_dir+'snps'+request+'.txt' print 'snplst: '+snplst file = "meta_assoc.meta" region = "variant" args = {} args["origin"] = "rs1231" print args try: out_json = calculate_hap(snplst,pop,request, false) #out_json = calculate_assoc(file,region,pop,request,args) except: return sendTraceback() #copy_output_files(reference) return sendJSON(out_json)
def ldhap(): isProgrammatic = False print 'Execute ldhap' print 'working' print 'Gathering Variables from url' snps = request.args.get('snps', False) pop = request.args.get('pop', False) if request.args.get('reference', False): reference = request.args.get('reference', False) else: reference = str(time.strftime("%I%M%S")) + ` random.randint(0, 10000) ` isProgrammatic = True print 'snps: ' + snps print 'pop: ' + pop print 'request: ' + str(reference) if reference is False: reference = str(time.strftime("%I%M%S")) + ` random.randint(0, 10000) ` snplst = tmp_dir + 'snps' + reference + '.txt' print 'snplst: ' + snplst f = open(snplst, 'w') f.write(snps) f.close() try: out_json = calculate_hap(snplst, pop, reference) if isProgrammatic: resultFile = "" resultFile1 = "./tmp/snps_" + reference + ".txt" resultFile2 = "./tmp/haplotypes_" + reference + ".txt" fp = open(resultFile1, "r") content1 = fp.read() fp.close() fp = open(resultFile2, "r") content2 = fp.read() fp.close() return content1 + "\n" + "#####################################################################################" + "\n\n" + content2 except: return sendTraceback() return sendJSON(out_json)
def ldhap(): print print 'Execute ldhap' print 'Gathering Variables from url' snps = request.args.get('snps', False) pop = request.args.get('pop', False) reference = request.args.get('reference', False) print 'snps: ' + snps print 'pop: ' + pop print 'request: ' + reference snplst = tmp_dir+'snps'+reference+'.txt' print 'snplst: '+snplst f = open(snplst, 'w') f.write(snps) f.close() out_json = calculate_hap(snplst,pop,reference) copy_output_files(reference) return out_json
def ldhap(): print 'Execute ldhap.' # print 'Request User Agent: ', request.user_agent # print 'Request User Agent Platform: ', request.user_agent.platform # print 'Request User Agent Browser: ', request.user_agent.browser snps = request.args.get('snps', False) pop = request.args.get('pop', False) token = request.args.get('token', False) print 'snps: ' + snps print 'pop: ' + pop web = False # differentiate web or api request if 'LDlinkRestWeb' in request.path: # WEB REQUEST if request.user_agent.browser is not None: web = True reference = request.args.get('reference', False) print 'request: ' + str(reference) snplst = tmp_dir + 'snps' + reference + '.txt' with open(snplst, 'w') as f: f.write(snps.lower()) try: out_json = calculate_hap(snplst, pop, reference, web) except: return sendTraceback(None) else: return sendJSON( "This web API route does not support programmatic access. Please use the API routes specified on the API Access web page." ) else: # API REQUEST web = False reference = str(time.strftime("%I%M%S")) + ` random.randint(0, 10000) ` print 'request: ' + str(reference) snplst = tmp_dir + 'snps' + reference + '.txt' with open(snplst, 'w') as f: f.write(snps.lower()) try: # lock token preventing concurrent requests toggleLocked(token, 1) out_json = calculate_hap(snplst, pop, reference, web) # display api out try: # unlock token then display api output resultFile1 = "./tmp/snps_" + reference + ".txt" resultFile2 = "./tmp/haplotypes_" + reference + ".txt" with open(resultFile1, "r") as fp: content1 = fp.read() with open(resultFile2, "r") as fp: content2 = fp.read() toggleLocked(token, 0) return content1 + "\n" + "#####################################################################################" + "\n\n" + content2 except: # unlock token then display error message output = json.loads(out_json) toggleLocked(token, 0) return sendTraceback(output["error"]) except: # unlock token if internal error w/ calculation toggleLocked(token, 0) return sendTraceback(None) return sendJSON(out_json)