Esempio n. 1
0
 def getOutputFiles(self):
     """ it returns a list of strings containing the URLs of the output files 
     produced by the job """
     resp = self.opalService.appServicePort.getOutputs(getOutputsRequest(self.jobID))
     outputFile = []
     for i in resp._outputFile:
         outputFile.append(i._url)
     return outputFile
Esempio n. 2
0
 def getOutputs(self):
     if self.status is None:
         raise RuntimeError("No job has been launched yet")
     from AppService_client import getOutputsRequest
     import socket
     req = getOutputsRequest(self.jobID)
     try:
         resp = self.appServicePort.getOutputs(req)
     except socket.error, e:
         from chimera import NonChimeraError
         raise NonChimeraError(str(e))
Esempio n. 3
0
	def getOutputs(self):
		if self.status is None:
			raise RuntimeError("No job has been launched yet")
		from AppService_client import getOutputsRequest
		import socket
		req = getOutputsRequest(self.jobID)
		try:
			resp = self.appServicePort.getOutputs(req)
		except socket.error, e:
			from chimera import NonChimeraError
			raise NonChimeraError(str(e))
Esempio n. 4
0
def displayResults(jobID):
	""" Displays URLs of resulting files, if they are not to be fetched automatically. """
	global service_url
	appServicePort = AppServiceLocator().getAppServicePort(service_url)
	resp = appServicePort.getOutputs(getOutputsRequest(jobID))
	
	# Retrieve a listing of all output files
	stdout.write("\tStandard Output:  %s\n" % resp._stdOut, "\n")
	stdout.write("\tStandard Error:  %s\n", resp._stdErr)
	if (resp._outputFile != None):
		for i in range(0, resp._outputFile.__len__()):
			stdout.write("\t%s:  %s\n" % (resp._outputFile[i]._name, resp._outputFile[i]._url))
		stdout.write("\tStandard Error:  %s\n" % resp._stdErr)
Esempio n. 5
0
def displayResults(jobID):
    """ Displays URLs of resulting files, if they are not to be fetched automatically. """
    global service_url
    appServicePort = AppServiceLocator().getAppServicePort(service_url)
    resp = appServicePort.getOutputs(getOutputsRequest(jobID))

    # Retrieve a listing of all output files
    stdout.write("\tStandard Output:  %s\n" % resp._stdOut, "\n")
    stdout.write("\tStandard Error:  %s\n", resp._stdErr)
    if (resp._outputFile != None):
        for i in range(0, resp._outputFile.__len__()):
            stdout.write("\t%s:  %s\n" %
                         (resp._outputFile[i]._name, resp._outputFile[i]._url))
        stdout.write("\tStandard Error:  %s\n" % resp._stdErr)
Esempio n. 6
0
def pollStatus(jobID,outputDirectory):
	""" Determines current status of run and executes fetching of results if the run is completed. """
	global service_url
	appServicePort = AppServiceLocator().getAppServicePort(service_url)
	status = appServicePort.queryStatus(queryStatusRequest(jobID))
	
	if status._code == 4:
		stderr.write("Error!  The calculation failed!\n")
		stderr.write("Message:  %s\n" % status._message)
		sys.exit(13)
	elif status._code != 8:
		stderr.write("Sorry, the calculation hasn't been completed yet. Please wait a short while and attempt to fetch the files again.\n")
		sys.exit(13)
	else:
		resp = appServicePort.getOutputs(getOutputsRequest(jobID))
		fetchResults(jobID, outputDirectory, resp._outputFile, status._code==4)
Esempio n. 7
0
def pollStatus(jobID, outputDirectory):
    """ Determines current status of run and executes fetching of results if the run is completed. """
    global service_url
    appServicePort = AppServiceLocator().getAppServicePort(service_url)
    status = appServicePort.queryStatus(queryStatusRequest(jobID))

    if status._code == 4:
        stderr.write("Error!  The calculation failed!\n")
        stderr.write("Message:  %s\n" % status._message)
        sys.exit(13)
    elif status._code != 8:
        stderr.write(
            "Sorry, the calculation hasn't been completed yet. Please wait a short while and attempt to fetch the files again.\n"
        )
        sys.exit(13)
    else:
        resp = appServicePort.getOutputs(getOutputsRequest(jobID))
        fetchResults(jobID, outputDirectory, resp._outputFile,
                     status._code == 4)
Esempio n. 8
0
def initVars():
    #global serviceURL

    if not form.has_key("jobid"):
        pass  # add code to redirect to PDB2PQR input page here
    else:
        jobid = form['jobid'].value

        #aspFile = open('./tmp/%s/%s-asp' % (logTime, logTime))
        #appServicePort = pickle.load(aspFile)
        #aspFile.close()

        #jobInfoFile = open('./tmp/%s/%s-jobinfo' % (logTime, logTime))
        #jobID = jobInfoFile.read()
        #jobInfoFile.close()

        aoFile = open('%s%s%s/%s-ao' % (INSTALLDIR, TMPDIR, jobid, jobid))
        apbsOptions = pickle.load(aoFile)
        aoFile.close()

        if APBS_OPAL_URL != "":
            from AppService_client import AppServiceLocator, getOutputsRequest
            apbsOpalJobIDFile = open('%s%s%s/apbs_opal_job_id' %
                                     (INSTALLDIR, TMPDIR, jobid))
            apbsOpalJobID = apbsOpalJobIDFile.read()
            apbsOpalJobIDFile.close()

            appLocator = AppServiceLocator()
            resp = appLocator.getAppServicePort(APBS_OPAL_URL).getOutputs(
                getOutputsRequest(apbsOpalJobID))
            if not os.access('%s%s%s' % (INSTALLDIR, TMPDIR, jobid), os.F_OK):
                os.mkdir('%s%s%s' % (INSTALLDIR, TMPDIR, jobid))
            for file in resp._outputFile:
                fileName = file._name
                if fileName != "Standard Output" and fileName != "Standard Error":
                    urllib.urlretrieve(
                        file._url,
                        '%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, fileName))

        return apbsOptions
Esempio n. 9
0
def initVars():
    #global serviceURL

    if not form.has_key("jobid"):
        pass # add code to redirect to PDB2PQR input page here
    else:
        jobid = form['jobid'].value

        #aspFile = open('./tmp/%s/%s-asp' % (logTime, logTime))
        #appServicePort = pickle.load(aspFile)
        #aspFile.close()

        #jobInfoFile = open('./tmp/%s/%s-jobinfo' % (logTime, logTime))
        #jobID = jobInfoFile.read()
        #jobInfoFile.close()

        aoFile = open('%s%s%s/%s-ao' % (INSTALLDIR, TMPDIR, jobid, jobid))
        apbsOptions = pickle.load(aoFile)
        aoFile.close()

        if APBS_OPAL_URL!="":
            from AppService_client import AppServiceLocator, getOutputsRequest
            apbsOpalJobIDFile = open('%s%s%s/apbs_opal_job_id' % (INSTALLDIR, TMPDIR, jobid))
            apbsOpalJobID = apbsOpalJobIDFile.read()
            apbsOpalJobIDFile.close()
            
            appLocator = AppServiceLocator()
            resp = appLocator.getAppServicePort(APBS_OPAL_URL).getOutputs(getOutputsRequest(apbsOpalJobID))
            if not os.access('%s%s%s' % (INSTALLDIR, TMPDIR, jobid), os.F_OK):
                os.mkdir('%s%s%s' % (INSTALLDIR, TMPDIR, jobid))
            for file in resp._outputFile:
                fileName = file._name
                if fileName!="Standard Output" and fileName!="Standard Error":
                    urllib.urlretrieve(file._url, '%s%s%s/%s' % (INSTALLDIR, TMPDIR, jobid, fileName))

        return apbsOptions
Esempio n. 10
0
def mainCGI():
    """
        Main method for determining the query page output
    """
    logopts = {}
    print "Content-type: text/html\n\n"
    calctype = form["calctype"].value

    # prints version error, if it exists
    if form["jobid"].value == 'False':
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "version_mismatch"
        runtime = 0
    elif form["jobid"].value == 'notenoughmem':
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "not_enough_memory"
        runtime = 0
    else:
        progress = None

    #Check for error html
    errorpath = '%s%s%s.html' % (INSTALLDIR, TMPDIR, form["jobid"].value)
    if os.path.isfile(errorpath):
        string = ""
        string += "<html>\n"
        string += "\t<head>\n"
        string += "\t\t<meta http-equiv=\"Refresh\" content=\"0; url=%s%s%s.html\">\n" % (
            WEBSITE, TMPDIR, form["jobid"].value)
        string += "\t</head>\n"
        string += "</html>\n"
        print string
        return

    # prepares for Opal query, if necessary
    if have_opal:
        if calctype == "pdb2pqr":
            opal_url = PDB2PQR_OPAL_URL
        elif calctype == "apbs":
            opal_url = APBS_OPAL_URL
        appLocator = AppServiceLocator()
        appServicePort = appLocator.getAppServicePort(opal_url)
    else:
        appServicePort = None

    # if PDB2PQR, determines if link to APBS calculation should be shown
    if calctype == "pdb2pqr":
        #if(form["apbsinput"].value=="True"): # change to use a file
        #    apbs_input = True
        #else:
        #    apbs_input = False
        apbsInputFile = open('%s%s%s/apbs_input' %
                             (INSTALLDIR, TMPDIR, form["jobid"].value))
        apbs_input = apbsInputFile.read()
        apbsInputFile.close()
        if apbs_input == "True":
            apbs_input = True
        else:
            apbs_input = False

        typemapInputFile = open('%s%s%s/typemap' %
                                (INSTALLDIR, TMPDIR, form["jobid"].value))
        typemap = typemapInputFile.read()
        typemapInputFile.close()
        if typemap == "True":
            typemap = True
        else:
            typemap = False

    if have_opal and progress == None:
        if form["calctype"].value == "pdb2pqr":
            pdb2pqrJobIDFile = open('%s%s%s/pdb2pqr_opal_job_id' %
                                    (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = pdb2pqrJobIDFile.read()
            pdb2pqrJobIDFile.close()
        elif form["calctype"].value == "apbs":
            apbsJobIDFile = open('%s%s%s/apbs_opal_job_id' %
                                 (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = apbsJobIDFile.read()
            apbsJobIDFile.close()
    else:
        jobid = form["jobid"].value

    if progress == None:
        cp = checkprogress(jobid, appServicePort,
                           calctype)  # finds out status of job
        progress = cp[0]

    #initialize with bogus value just in case
    starttime = time.time()

    if progress == "running" or progress == "complete":
        timefile = open(
            '%s%s%s/%s_start_time' %
            (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        starttime = float(timefile.read())
        timefile.close()
    if progress == "running" or (have_opal and progress not in (
            "version_mismatch", "not_enough_memory", "error", "complete")):
        runtime = time.time() - starttime
    elif progress == "complete":
        endTimeFileString = '%s%s%s/%s_end_time' % (
            INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value)
        if have_opal and not os.path.isfile(endTimeFileString):
            runtime = time.time() - starttime
            with open(endTimeFileString, 'w') as endTimeFile:
                endTimeFile.write(str(time.time()))
        else:
            with open(endTimeFileString, 'r') as endTimeFile:
                runtime = float(endTimeFile.read()) - starttime
    else:
        runtime = -1

    if progress == "running":
        #if have_opal:
        #    resultsurl = cp[1]._baseURL
        #else:
        if calctype == "pdb2pqr":
            resultsurl = '%squerystatus.cgi?jobid=%s&apbsinput=%s&calctype=pdb2pqr' % (
                WEBSITE, form["jobid"].value, apbs_input)
        else:
            resultsurl = '%squerystatus.cgi?jobid=%s&calctype=apbs' % (
                WEBSITE, form["jobid"].value)

    if progress == "complete":
        print printheader("%s Job Status Page" % calctype.upper(),
                          jobid=form["jobid"].value)

    elif progress == "error":
        print printheader("%s Job Status Page - Error" % calctype.upper(),
                          0,
                          jobid=form["jobid"].value)

    elif progress == "running":  # job is not complete, refresh in 30 seconds
        print printheader("%s Job Status Page" % calctype.upper(),
                          refresh,
                          jobid=form["jobid"].value)

    print "<BODY>\n<P>"
    print "<h3>Status"
    print "</h3>"
    print "Message: %s<br />" % progress
    print "Run time: %s seconds<br />" % int(runtime)
    print "Current time: %s<br />" % time.asctime()
    print "</P>\n<HR>\n<P>"

    if progress == "complete":
        if calctype == "pdb2pqr":
            nexturl = 'apbs_cgi.cgi?jobid=%s' % form["jobid"].value
        else:
            nexturl = 'visualize.cgi?jobid=%s' % form["jobid"].value

        if have_opal:
            resp = appServicePort.getOutputs(getOutputsRequest(jobid))
            filelist = resp._outputFile

        print "Here are the results:<ul>"
        print "<li>Input files<ul>"

        if calctype == "pdb2pqr":
            # this code should be cleaned up once local PDB2PQR runs output the PDB file with the .pdb extension
            if have_opal:
                for i in range(0, len(filelist)):
                    if len(filelist[i]._name) == 4:
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/%s.pdb>%s.pdb</a></li>" % (
                    WEBSITE, TMPDIR, jobid, jobid, jobid)

        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name == "apbsinput.in" or filelist[
                            i]._name[-4:] == ".pqr":
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/apbsinput.in>apbsinput.in</a></li>" % (
                    WEBSITE, TMPDIR, jobid)
                print "<li><a href=%s%s%s/%s.pqr>%s.pqr</a></li>" % (
                    WEBSITE, TMPDIR, jobid, jobid, jobid)

        print "</ul></li>"
        print "<li>Output files<ul>"

        queryString = [str(os.environ["REMOTE_ADDR"])]
        # Getting PDB2PQR run log info
        if os.path.isfile('%s%s%s/pdb2pqr_log' % (INSTALLDIR, TMPDIR, jobid)):
            pdb2pqrLogFile = open(
                '%s%s%s/pdb2pqr_log' % (INSTALLDIR, TMPDIR, jobid), 'r')
            logstr = pdb2pqrLogFile.read().split('\n')
            templogopts = eval(logstr[0])
            pdb2pqrLogFile.close()
            queryString.insert(0, templogopts.get('pdb', ''))

        if calctype == "pdb2pqr":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name.endswith(
                        (".propka", "-typemap.html", ".pqr", ".in")):
                        #                        if filelist[i]._name[-4:]==".pqr":
                        #                            # Getting pqr file length for PDB2PQR Opal run
                        #                            f=urllib.urlopen(filelist[i]._url)
                        #                            #pqrOpalFileLength = len(f.readlines())
                        #                            f.close()
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)

                    #Get the first line of the summary file.
                    if filelist[i]._name.endswith(".summary"):
                        f = urllib.urlopen(filelist[i]._url)
                        summaryLine = f.readline().strip()
                        #logopts["pdb"]=logopts.get("pdb", "") + "|" + summaryLine
                        queryString.append(summaryLine)
                        f.close()


#                logRun(logopts, runtime, pqrOpalFileLength, logff, REMOTE_ADDR)
            else:
                #Get the first line of the summary file.
                summaryFile = '%s%s%s/%s%s' % (INSTALLDIR, TMPDIR, jobid,
                                               jobid, ".summary")
                if os.path.isfile(summaryFile):
                    with open(summaryFile) as f:
                        summaryLine = f.readline().strip()
                        #logopts["pdb"]=logopts.get("pdb", "") + "|" + summaryLine
                        queryString.append(summaryLine)

                outputfilelist = glob.glob('%s%s%s/*.propka' %
                                           (INSTALLDIR, TMPDIR, jobid))
                for i in range(0, len(outputfilelist)):
                    outputfilelist[i] = os.path.basename(outputfilelist[i])
                for extension in ["-typemap.html", ".pqr", ".in"]:
                    if extension != ".in" or apbs_input != False:
                        if extension == "-typemap.html" and typemap == False:
                            continue
                        outputfilelist.append('%s%s' % (jobid, extension))
                for outputfile in outputfilelist:
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                        WEBSITE, TMPDIR, jobid, outputfile, outputfile)

            logopts['queryPDB2PQR'] = '|'.join(queryString)

            #for extension in ["-typemap.html", ".pqr", ".in"]:
            #    print "<li><a href=%s%s%s/%s%s>%s%s</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, extension, jobid, extension)
        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name[-3:] == ".dx":
                        # compressing APBS OpenDX output files
                        currentpath = os.getcwd()
                        zipjobid = filelist[i]._name.split("-")[0]
                        urllib.urlretrieve(
                            filelist[i]._url, '%s%s%s/%s' %
                            (INSTALLDIR, TMPDIR, zipjobid, filelist[i]._name))
                        os.chdir('%s%s%s' % (INSTALLDIR, TMPDIR, zipjobid))
                        # making both the dx file and the compressed file (.gz) available in the directory
                        syscommand = 'cp %s dxbkupfile' % (filelist[i]._name)
                        os.system(syscommand)
                        syscommand = 'gzip -9 ' + filelist[i]._name
                        os.system(syscommand)
                        syscommand = 'mv dxbkupfile %s' % (filelist[i]._name)
                        os.system(syscommand)
                        os.chdir(currentpath)
                        outputfilezip = filelist[i]._name + '.gz'
                        print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                            WEBSITE, TMPDIR, zipjobid, outputfilezip,
                            outputfilezip)
            else:
                outputfilelist = glob.glob('%s%s%s/%s-*.dx' %
                                           (INSTALLDIR, TMPDIR, jobid, jobid))
                for outputfile in outputfilelist:
                    # compressing APBS OpenDX output files
                    currentpath = os.getcwd()
                    workingpath = os.path.dirname(outputfile)
                    os.chdir(workingpath)
                    # making both the dx file and the compressed file (.gz) available in the directory
                    syscommand = 'cp %s dxbkupfile' % (
                        os.path.basename(outputfile))
                    os.system(syscommand)
                    syscommand = 'gzip -9 ' + os.path.basename(outputfile)
                    os.system(syscommand)
                    syscommand = 'mv dxbkupfile %s' % (
                        os.path.basename(outputfile))
                    os.system(syscommand)
                    os.chdir(currentpath)
                    outputfilezip = outputfile + ".gz"
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                        WEBSITE, TMPDIR, jobid,
                        os.path.basename(outputfilezip),
                        os.path.basename(outputfilezip))

            logopts['queryAPBS'] = '|'.join(queryString)

        print "</ul></li>"
        print "<li>Runtime and debugging information<ul>"

        if have_opal:
            stdouturl = resp._stdOut
            stderrurl = resp._stdErr
        else:
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid,
                                                  calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid,
                                                  calctype)

        print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
        print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl

        print "</ul></li></ul>"

        #if have_opal:
        #    resp = appServicePort.getOutputs(getOutputsRequest(jobid))
        #    for opalfile in resp._outputFile:
        #        if opalfile._name[-8:]!="-input.p":
        #            print "<li><a href=%s>%s</a></li>" % (opalfile._url, opalfile._name)
        #    print "<li><a href=%s>Standard output</a></li>" % (resp._stdOut)
        #    print "<li><a href=%s>Standard error</a></li>" % (resp._stdErr)
        #else:
        #    for line in cp[1:]:
        #        line = os.path.basename(line)
        #        if line[-8:]!="-input.p":
        #            if line[-11:]=="_stdout.txt":
        #                printname = "Standard output"
        #            elif line[-11:]=="_stderr.txt":
        #                printname = "Standard error"
        #            else:
        #                printname = line
        #            print "<li><a href=%s>%s</a></li>" % (WEBSITE+TMPDIR+jobid+"/"+line,printname)

        if calctype == "pdb2pqr" and apbs_input and HAVE_APBS != "":
            print "</ul></p><hr><p><b><a href=%s>Click here</a> to run APBS with your results.</b></p>" % nexturl
        elif calctype == "apbs":
            print "</ul></p><hr><p><b><a href=%s>Click here</a> to visualize your results.</b></p>" % nexturl

    elif progress == "error":
        print "There was an error with your query request. This page will not refresh."
    elif progress == "running":
        print "Page will refresh in %d seconds<br />" % refresh
        print "<HR>"
        print "<small>Your results will appear at <a href=%s>this page</a>. If you want, you can bookmark it and come back later (note: results are only stored for approximately 12-24 hours).</small>" % resultsurl
    elif progress == "version_mismatch":
        print "The versions of APBS on the local server and on the Opal server do not match, so the calculation could not be completed"

    print "</P>"
    print "<script type=\"text/javascript\">"
    for key in logopts:
        print getEventTrackingString('queryData', key, logopts[key]),
        #print "_gaq.push(['_trackPageview', '/main_cgi/has_%s_%s.html']);" % (key, logopts[key])
    print "</script>"
    print "</BODY>"
    print "</HTML>"
Esempio n. 11
0
  print "Waiting 30 seconds"
  sleep(30)
  
  # Query job status
  status = appServicePort.queryStatus(queryStatusRequest(jobID))

# If execution is successful retrieve job outputs. 
if status._code == 8: # 8 = GramJob.STATUS_DONE

  # Create local directory to hold output files
  output_dir = 'meme_out'
  mkdir(output_dir);

  # Instantiate a collection of outputs
  outputs = appServicePort.getOutputs(getOutputsRequest(jobID))

  # Instantiate a request object for retrieving output files
  fileRequest = getOutputAsBase64ByNameRequest()

  # Retreive each output file and save to local directory.
  # MEME writes stdout and stderr to files that aren't listed
  # in the response, so we handle those separately.
  print "\tStandard Output:", outputs._stdOut
  localOutput = open(output_dir + '/' + "stdout.txt", "w")
  fileRequest._jobID = jobID
  fileRequest._fileName = "stdout.txt"
  content = appServicePort.getOutputAsBase64ByName(fileRequest)
  print >>localOutput, content
  localOutput.close()
  print "\tStandard Error:", outputs._stdErr
def mainCGI():
    """
        Main method for determining the query page output
    """
    logopts = {}
    print "Content-type: text/html\n\n"
    calctype = form["calctype"].value

    # prints version error, if it exists
    if form["jobid"].value == "False":
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "version_mismatch"
        runtime = 0
    elif form["jobid"].value == "notenoughmem":
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "not_enough_memory"
        runtime = 0
    else:
        progress = None

    # Check for error html
    errorpath = "%s%s%s.html" % (INSTALLDIR, TMPDIR, form["jobid"].value)
    if os.path.isfile(errorpath):
        string = ""
        string += "<html>\n"
        string += "\t<head>\n"
        string += '\t\t<meta http-equiv="Refresh" content="0; url=%s%s%s.html">\n' % (
            WEBSITE,
            TMPDIR,
            form["jobid"].value,
        )
        string += "\t</head>\n"
        string += "</html>\n"
        print string
        return

    # prepares for Opal query, if necessary
    if have_opal:
        if calctype == "pdb2pqr":
            opal_url = PDB2PQR_OPAL_URL
        elif calctype == "apbs":
            opal_url = APBS_OPAL_URL
        appLocator = AppServiceLocator()
        appServicePort = appLocator.getAppServicePort(opal_url)
    else:
        appServicePort = None

    # if PDB2PQR, determines if link to APBS calculation should be shown
    if calctype == "pdb2pqr":
        # if(form["apbsinput"].value=="True"): # change to use a file
        #    apbs_input = True
        # else:
        #    apbs_input = False
        apbsInputFile = open("%s%s%s/apbs_input" % (INSTALLDIR, TMPDIR, form["jobid"].value))
        apbs_input = apbsInputFile.read()
        apbsInputFile.close()
        if apbs_input == "True":
            apbs_input = True
        else:
            apbs_input = False

        typemapInputFile = open("%s%s%s/typemap" % (INSTALLDIR, TMPDIR, form["jobid"].value))
        typemap = typemapInputFile.read()
        typemapInputFile.close()
        if typemap == "True":
            typemap = True
        else:
            typemap = False

    if have_opal and progress == None:
        if form["calctype"].value == "pdb2pqr":
            pdb2pqrJobIDFile = open("%s%s%s/pdb2pqr_opal_job_id" % (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = pdb2pqrJobIDFile.read()
            pdb2pqrJobIDFile.close()
        elif form["calctype"].value == "apbs":
            apbsJobIDFile = open("%s%s%s/apbs_opal_job_id" % (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = apbsJobIDFile.read()
            apbsJobIDFile.close()
    else:
        jobid = form["jobid"].value

    if progress == None:
        cp = checkprogress(jobid, appServicePort, calctype)  # finds out status of job
        progress = cp[0]

    # initialize with bogus value just in case
    starttime = time.time()

    if progress == "running" or progress == "complete":
        timefile = open("%s%s%s/%s_start_time" % (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        starttime = float(timefile.read())
        timefile.close()
    if progress == "running" or (
        have_opal and progress != "version_mismatch" and progress != "not_enough_memory" and progress != "error"
    ):
        runtime = time.time() - starttime
    elif progress == "complete":
        endtimefile = open("%s%s%s/%s_end_time" % (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        runtime = float(endtimefile.read()) - starttime
    else:
        runtime = -1

    if progress == "running":
        # if have_opal:
        #    resultsurl = cp[1]._baseURL
        # else:
        if calctype == "pdb2pqr":
            resultsurl = "%squerystatus.cgi?jobid=%s&apbsinput=%s&calctype=pdb2pqr" % (
                WEBSITE,
                form["jobid"].value,
                apbs_input,
            )
        else:
            resultsurl = "%squerystatus.cgi?jobid=%s&calctype=apbs" % (WEBSITE, form["jobid"].value)

    if progress == "complete":
        print printheader("%s Job Status Page" % calctype.upper())

    elif progress == "error":
        print printheader("%s Job Status Page - Error" % calctype.upper(), 0)

    elif progress == "running":  # job is not complete, refresh in 30 seconds
        print printheader("%s Job Status Page" % calctype.upper(), refresh)

    print "<BODY>\n<P>"
    print "<h3>Status"
    print "</h3>"
    print "Message: %s<br />" % progress
    print "Run time: %s seconds<br />" % int(runtime)
    print "Current time: %s<br />" % time.asctime()
    print "</P>\n<HR>\n<P>"

    if progress == "complete":
        if calctype == "pdb2pqr":
            nexturl = "apbs_cgi.cgi?jobid=%s" % form["jobid"].value
        else:
            nexturl = "visualize.cgi?jobid=%s" % form["jobid"].value

        if have_opal:
            resp = appServicePort.getOutputs(getOutputsRequest(jobid))
            filelist = resp._outputFile

        print "Here are the results:<ul>"
        print "<li>Input files<ul>"

        if calctype == "pdb2pqr":
            # this code should be cleaned up once local PDB2PQR runs output the PDB file with the .pdb extension
            if have_opal:
                for i in range(0, len(filelist)):
                    if len(filelist[i]._name) == 4:
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/%s.pdb>%s.pdb</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, jobid)

        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name == "apbsinput.in" or filelist[i]._name[-4:] == ".pqr":
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/apbsinput.in>apbsinput.in</a></li>" % (WEBSITE, TMPDIR, jobid)
                print "<li><a href=%s%s%s/%s.pqr>%s.pqr</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, jobid)

        print "</ul></li>"
        print "<li>Output files<ul>"

        if calctype == "pdb2pqr":
            if have_opal:
                # Getting PDB2PQR Opal run log info
                if os.path.isfile("%s%s%s/pdb2pqr_opal_log" % (INSTALLDIR, TMPDIR, form["jobid"].value)):
                    pdb2pqrOpalLogFile = open(
                        "%s%s%s/pdb2pqr_opal_log" % (INSTALLDIR, TMPDIR, form["jobid"].value), "r"
                    )
                    logstr = pdb2pqrOpalLogFile.read().split("\n")
                    logopts = eval(logstr[0])
                    #                    logff = logstr[1]
                    #                    REMOTE_ADDR = logstr[2]
                    pdb2pqrOpalLogFile.close()
                for i in range(0, len(filelist)):
                    if (
                        filelist[i]._name[-7:] == ".propka"
                        or (filelist[i]._name[-13:] == "-typemap.html" and typemap == True)
                        or filelist[i]._name[-4:] == ".pqr"
                        or filelist[i]._name[-3:] == ".in"
                    ):
                        if filelist[i]._name[-4:] == ".pqr":
                            # Getting pqr file length for PDB2PQR Opal run
                            f = urllib.urlopen(filelist[i]._url)
                            pqrOpalFileLength = len(f.readlines())
                            f.close()
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)
            #                logRun(logopts, runtime, pqrOpalFileLength, logff, REMOTE_ADDR)
            else:
                outputfilelist = glob.glob("%s%s%s/*.propka" % (INSTALLDIR, TMPDIR, jobid))
                for i in range(0, len(outputfilelist)):
                    outputfilelist[i] = os.path.basename(outputfilelist[i])
                for extension in ["-typemap.html", ".pqr", ".in"]:
                    if extension != ".in" or apbs_input != False:
                        if extension == "-typemap.html" and typemap == False:
                            continue
                        outputfilelist.append("%s%s" % (jobid, extension))
                for outputfile in outputfilelist:
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, jobid, outputfile, outputfile)

                # for extension in ["-typemap.html", ".pqr", ".in"]:
                #    print "<li><a href=%s%s%s/%s%s>%s%s</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, extension, jobid, extension)
        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name[-3:] == ".dx":
                        # compressing APBS OpenDX output files
                        currentpath = os.getcwd()
                        zipjobid = filelist[i]._name.split("-")[0]
                        urllib.urlretrieve(
                            filelist[i]._url, "%s%s%s/%s" % (INSTALLDIR, TMPDIR, zipjobid, filelist[i]._name)
                        )
                        os.chdir("%s%s%s" % (INSTALLDIR, TMPDIR, zipjobid))
                        # making both the dx file and the compressed file (.gz) available in the directory
                        syscommand = "cp %s dxbkupfile" % (filelist[i]._name)
                        os.system(syscommand)
                        syscommand = "gzip -9 " + filelist[i]._name
                        os.system(syscommand)
                        syscommand = "mv dxbkupfile %s" % (filelist[i]._name)
                        os.system(syscommand)
                        os.chdir(currentpath)
                        outputfilezip = filelist[i]._name + ".gz"
                        print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                            WEBSITE,
                            TMPDIR,
                            zipjobid,
                            outputfilezip,
                            outputfilezip,
                        )
            else:
                outputfilelist = glob.glob("%s%s%s/%s-*.dx" % (INSTALLDIR, TMPDIR, jobid, jobid))
                for outputfile in outputfilelist:
                    # compressing APBS OpenDX output files
                    currentpath = os.getcwd()
                    workingpath = os.path.dirname(outputfile)
                    os.chdir(workingpath)
                    # making both the dx file and the compressed file (.gz) available in the directory
                    syscommand = "cp %s dxbkupfile" % (os.path.basename(outputfile))
                    os.system(syscommand)
                    syscommand = "gzip -9 " + os.path.basename(outputfile)
                    os.system(syscommand)
                    syscommand = "mv dxbkupfile %s" % (os.path.basename(outputfile))
                    os.system(syscommand)
                    os.chdir(currentpath)
                    outputfilezip = outputfile + ".gz"
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                        WEBSITE,
                        TMPDIR,
                        jobid,
                        os.path.basename(outputfilezip),
                        os.path.basename(outputfilezip),
                    )

        print "</ul></li>"
        print "<li>Runtime and debugging information<ul>"

        if have_opal:
            stdouturl = resp._stdOut
            stderrurl = resp._stdErr
        else:
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid, calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid, calctype)

        print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
        print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl

        print "</ul></li></ul>"

        # if have_opal:
        #    resp = appServicePort.getOutputs(getOutputsRequest(jobid))
        #    for opalfile in resp._outputFile:
        #        if opalfile._name[-8:]!="-input.p":
        #            print "<li><a href=%s>%s</a></li>" % (opalfile._url, opalfile._name)
        #    print "<li><a href=%s>Standard output</a></li>" % (resp._stdOut)
        #    print "<li><a href=%s>Standard error</a></li>" % (resp._stdErr)
        # else:
        #    for line in cp[1:]:
        #        line = os.path.basename(line)
        #        if line[-8:]!="-input.p":
        #            if line[-11:]=="_stdout.txt":
        #                printname = "Standard output"
        #            elif line[-11:]=="_stderr.txt":
        #                printname = "Standard error"
        #            else:
        #                printname = line
        #            print "<li><a href=%s>%s</a></li>" % (WEBSITE+TMPDIR+jobid+"/"+line,printname)

        if calctype == "pdb2pqr" and apbs_input and HAVE_APBS != "":
            print "</ul></p><hr><p><a href=%s>Click here</a> to run APBS with your results.</p>" % nexturl
        elif calctype == "apbs":
            print "</ul></p><hr><p><a href=%s>Click here</a> to visualize your results.</p>" % nexturl

    elif progress == "error":
        print "There was an error with your query request. This page will not refresh."
    elif progress == "running":
        print "Page will refresh in %d seconds<br />" % refresh
        print "<HR>"
        print "<small>Your results will appear at <a href=%s>this page</a>. If you want, you can bookmark it and come back later (note: results are only stored for approximately 12-24 hours).</small>" % resultsurl
    elif progress == "version_mismatch":
        print "The versions of APBS on the local server and on the Opal server do not match, so the calculation could not be completed"

    print "</P>"
    print '<script type="text/javascript">'
    print 'var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");'
    print "document.write(unescape(\"%3Cscript src='\" + gaJsHost + \"google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E\"));"
    print "</script>"
    print '<script type="text/javascript">'
    print "try {"
    print 'var pageTracker = _gat._getTracker("UA-11026338-3");'
    if logopts != {}:
        for key in logopts:
            print 'pageTracker._trackPageview("/main_cgi/has_%s_%s.html");' % (key, logopts[key])
    print "pageTracker._trackPageview();"
    print "} catch(err) {}</script>"
    print "</BODY>"
    print "</HTML>"
Esempio n. 13
0
    print "Waiting 30 seconds"
    sleep(30)

    # Query job status
    status = appServicePort.queryStatus(queryStatusRequest(jobID))

# If execution is successful retrieve job outputs.
if status._code == 8:  # 8 = GramJob.STATUS_DONE

    # Create local directory to hold output files
    output_dir = "meme_out"
    mkdir(output_dir)

    # Instantiate a collection of outputs
    outputs = appServicePort.getOutputs(getOutputsRequest(jobID))

    # Instantiate a request object for retrieving output files
    fileRequest = getOutputAsBase64ByNameRequest()

    # Retreive each output file and save to local directory.
    # MEME writes stdout and stderr to files that aren't listed
    # in the response, so we handle those separately.
    print "\tStandard Output:", outputs._stdOut
    localOutput = open(output_dir + "/" + "stdout.txt", "w")
    fileRequest._jobID = jobID
    fileRequest._fileName = "stdout.txt"
    content = appServicePort.getOutputAsBase64ByName(fileRequest)
    print >> localOutput, content
    localOutput.close()
    print "\tStandard Error:", outputs._stdErr
Esempio n. 14
0
def mainCGI():
    """
        Main method for determining the query page output
    """
    logopts = {}
    print "Content-type: text/html\n\n"
    calctype = form["calctype"].value

    # prints version error, if it exists
    if form["jobid"].value == 'False':
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "version_mismatch"
        runtime = 0
    elif form["jobid"].value == 'notenoughmem':
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "not_enough_memory"
        runtime = 0
    else:
        progress = None

    #Check for error html
    errorpath = '%s%s%s.html' % (INSTALLDIR, TMPDIR, form["jobid"].value)
    if os.path.isfile(errorpath):
        string = ""
        string+= "<html>\n"
        string+= "\t<head>\n"
        string+= "\t\t<meta http-equiv=\"Refresh\" content=\"0; url=%s%s%s.html\">\n" % (WEBSITE, TMPDIR, form["jobid"].value)
        string+= "\t</head>\n"
        string+= "</html>\n"
        print string
        return

    # prepares for Opal query, if necessary
    if have_opal:
        if calctype=="pdb2pqr":
            opal_url = PDB2PQR_OPAL_URL
        elif calctype=="apbs":
            opal_url = APBS_OPAL_URL
        appLocator = AppServiceLocator()
        appServicePort = appLocator.getAppServicePort(opal_url)
    else:
        appServicePort = None

    # if PDB2PQR, determines if link to APBS calculation should be shown
    if calctype=="pdb2pqr":
        #if(form["apbsinput"].value=="True"): # change to use a file
        #    apbs_input = True
        #else:
        #    apbs_input = False
        apbsInputFile = open('%s%s%s/apbs_input' % (INSTALLDIR, TMPDIR, form["jobid"].value))
        apbs_input = apbsInputFile.read()
        apbsInputFile.close()
        if apbs_input=="True":
            apbs_input = True
        else:
            apbs_input = False

        typemapInputFile = open('%s%s%s/typemap' % (INSTALLDIR, TMPDIR, form["jobid"].value))
        typemap = typemapInputFile.read()
        typemapInputFile.close()
        if typemap=="True":
            typemap = True
        else:
            typemap = False

    if have_opal and progress == None:
        if form["calctype"].value=="pdb2pqr":
            pdb2pqrJobIDFile = open('%s%s%s/pdb2pqr_opal_job_id' % (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = pdb2pqrJobIDFile.read()
            pdb2pqrJobIDFile.close()
        elif form["calctype"].value=="apbs":
            apbsJobIDFile = open('%s%s%s/apbs_opal_job_id' % (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = apbsJobIDFile.read()
            apbsJobIDFile.close()
    else:
        jobid = form["jobid"].value

    if progress == None:
        cp = checkprogress(jobid,appServicePort,calctype) # finds out status of job
        progress = cp[0]

    #initialize with bogus value just in case
    starttime = time.time()

    if progress == "running" or progress == "complete":
        timefile = open('%s%s%s/%s_start_time' % (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        starttime = float(timefile.read())
        timefile.close()

    if progress == "running" or (have_opal and progress not in ("version_mismatch",
                                                                "not_enough_memory",
                                                                "error",
                                                                "complete")):
        runtime = time.time()-starttime
        runtime = int(runtime)

    elif progress == "complete":
        endTimeFileString = '%s%s%s/%s_end_time' % (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value)
        if have_opal and not os.path.isfile(endTimeFileString):
            runtime = time.time()-starttime
            with open(endTimeFileString, 'w') as endTimeFile:
                endTimeFile.write(str(time.time()))
        else:
            with open(endTimeFileString, 'r') as endTimeFile:
                runtime = float(endTimeFile.read())-starttime
    else:
        runtime = -1

    if progress == "running":
        #if have_opal:
        #    resultsurl = cp[1]._baseURL
        #else:
        if calctype=="pdb2pqr":
            resultsurl = '%squerystatus.cgi?jobid=%s&apbsinput=%s&calctype=pdb2pqr' % (WEBSITE, form["jobid"].value, apbs_input)
        else:
            resultsurl = '%squerystatus.cgi?jobid=%s&calctype=apbs' % (WEBSITE, form["jobid"].value)

    if progress == "complete":
        print printheader("%s Job Status Page" % calctype.upper(), jobid=form["jobid"].value)

    elif progress == "error":
        print printheader("%s Job Status Page - Error" % calctype.upper(),0, jobid=form["jobid"].value)

    elif progress == "running": # job is not complete, refresh in 30 seconds
        print printheader("%s Job Status Page" % calctype.upper(), refresh, jobid=form["jobid"].value)

    print "<BODY>\n<P>"
    print "<p></p>"
    print '<div id="content">'
    print "<h3>Status:"

    color = "FA3434"
    image = WEBSITE+"images/red_x.png"

    if progress == "complete":
        color = "2CDE56"
        image = WEBSITE+"images/green_check.png"
    elif progress == "running":
        color = "ffcc00"
        image = WEBSITE+"images/yellow_exclamation.png"

    print "<strong style=\"color:#%s;\">%s</strong>" % (color, progress)
    print "<img src=\"%s\"><br />" % image
    print "</h3>"
    print "Run time: " + str(timedelta(seconds=round(runtime))) + '<br />'
    print "Current time: %s<br />" % time.asctime()
    print "</P>\n<HR>\n<P>"

    if progress == "complete":
        if calctype=="pdb2pqr":
            nexturl = 'apbs_cgi.cgi?jobid=%s' % form["jobid"].value
        else:
            url_3dmol = 'visualize.cgi?jobid=%s&tool=%s' % (form["jobid"].value,'tool_3dmol')
            url_jmol = 'visualize.cgi?jobid=%s&tool=%s' % (form["jobid"].value,'tool_jmol')


        if have_opal:
            resp = appServicePort.getOutputs(getOutputsRequest(jobid))
            filelist = resp._outputFile

        print "Here are the results:<ul>"
        print "<li>Input files<ul>"

        if calctype=="pdb2pqr":
            # this code should be cleaned up once local PDB2PQR runs output the PDB file with the .pdb extension
            if have_opal:
                for i in range(0,len(filelist)):
                    file_name = filelist[i]._name
                    if ((len(file_name) == 4 and '.' not in file_name) or
                        (file_name.lower().endswith(".pdb") and "pdb2pka_output" not in file_name)):
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)

                    if file_name.lower().endswith((".mol", ".mol2", ".names", ".dat")) and "pdb2pka_output" not in file_name:
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)


            else:
                print "<li><a href=%s%s%s/%s.pdb>%s.pdb</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, jobid)

        elif calctype=="apbs":
            if have_opal:
                for i in range(0,len(filelist)):
                    if filelist[i]._name == "apbsinput.in" or filelist[i]._name[-4:] == ".pqr":
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/apbsinput.in>apbsinput.in</a></li>" % (WEBSITE, TMPDIR, jobid)
                print "<li><a href=%s%s%s/%s.pqr>%s.pqr</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, jobid)

        print "</ul></li>"
        print "<li>Output files<ul>"

        queryString = [str(os.environ["REMOTE_ADDR"])]
        # Getting PDB2PQR run log info
        if os.path.isfile('%s%s%s/pdb2pqr_log' % (INSTALLDIR, TMPDIR, jobid)):
            pdb2pqrLogFile=open('%s%s%s/pdb2pqr_log' % (INSTALLDIR, TMPDIR, jobid), 'r')
            logstr=pdb2pqrLogFile.read().split('\n')
            templogopts = eval(logstr[0])
            pdb2pqrLogFile.close()
            queryString.insert(0, templogopts.get('pdb',''))

        if calctype=="pdb2pqr":
            if have_opal:
                for i in range(0,len(filelist)):
                    if filelist[i]._name.endswith((".propka", "-typemap.html")):
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)

                    if filelist[i]._name.endswith(".in") and "pdb2pka_output" not in filelist[i]._name:
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)

                    if filelist[i]._name.endswith(".pqr") and not filelist[i]._name.endswith("background_input.pqr"):
                        print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)

                    #Get the first line of the summary file.
                    if filelist[i]._name.endswith(".summary"):
                        f=urllib.urlopen(filelist[i]._url)
                        summaryLine = f.readline().strip()
                        #logopts["pdb"]=logopts.get("pdb", "") + "|" + summaryLine
                        queryString.append(summaryLine)
                        f.close()
#                logRun(logopts, runtime, pqrOpalFileLength, logff, REMOTE_ADDR)
            else:
                #Get the first line of the summary file.
                summaryFile = '%s%s%s/%s%s' % (INSTALLDIR, TMPDIR, jobid, jobid, ".summary")
                if os.path.isfile(summaryFile):
                    with open(summaryFile) as f:
                        summaryLine = f.readline().strip()
                        #logopts["pdb"]=logopts.get("pdb", "") + "|" + summaryLine
                        queryString.append(summaryLine)

                outputfilelist = glob.glob('%s%s%s/*.propka' % (INSTALLDIR, TMPDIR, jobid))
                for i in range(0,len(outputfilelist)):
                    outputfilelist[i] = os.path.basename(outputfilelist[i])
                for extension in ["-typemap.html", ".pqr", ".in"]:
                    if extension != ".in" or apbs_input != False:
                        if extension == "-typemap.html" and typemap == False:
                            continue
                        outputfilelist.append('%s%s' % (jobid, extension))
                for outputfile in outputfilelist:
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, jobid, outputfile, outputfile)

            logopts['queryPDB2PQR'] = '|'.join(queryString)

                #for extension in ["-typemap.html", ".pqr", ".in"]:
                #    print "<li><a href=%s%s%s/%s%s>%s%s</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, extension, jobid, extension)
        elif calctype=="apbs":
            if have_opal:
                for i in range(0,len(filelist)):
                    if filelist[i]._name[-3:]==".dx":
                        # compressing APBS OpenDX output files
                        currentpath = os.getcwd()
                        zipjobid = filelist[i]._name.split("-")[0]
                        dxfilename = '%s%s%s/%s' % (INSTALLDIR, TMPDIR, zipjobid, filelist[i]._name)
                        urllib.urlretrieve(filelist[i]._url, dxfilename)
                        os.chdir('%s%s%s' % (INSTALLDIR, TMPDIR, zipjobid))
                        # making both the dx file and the compressed file (.gz) available in the directory
                        syscommand = 'cp %s dxbkupfile' % (filelist[i]._name)
                        os.system(syscommand)
                        syscommand = 'gzip -9 ' + filelist[i]._name
                        os.system(syscommand)
                        syscommand = 'mv dxbkupfile %s' % (filelist[i]._name)
                        os.system(syscommand)
                        outputfilezip = filelist[i]._name + '.gz'

                        pqrfilename = '%s%s%s/%s.pqr' % (INSTALLDIR, TMPDIR, zipjobid, zipjobid)
                        cubefilename = '%s%s%s/%s.cube' % (INSTALLDIR, TMPDIR, zipjobid, zipjobid)

                        # making both the cube file and the compressed file (.gz) available in the directory
                        createcube(dxfilename, pqrfilename, cubefilename)
                        cubefilebasename = os.path.basename(cubefilename)

                        syscommand = 'cp %s cubebkupfile' % cubefilebasename
                        os.system(syscommand)
                        syscommand = 'gzip -9 ' + cubefilebasename
                        os.system(syscommand)
                        syscommand = 'mv cubebkupfile %s' % cubefilebasename
                        os.system(syscommand)
                        os.chdir(currentpath)
                        outputcubefilezip = cubefilebasename+".gz"

                        print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, zipjobid, outputfilezip, outputfilezip)
                        print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, zipjobid, outputcubefilezip, outputcubefilezip)

            else:
                outputfilelist = glob.glob('%s%s%s/%s-*.dx' % (INSTALLDIR, TMPDIR, jobid, jobid))
                for dxfile in outputfilelist:
                    # compressing APBS OpenDX output files
                    currentpath = os.getcwd()
                    workingpath = os.path.dirname(dxfile)
                    os.chdir(workingpath)
                    # making both the dx file and the compressed file (.gz) available in the directory
                    syscommand = 'cp %s dxbkupfile' % (os.path.basename(dxfile))
                    os.system(syscommand)
                    syscommand = 'gzip -9 ' + os.path.basename(dxfile)
                    os.system(syscommand)
                    syscommand = 'mv dxbkupfile %s' % (os.path.basename(dxfile))
                    os.system(syscommand)
                    os.chdir(currentpath)
                    outputfilezip = dxfile+".gz"



                    cubefilename = '%s%s%s/%s.cube' % (INSTALLDIR, TMPDIR, jobid, jobid)
                    pqrfilename = '%s%s%s/%s.pqr' % (INSTALLDIR, TMPDIR, jobid, jobid)


                    createcube(dxfile, pqrfilename, cubefilename)

                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, jobid, os.path.basename(outputfilezip), os.path.basename(outputfilezip))

                outputcubefilelist = glob.glob('%s%s%s/%s.cube' % (INSTALLDIR, TMPDIR, jobid, jobid))
                for cubefile in outputcubefilelist:
                    # compressing cube output file
                    currentpath = os.getcwd()
                    os.chdir(workingpath)
                    # making both the cube file and the compressed file (.gz) available in the directory
                    syscommand = 'cp %s cubebkupfile' % (os.path.basename(cubefile))
                    os.system(syscommand)
                    syscommand = 'gzip -9 ' + os.path.basename(cubefile)
                    os.system(syscommand)
                    syscommand = 'mv cubebkupfile %s' % (os.path.basename(cubefile))
                    os.system(syscommand)
                    os.chdir(currentpath)
                    outputcubefilezip = cubefile+".gz"

                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (WEBSITE, TMPDIR, jobid, os.path.basename(outputcubefilezip), os.path.basename(outputcubefilezip))

            logopts['queryAPBS'] = '|'.join(queryString)

        if calctype=="pdb2pqr":
            if have_opal:
                outputfilelist = []
                for i in range(0,len(filelist)):
                    if filelist[i]._name.endswith((".DAT", ".txt")):
                        outputfilelist.append((filelist[i]._url, os.path.basename(filelist[i]._name)))
                        #print "<li><a href=%s>%s</a></li>" % (filelist[i]._url, filelist[i]._name)
                if outputfilelist:
                    print "</ul></li>"
                    print "<li>PDB2PKA files<ul>"
                    for outputfile in outputfilelist:
                        print "<li><a href=%s>%s</a></li>" % (outputfile[0], outputfile[1])
            else:
                outputfilelist = glob.glob('%s%s%s/pdb2pka_output/*.DAT' % (INSTALLDIR, TMPDIR, jobid))
                outputfilelist.extend(glob.glob('%s%s%s/pdb2pka_output/*.txt' % (INSTALLDIR, TMPDIR, jobid)))
                outputfilelist = [os.path.basename(outputfile) for outputfile in outputfilelist]
                if outputfilelist:
                    print "</ul></li>"
                    print "<li>PDB2PKA files<ul>"
                    for outputfile in outputfilelist:
                        print "<li><a href=%s%s%s/pdb2pka_output/%s>%s</a></li>" % (WEBSITE, TMPDIR, jobid, outputfile, outputfile)

        print "</ul></li>"
        print "<li>Runtime and debugging information<ul>"

        if have_opal:
            stdouturl = resp._stdOut
            stderrurl = resp._stdErr
        else:
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid, calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid, calctype)

        print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
        print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl


        print "</ul></li></ul>"


        #if have_opal:
        #    resp = appServicePort.getOutputs(getOutputsRequest(jobid))
        #    for opalfile in resp._outputFile:
        #        if opalfile._name[-8:]!="-input.p":
        #            print "<li><a href=%s>%s</a></li>" % (opalfile._url, opalfile._name)
        #    print "<li><a href=%s>Standard output</a></li>" % (resp._stdOut)
        #    print "<li><a href=%s>Standard error</a></li>" % (resp._stdErr)
        #else:
        #    for line in cp[1:]:
        #        line = os.path.basename(line)
        #        if line[-8:]!="-input.p":
        #            if line[-11:]=="_stdout.txt":
        #                printname = "Standard output"
        #            elif line[-11:]=="_stderr.txt":
        #                printname = "Standard error"
        #            else:
        #                printname = line
        #            print "<li><a href=%s>%s</a></li>" % (WEBSITE+TMPDIR+jobid+"/"+line,printname)

        if calctype=="pdb2pqr" and apbs_input and HAVE_APBS:
            print "</ul></p><hr><p><b><a href=%s>Click here</a> to run APBS with your results.</b></p>" % nexturl
        elif calctype=="apbs":
            #print "</ul></p><hr><p><b><a href=%s>Click here</a> to visualize your results in Jmol.</b></p>" % nexturl
            print "</ul></p><hr><p><b>Visualize your results online:"
            print "<ul> <li><a href=%s>3Dmol</a></li><li><a href=%s>Jmol</a></li></ul>" % (url_3dmol, url_jmol)

    elif progress == "error":
        print "There was an error with your query request. This page will not refresh."

        print "</ul></li>"
        print "<li>Runtime and debugging information<ul>"

        if have_opal:
            resp = appServicePort.getOutputs(getOutputsRequest(jobid))
            stdouturl = resp._stdOut
            stderrurl = resp._stdErr

        else:
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid, calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid, calctype)

        print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
        print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl

        print "</ul></li></ul>"

        if have_opal:
            print " <br />If your job has been running for a prolonged period of time and failed with no reason listed in the standard out or standard error, then the job probably timed out and was terminated by the system.<br />"

        print '<br />If you are having trouble running PDB2PQR on the webserver, please download the <a href="http://www.poissonboltzmann.org/docs/downloads/">command line version of PDB2PQR</a> and run the job from there.'



    elif progress == "running":
        print "Page will refresh in %d seconds<br />" % refresh
        print "<HR>"

        if not have_opal:
            print "</ul></li>"
            print "<li>Runtime and debugging information<ul>"
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid, calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid, calctype)
            print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
            print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl
            print "</ul></li></ul>"

        print "<small>Your results will appear at <a href=%s>this page</a>. If you want, you can bookmark it and come back later (note: results are only stored for approximately 12-24 hours).</small>" % resultsurl
    elif progress == "version_mismatch":
        print "The versions of APBS on the local server and on the Opal server do not match, so the calculation could not be completed"

    print "</P>"
    print "<script type=\"text/javascript\">"
    for key in logopts:
        print getEventTrackingString('queryData', key, logopts[key]),
        #print "_gaq.push(['_trackPageview', '/main_cgi/has_%s_%s.html']);" % (key, logopts[key])
    print "</script>"
    print "</div> <!--end content div-->"
    print "</BODY>"
    print "</HTML>"
Esempio n. 15
0
        def ws_compute(self):
            if self._port_list[0][3]['url'] != None:
                url = self._port_list[0][3]['url']
                adv = self._port_list[0][3]['adv']
            else:
                url = ""
                print "ERROR: There are no input arguments provided for this web service"

            cmdline = ""
            numProcs = None
            tagged = []
            untagged = []
            flags = []
            files = []

            for i in self._port_list:
                pn = i[0]
                meta = i[3]

                if ((self.hasInputFromPort(pn) and self.getInputFromPort(pn) != "") or meta['default'] != None) and adv == True:
#                    print "META"
#                    print meta

                    if meta['type'] == 'FLAG':
                        if self.hasInputFromPort(pn):
                            if self.getInputFromPort(pn) == True:
                                flags.append(meta['arg'])
                        elif meta['default'] == 'True':
                            flags.append(meta['arg'])
                    elif meta['type'] == 'TAGGED':
                        if self.hasInputFromPort(pn):
                            val = self.getInputFromPort(pn)
                        elif meta['default'] != None:
                            val = meta['default']

                        if meta['file'] == True:
                            file_an = core.modules.basic_modules.File.translate_to_string(val)
                            file_bn = os.path.basename(file_an)
                            tagged.append(meta['arg'] + file_bn)
                            files.append(file_an)
                        else:
                            tagged.append(meta['arg'] + val)
                    elif meta['type'] == 'UNTAGGED':
                        if self.hasInputFromPort(pn):
                            val = self.getInputFromPort(pn)
                        elif meta['default'] != None:
                            val = meta['default']

                        if meta['file'] == True:
                            file_an = core.modules.basic_modules.File.translate_to_string(val)
                            file_bn = os.path.basename(file_an)
                            untagged.append(file_bn)
                            files.append(file_an)
                        else:
                            untagged.append(val)
                            
                    cmdline = ""

                    for i in flags:
                        cmdline += i + " "
                    for i in tagged:
                        cmdline += i + " "
                    for i in untagged:
                        cmdline += i + " "

            inputFiles = []

            for i in files:
                inputFile = ns0.InputFileType_Def('inputFile')
                inputFile._name = os.path.basename(i)                     
                inputFile._attachment = open(i, "r")
                inputFiles.append(inputFile)

            if cmdline == "":
                if self.hasInputFromPort('commandLine'):
                    cmdline = self.getInputFromPort('commandLine')
                if self.hasInputFromPort('numProcs'):
                    numProcs = self.getInputFromPort('numProcs')
                if self.hasInputFromPort("inFiles"):
                    inFilesPath = self.getInputFromPort("inFiles")
                    if inFilesPath != None:
                        for i in inFilesPath:
                            inputFile = ns0.InputFileType_Def('inputFile')
                            inputFile._name = os.path.basename(i)                     
                            inputFile._attachment = open(i, "r")
                            inputFiles.append(inputFile)
            
            print os.path.basename(url) + " from " + os.path.dirname(url) + " is going to run with arguments:\n     " + cmdline 

            appLocator = AppServiceLocator()
            appServicePort = appLocator.getAppServicePort(url)
            req = launchJobRequest()
            req._argList = cmdline
            req._inputFile = inputFiles
            if numProcs != None:
                req._numProcs = numProcs
            resp = appServicePort.launchJob(req)
            self.jobID = resp._jobID
            print "Job outputs URL: " + resp._status._baseURL # urlparse.urljoin(url, '/' + self.jobID)
            status = resp._status._code

            while (status != 4 and status != 8):
                status = appServicePort.queryStatus(queryStatusRequest(self.jobID))._code
                time.sleep(5)
             
            if (status == 8):
                resp = appServicePort.getOutputs(getOutputsRequest(self.jobID))
                outurls = [str(resp._stdOut), str(resp._stdErr)]
                if (resp._outputFile != None):
                    for i in resp._outputFile:
                        outurls.append(str(i._url))
                    print "Opal job completed successfully"
            else:
                print "ERROR: Opal job failed"
                resp = appServicePort.getOutputs(getOutputsRequest(self.jobID))
                outurls = [str(resp._stdOut), str(resp._stdErr)]

            self.setResult("outurls", tuple(outurls))
Esempio n. 16
0
def mainCGI():
    """
        Main method for determining the query page output
    """
    logopts = {}
    print "Content-type: text/html\n\n"
    calctype = form["calctype"].value

    # prints version error, if it exists
    if form["jobid"].value == 'False':
        print printheader("%s Job Status Page" % calctype.upper())
        progress = "version_mismatch"
        runtime = 0
    else:
        progress = None

    # prepares for Opal query, if necessary
    if have_opal:
        if calctype == "pdb2pqr":
            opal_url = PDB2PQR_OPAL_URL
        elif calctype == "apbs":
            opal_url = APBS_OPAL_URL
        appLocator = AppServiceLocator()
        appServicePort = appLocator.getAppServicePort(opal_url)
    else:
        appServicePort = None

    # if PDB2PQR, determines if link to APBS calculation should be shown
    if calctype == "pdb2pqr":
        #if(form["apbsinput"].value=="True"): # change to use a file
        #    apbs_input = True
        #else:
        #    apbs_input = False
        apbsInputFile = open('%s%s%s/apbs_input' %
                             (INSTALLDIR, TMPDIR, form["jobid"].value))
        apbs_input = apbsInputFile.read()
        apbsInputFile.close()
        if apbs_input == "True":
            apbs_input = True
        else:
            apbs_input = False

        typemapInputFile = open('%s%s%s/typemap' %
                                (INSTALLDIR, TMPDIR, form["jobid"].value))
        typemap = typemapInputFile.read()
        typemapInputFile.close()
        if typemap == "True":
            typemap = True
        else:
            typemap = False

    if have_opal and progress == None:
        if form["calctype"].value == "pdb2pqr":
            pdb2pqrJobIDFile = open('%s%s%s/pdb2pqr_opal_job_id' %
                                    (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = pdb2pqrJobIDFile.read()
            pdb2pqrJobIDFile.close()
        elif form["calctype"].value == "apbs":
            apbsJobIDFile = open('%s%s%s/apbs_opal_job_id' %
                                 (INSTALLDIR, TMPDIR, form["jobid"].value))
            jobid = apbsJobIDFile.read()
            apbsJobIDFile.close()
    else:
        jobid = form["jobid"].value

    if progress == None:
        cp = checkprogress(jobid, appServicePort,
                           calctype)  # finds out status of job
        progress = cp[0]

    if progress == "running" or progress == "complete":
        timefile = open(
            '%s%s%s/%s_start_time' %
            (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        starttime = float(timefile.read())
        timefile.close()
    if progress == "running" or (have_opal and progress != "version_mismatch"):
        runtime = time.time() - starttime
    elif progress == "complete":
        endtimefile = open(
            '%s%s%s/%s_end_time' %
            (INSTALLDIR, TMPDIR, form["jobid"].value, form["calctype"].value))
        runtime = float(endtimefile.read()) - starttime

    if progress == "running":
        #if have_opal:
        #    resultsurl = cp[1]._baseURL
        #else:
        if calctype == "pdb2pqr":
            resultsurl = '%squerystatus.cgi?jobid=%s&apbsinput=%s&calctype=pdb2pqr' % (
                WEBSITE, form["jobid"].value, apbs_input)
        else:
            resultsurl = '%squerystatus.cgi?jobid=%s&calctype=apbs' % (
                WEBSITE, form["jobid"].value)

    if progress == "complete":
        print printheader("%s Job Status Page" % calctype.upper())

    elif progress == "error":
        print printheader("%s Job Status Page - Error" % calctype.upper(), 0)

    elif progress == "running":  # job is not complete, refresh in 30 seconds
        print printheader("%s Job Status Page" % calctype.upper(), refresh)

    print "<BODY>\n<P>"
    print "<h3>Status"
    print "</h3>"
    print "Message: %s<br />" % progress
    print "Run time: %s seconds<br />" % int(runtime)
    print "Current time: %s<br />" % time.asctime()
    print "</P>\n<HR>\n<P>"

    if progress == "complete":
        if calctype == "pdb2pqr":
            nexturl = 'apbs_cgi.cgi?jobid=%s' % form["jobid"].value
        else:
            nexturl = 'visualize.cgi?jobid=%s' % form["jobid"].value

        if have_opal:
            resp = appServicePort.getOutputs(getOutputsRequest(jobid))
            filelist = resp._outputFile

        print "Here are the results:<ul>"
        print "<li>Input files<ul>"

        if calctype == "pdb2pqr":
            # this code should be cleaned up once local PDB2PQR runs output the PDB file with the .pdb extension
            if have_opal:
                for i in range(0, len(filelist)):
                    if len(filelist[i]._name) == 4:
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/%s.pdb>%s.pdb</a></li>" % (
                    WEBSITE, TMPDIR, jobid, jobid, jobid)

        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name == "apbsinput.in" or filelist[
                            i]._name[-4:] == ".pqr":
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)
            else:
                print "<li><a href=%s%s%s/apbsinput.in>apbsinput.in</a></li>" % (
                    WEBSITE, TMPDIR, jobid)
                print "<li><a href=%s%s%s/%s.pqr>%s.pqr</a></li>" % (
                    WEBSITE, TMPDIR, jobid, jobid, jobid)

        print "</ul></li>"
        print "<li>Output files<ul>"

        if calctype == "pdb2pqr":
            if have_opal:
                # Getting PDB2PQR Opal run log info
                if os.path.isfile('%s%s%s/pdb2pqr_opal_log' %
                                  (INSTALLDIR, TMPDIR, form["jobid"].value)):
                    pdb2pqrOpalLogFile = open(
                        '%s%s%s/pdb2pqr_opal_log' %
                        (INSTALLDIR, TMPDIR, form["jobid"].value), 'r')
                    logstr = pdb2pqrOpalLogFile.read().split('\n')
                    logopts = eval(logstr[0])
                    logff = logstr[1]
                    REMOTE_ADDR = logstr[2]
                    pdb2pqrOpalLogFile.close()
                for i in range(0, len(filelist)):
                    if filelist[i]._name[-7:] == ".propka" or (
                            filelist[i]._name[-13:] == "-typemap.html"
                            and typemap == True
                    ) or filelist[i]._name[-4:] == ".pqr" or filelist[i]._name[
                            -3:] == ".in":
                        if filelist[i]._name[-4:] == ".pqr":
                            # Getting pqr file length for PDB2PQR Opal run
                            f = urllib.urlopen(filelist[i]._url)
                            pqrOpalFileLength = len(f.readlines())
                            f.close()
                        print "<li><a href=%s>%s</a></li>" % (
                            filelist[i]._url, filelist[i]._name)
                logRun(logopts, runtime, pqrOpalFileLength, logff, REMOTE_ADDR)
            else:
                outputfilelist = glob.glob('%s%s%s/*.propka' %
                                           (INSTALLDIR, TMPDIR, jobid))
                for i in range(0, len(outputfilelist)):
                    outputfilelist[i] = os.path.basename(outputfilelist[i])
                for extension in ["-typemap.html", ".pqr", ".in"]:
                    if extension != ".in" or apbs_input != False:
                        if extension == "-typemap.html" and typemap == False:
                            continue
                        outputfilelist.append('%s%s' % (jobid, extension))
                for outputfile in outputfilelist:
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                        WEBSITE, TMPDIR, jobid, outputfile, outputfile)

                #for extension in ["-typemap.html", ".pqr", ".in"]:
                #    print "<li><a href=%s%s%s/%s%s>%s%s</a></li>" % (WEBSITE, TMPDIR, jobid, jobid, extension, jobid, extension)
        elif calctype == "apbs":
            if have_opal:
                for i in range(0, len(filelist)):
                    if filelist[i]._name[-3:] == ".dx":
                        # compressing APBS OpenDX output files
                        currentpath = os.getcwd()
                        zipjobid = filelist[i]._name.split("-")[0]
                        urllib.urlretrieve(
                            filelist[i]._url, '%s%s%s/%s' %
                            (INSTALLDIR, TMPDIR, zipjobid, filelist[i]._name))
                        os.chdir('%s%s%s' % (INSTALLDIR, TMPDIR, zipjobid))
                        syscommand = 'zip -9 ' + filelist[
                            i]._name + '.zip ' + filelist[i]._name
                        os.system(syscommand)
                        os.chdir(currentpath)
                        outputfilezip = filelist[i]._name + '.zip'
                        print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                            WEBSITE, TMPDIR, zipjobid, outputfilezip,
                            outputfilezip)
            else:
                outputfilelist = glob.glob('%s%s%s/%s-*.dx' %
                                           (INSTALLDIR, TMPDIR, jobid, jobid))
                for outputfile in outputfilelist:
                    # compressing APBS OpenDX output files
                    currentpath = os.getcwd()
                    workingpath = os.path.dirname(outputfile)
                    os.chdir(workingpath)
                    syscommand = 'zip -9 ' + os.path.basename(
                        outputfile) + '.zip ' + os.path.basename(outputfile)
                    os.system(syscommand)
                    os.chdir(currentpath)
                    outputfilezip = outputfile + ".zip"
                    print "<li><a href=%s%s%s/%s>%s</a></li>" % (
                        WEBSITE, TMPDIR, jobid,
                        os.path.basename(outputfilezip),
                        os.path.basename(outputfilezip))

        print "</ul></li>"
        print "<li>Runtime and debugging information<ul>"

        if have_opal:
            stdouturl = resp._stdOut
            stderrurl = resp._stdErr
        else:
            stdouturl = "%s%s%s/%s_stdout.txt" % (WEBSITE, TMPDIR, jobid,
                                                  calctype)
            stderrurl = "%s%s%s/%s_stderr.txt" % (WEBSITE, TMPDIR, jobid,
                                                  calctype)

        print "<li><a href=%s>Program output (stdout)</a></li>" % stdouturl
        print "<li><a href=%s>Program errors and warnings (stderr)</a></li>" % stderrurl

        print "</ul></li></ul>"

        #if have_opal:
        #    resp = appServicePort.getOutputs(getOutputsRequest(jobid))
        #    for opalfile in resp._outputFile:
        #        if opalfile._name[-8:]!="-input.p":
        #            print "<li><a href=%s>%s</a></li>" % (opalfile._url, opalfile._name)
        #    print "<li><a href=%s>Standard output</a></li>" % (resp._stdOut)
        #    print "<li><a href=%s>Standard error</a></li>" % (resp._stdErr)
        #else:
        #    for line in cp[1:]:
        #        line = os.path.basename(line)
        #        if line[-8:]!="-input.p":
        #            if line[-11:]=="_stdout.txt":
        #                printname = "Standard output"
        #            elif line[-11:]=="_stderr.txt":
        #                printname = "Standard error"
        #            else:
        #                printname = line
        #            print "<li><a href=%s>%s</a></li>" % (WEBSITE+TMPDIR+jobid+"/"+line,printname)

        if calctype == "pdb2pqr" and apbs_input and HAVE_APBS != "":
            print "</ul></p><hr><p><a href=%s>Click here</a> to run APBS with your results.</p>" % nexturl
        elif calctype == "apbs":
            print "</ul></p><hr><p><a href=%s>Click here</a> to visualize your results.</p>" % nexturl

    elif progress == "error":
        print "There was an error with your query request. This page will not refresh."
    elif progress == "running":
        print "Page will refresh in %d seconds<br />" % refresh
        print "<HR>"
        print "<small>Your results will appear at <a href=%s>this page</a>. If you want, you can bookmark it and come back later (note: results are only stored for approximately 12-24 hours).</small>" % resultsurl
    elif progress == "version_mismatch":
        print "The versions of APBS on the local server and on the Opal server do not match, so the calculation could not be completed"

    print "</P>"
    print "<script type=\"text/javascript\">"
    print "var gaJsHost = ((\"https:\" == document.location.protocol) ? \"https://ssl.\" : \"http://www.\");"
    print "document.write(unescape(\"%3Cscript src=\'\" + gaJsHost + \"google-analytics.com/ga.js\' type=\'text/javascript\'%3E%3C/script%3E\"));"
    print "</script>"
    print "<script type=\"text/javascript\">"
    print "try {"
    print "var pageTracker = _gat._getTracker(\"UA-11026338-3\");"
    if logopts != {}:
        for key in logopts:
            print "pageTracker._trackPageview(\"/main_cgi/has_%s_%s.html\");" % (
                key, logopts[key])
    print "pageTracker._trackPageview();"
    print "} catch(err) {}</script>"
    print "</BODY>"
    print "</HTML>"