413eea60a2ca4d9c534a6750fcbf332ffa7e1e36 max Thu Nov 27 03:06:00 2014 -0800 moving bigbed files to a location that is less lame, refs #14427 diff --git src/beacon/query src/beacon/query index 71a6970..e951874 100755 --- src/beacon/query +++ src/beacon/query @@ -1,51 +1,55 @@ #!/usr/bin/env python # a beacon for LOVD, ClinVar, UniProt and HGMD, see ga4gh.org/#/beacon import cgi, subprocess, sys, cgitb, os, datetime, gdbm +from os.path import join cgitb.enable() +# dir for bigBed files +DATADIR = "/gbdb/hg19/beacon" + trackFnames = { "clinvar" : "clinvarMain.bb", "uniprot" : "spMut.bb", "hgmd" : "hgmd.bb", "lovd" : "lovd.bb" } MAXREQPERDAY=1000 def checkReqCount(): " check if IP address has exceeded max number of requests today " accCounts = gdbm.open("accCounts.gdbm", "c") ipAddr = os.environ["REMOTE_ADDR"] dateStr = datetime.date.today().isoformat() accKey = ipAddr+"|"+dateStr try: oldCount = int(accCounts[accKey]) except KeyError: oldCount = 0 newCount = oldCount+1 if newCount > MAXREQPERDAY: print("No more requests left today") sys.exit(0) accCounts[accKey]=str(newCount) accCounts.close() def getTrackFromScript(): - " check which track name occurs in script name, to make the track captured by symlinks " + " check which track name occurs in script name, allows symlinks to cgi that include the track name " name = sys.argv[0].lower() for trackName in trackFnames: if trackName in name: return trackName def errAbort(errMsg=None): print "<html><body><pre>" if errMsg is not None: print "error: "+errMsg host = os.environ.get("HTTP_HOST", "") print """ A Genomics Alliance Beacon at UCSC. In collaboration with the Leiden Open Variation Database. @@ -110,31 +114,31 @@ if chrom not in insdcToUcsc.values(): chrom = insdcToUcsc.get(chrom, None) if chrom==None: errAbort( "ERROR: illegal chrom identifier %s" % chrom) if track not in trackFnames: errAbort("illegal track name") if nucl==None or len(nucl)!=1 or nucl[0].lower() not in "actg": errAbort("invalid allele, can only be ACTG") checkReqCount() # change parameters slightly nucl = nucl.upper() -fname = trackFnames[track] +fname = join(DATADIR, trackFnames[track]) pos = int(pos) # run tool args = ["./bigBedToBed", fname, "stdout", "-chrom=%s"%chrom, "-start=%d"%pos, "-end=%d"%(pos+1)] p = subprocess.Popen(args, stdout=subprocess.PIPE) # parse output isMaybe = False for line in p.stdout: fs = line.rstrip("\n").split("\t") if fs[-1]=="maybe": isMaybe=True if int(fs[2])-int(fs[1])!=1 and track != "uniprot": continue if fs[3][-1]==nucl or track in ["hgmd", "uniprot"]: