示例#1
0
    def _initBlast(self, program, db, queryName, querySeq, evalue, matrix,
                   passes):
        self.program = program
        self.db = db
        self.queryName = queryName
        self.params = (querySeq, evalue, matrix, passes)
        from WebServices.AppService_types import ns0
        from WebServices.opal_client import OpalService
        inputFile = ns0.InputFileType_Def("inputFile")
        inputFile._name = "query.fa"
        inputFile._contents = self.makeFasta(queryName, querySeq)
        service = "BlastproteinServicePort"
        argList = "-P %s -d %s -i %s -o %s -e %s -M %s -p %s" % (
            program, db, inputFile._name, self.outputFile, evalue, matrix,
            passes)
        try:
            self.opal = OpalService(service)
        except:
            import traceback, sys
            print "Traceback from Blast request:"
            traceback.print_exc(file=sys.stdout)
            print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
            from chimera import NonChimeraError
            raise NonChimeraError("Blast web service appears "
                                  "to be down.  See Reply Log "
                                  "for more details.")
        self.opal.launchJob(argList, _inputFile=[inputFile])
        from chimera.tasks import Task
        self.task = Task(self._title(), self.cancelCB, self.statusCB)
示例#2
0
 def _initSession(self, program, db, queryName, params, running, opalData):
     self.program = program
     self.db = db
     self.queryName = queryName
     self.params = params
     from WebServices.opal_client import OpalService
     self.opal = OpalService(sessionData=opalData)
     if not running:
         self.task = None
     else:
         from chimera.tasks import Task
         self.task = Task(self._title(), self.cancelCB, self.statusCB)
示例#3
0
def _getWebService(residue):
	from WebServices.AppService_types import ns0
	from WebServices.opal_client import OpalService
	service = "ccd_catServicePort"
	argList = "%s" % residue
	opal = OpalService(service)
	status, fileMap = opal.launchJobBlocking(argList)
	opal.destroy()
	if not status:
		return None
	import urllib2
	f = urllib2.urlopen(fileMap["stdout.txt"])
	data = f.read()
	f.close()
	return data
示例#4
0
def _getWebService(residue):
    from WebServices.AppService_types import ns0
    from WebServices.opal_client import OpalService
    service = "ccd_catServicePort"
    argList = "%s" % residue
    opal = OpalService(service)
    status, fileMap = opal.launchJobBlocking(argList)
    opal.destroy()
    if not status:
        return None
    import urllib2
    f = urllib2.urlopen(fileMap["stdout.txt"])
    data = f.read()
    f.close()
    return data
示例#5
0
	def _initBlast(self, program, db, queryName, querySeq,
			evalue, matrix, passes):
		self.program = program
		self.db = db
		self.queryName = queryName
		self.params = (querySeq, evalue, matrix, passes)
		from WebServices.AppService_types import ns0
		from WebServices.opal_client import OpalService
		inputFile = ns0.InputFileType_Def("inputFile")
		inputFile._name = "query.fa"
		inputFile._contents = self.makeFasta(queryName, querySeq)
		service = "BlastproteinServicePort"
		argList = "-P %s -d %s -i %s -o %s -e %s -M %s -p %s" % (
				program, db, inputFile._name,
				self.outputFile, evalue, matrix, passes)
		try:
			self.opal = OpalService(service)
		except:
			import traceback, sys
			print "Traceback from Blast request:"
			traceback.print_exc(file=sys.stdout)
			print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
			from chimera import NonChimeraError
			raise NonChimeraError("Blast web service appears "
						"to be down.  See Reply Log "
						"for more details.")
		self.opal.launchJob(argList, _inputFile=[inputFile])
		from chimera.tasks import Task
		self.task = Task(self._title(), self.cancelCB,
								self.statusCB)
示例#6
0
 def __init__(self, queryName, querySeq, evalue, matrix, finishCB):
     from WebServices.AppService_types import ns0
     from WebServices.opal_client import OpalService
     self.queryName = queryName
     inputFile = ns0.InputFileType_Def("inputFile")
     inputFile._name = "query.fa"
     inputFile._contents = self.makeFasta(queryName, querySeq)
     service = "BlastpdbServicePort"
     argList = "-i %s -o %s -e %s -M %s" % (self.inputFile._name,
                                            self.outputFile, evalue, matrix)
     self.opal = OpalService(service)
     self.opal.launchJob(argList, _inputFile=[inputFile])
     self.finishCB = finishCB
     from chimera.tasks import Task
     self.task = Task("blastpdb %s" % queryName, self.cancelCB,
                      self.statusCB)
    def __init__(self, pdbpath, expath, name, fig):
        from WebServices.AppService_types import ns0
        from WebServices.opal_client import OpalService
        self.pdbpath = pdbpath
        self.expath = expath
        self.name = name
        self.figure = fig

        pdbFile = ns0.InputFileType_Def("inputFile")
        pdbFile._name = "pdbfile"
        f = open(pdbpath)
        pdbFile._contents = f.read()
        f.close()
        files = [pdbFile]
        argList = "pdbfile"
        if expath:
            exFile = ns0.InputFileType_Def("inputFile")
            exFile._name = "exfile"
            f = open(expath)
            exFile._contents = f.read()
            f.close()
            files.append(exFile)
            argList += " exfile"

        try:
            self.opal = OpalService("SAXSService")
        except:
            import traceback, sys
            print "Traceback from SAXS request:"
            traceback.print_exc(file=sys.stdout)
            print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
            from chimera import NonChimeraError
            raise NonChimeraError("SAXS web service appears "
                                  "to be down.  See Reply Log "
                                  "for more details.")

        self.opal.launchJob(argList, _inputFile=files)
        from chimera.tasks import Task
        self.task = Task("SAXS " + self.name, self.cancelCB, self.statusCB)
示例#8
0
	def _initSession(self, program, db, queryName,
				params, running, opalData):
		self.program = program
		self.db = db
		self.queryName = queryName
		self.params = params
		from WebServices.opal_client import OpalService
		self.opal = OpalService(sessionData=opalData)
		if not running:
			self.task = None
		else:
			from chimera.tasks import Task
			self.task = Task(self._title(), self.cancelCB,
								self.statusCB)
示例#9
0
	def __init__(self, queryName, querySeq, evalue, matrix, finishCB):
		from WebServices.AppService_types import ns0
		from WebServices.opal_client import OpalService
		self.queryName = queryName
		inputFile = ns0.InputFileType_Def("inputFile")
		inputFile._name = "query.fa"
		inputFile._contents = self.makeFasta(queryName, querySeq)
		service = "BlastpdbServicePort"
		argList = "-i %s -o %s -e %s -M %s" % (
				self.inputFile._name, self.outputFile,
				evalue, matrix)
		self.opal = OpalService(service)
		self.opal.launchJob(argList, _inputFile=[inputFile])
		self.finishCB = finishCB
		from chimera.tasks import Task
		self.task = Task("blastpdb %s" % queryName, self.cancelCB,
								self.statusCB)
示例#10
0
  def __init__(self, pdbpath, expath, name, fig):
    from WebServices.AppService_types import ns0
    from WebServices.opal_client import OpalService
    self.pdbpath = pdbpath
    self.expath = expath
    self.name = name
    self.figure = fig

    pdbFile = ns0.InputFileType_Def("inputFile")
    pdbFile._name = "pdbfile"
    f = open(pdbpath)
    pdbFile._contents = f.read()
    f.close()
    files = [ pdbFile ]
    argList = "pdbfile"
    if expath:
      exFile = ns0.InputFileType_Def("inputFile")
      exFile._name = "exfile"
      f = open(expath)
      exFile._contents = f.read()
      f.close()
      files.append(exFile)
      argList += " exfile"
    
    try:
      self.opal = OpalService("SAXSService")
    except:
      import traceback, sys
      print "Traceback from SAXS request:"
      traceback.print_exc(file=sys.stdout)
      print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
      from chimera import NonChimeraError
      raise NonChimeraError("SAXS web service appears "
            "to be down.  See Reply Log "
            "for more details.")

    self.opal.launchJob(argList, _inputFile=files)
    from chimera.tasks import Task
    self.task = Task("SAXS " + self.name, self.cancelCB, self.statusCB)
示例#11
0
class BlastproteinService:

    outputFile = "blast.out"

    def __init__(self, finishCB, params=None, sessionData=None):
        self.finishCB = finishCB
        if params is not None:
            self._initBlast(*params)
        else:
            self._initSession(*sessionData)

    def _initBlast(self, program, db, queryName, querySeq, evalue, matrix,
                   passes):
        self.program = program
        self.db = db
        self.queryName = queryName
        self.params = (querySeq, evalue, matrix, passes)
        from WebServices.AppService_types import ns0
        from WebServices.opal_client import OpalService
        inputFile = ns0.InputFileType_Def("inputFile")
        inputFile._name = "query.fa"
        inputFile._contents = self.makeFasta(queryName, querySeq)
        service = "BlastproteinServicePort"
        argList = "-P %s -d %s -i %s -o %s -e %s -M %s -p %s" % (
            program, db, inputFile._name, self.outputFile, evalue, matrix,
            passes)
        try:
            self.opal = OpalService(service)
        except:
            import traceback, sys
            print "Traceback from Blast request:"
            traceback.print_exc(file=sys.stdout)
            print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
            from chimera import NonChimeraError
            raise NonChimeraError("Blast web service appears "
                                  "to be down.  See Reply Log "
                                  "for more details.")
        self.opal.launchJob(argList, _inputFile=[inputFile])
        from chimera.tasks import Task
        self.task = Task(self._title(), self.cancelCB, self.statusCB)

    def _initSession(self, program, db, queryName, params, running, opalData):
        self.program = program
        self.db = db
        self.queryName = queryName
        self.params = params
        from WebServices.opal_client import OpalService
        self.opal = OpalService(sessionData=opalData)
        if not running:
            self.task = None
        else:
            from chimera.tasks import Task
            self.task = Task(self._title(), self.cancelCB, self.statusCB)

    def _title(self):
        return "%s %s: %s" % (self.program, self.db, self.queryName)

    def sessionData(self):
        return (self.program, self.db, self.queryName, self.params, self.task
                is not None, self.opal.sessionData())

    def cancelCB(self):
        self.task = None

    def statusCB(self):
        self.task.updateStatus(self.opal.currentStatus())
        if not self.opal.isFinished():
            self.opal.queryStatus()
            return
        self.task = None
        fileMap = self.opal.getOutputs()
        if self.opal.isFinished() > 0:
            # Successful completion
            self.finishCB(self.getURLContent(fileMap[self.outputFile]))
        else:
            # Failed
            from chimera import replyobj
            replyobj.error("blast %s failed; "
                           "see Reply Log for more information\n" %
                           self.queryName)
            self.showURLContent("blast stderr", fileMap["stderr.txt"])
            self.showURLContent("blast stdout", fileMap["stdout.txt"])

    def makeFasta(self, name, seq):
        output = [">QUERY\n"]
        maxLine = 60
        for i in range(0, len(seq), maxLine):
            end = min(i + maxLine, len(seq))
            output.append("%s\n" % seq[i:end])
        return ''.join(output)

    def getURLContent(self, url):
        import urllib2
        f = urllib2.urlopen(url)
        data = f.read()
        f.close()
        return data

    def showURLContent(self, title, url):
        from chimera import replyobj
        data = self.getURLContent(url)
        replyobj.message("%s\n-----\n%s-----\n" % (title, data))
示例#12
0
class BlastpdbService:

    outputFile = "blast.out"

    def __init__(self, queryName, querySeq, evalue, matrix, finishCB):
        from WebServices.AppService_types import ns0
        from WebServices.opal_client import OpalService
        self.queryName = queryName
        inputFile = ns0.InputFileType_Def("inputFile")
        inputFile._name = "query.fa"
        inputFile._contents = self.makeFasta(queryName, querySeq)
        service = "BlastpdbServicePort"
        argList = "-i %s -o %s -e %s -M %s" % (self.inputFile._name,
                                               self.outputFile, evalue, matrix)
        self.opal = OpalService(service)
        self.opal.launchJob(argList, _inputFile=[inputFile])
        self.finishCB = finishCB
        from chimera.tasks import Task
        self.task = Task("blastpdb %s" % queryName, self.cancelCB,
                         self.statusCB)

    def cancelCB(self):
        self.task = None

    def statusCB(self):
        self.task.updateStatus(self.opal.currentStatus())
        if not self.opal.isFinished():
            self.opal.queryStatus()
            return
        self.task = None
        fileMap = self.opal.getOutputs()
        if self.opal.isFinished() > 0:
            # Successful completion
            self.finishCB(self.getURLContent(fileMap[self.outputFile]))
        else:
            # Failed
            from chimera import replyobj
            replyobj.error("blastpdb %s failed; "
                           "see Reply Log for more information" %
                           self.queryName)
            try:
                self.showURLContent("blastpdb stdout", fileMap["stdout"])
            except KeyError:
                pass
            try:
                self.showURLContent("blastpdb stderr", fileMap["stderr"])
            except KeyError:
                pass

    def makeFasta(self, name, seq):
        output = [">QUERY\n"]
        maxLine = 60
        for i in range(0, len(seq), maxLine):
            end = min(i + maxLine, len(seq))
            output.append("%s\n" % seq[i:end])
        return ''.join(output)

    def getURLContent(self, url):
        import urllib2
        f = urllib2.urlopen(url)
        data = f.read()
        f.close()
        return data

    def showURLContent(self, title, url):
        from chimera import replyobj
        data = self.getURLContent(url)
        replyobj.message("%s\n-----\n%s-----\n" % (title, data))
示例#13
0
class BlastproteinService:

	outputFile = "blast.out"

	def __init__(self, finishCB, params=None, sessionData=None):
		self.finishCB = finishCB
		if params is not None:
			self._initBlast(*params)
		else:
			self._initSession(*sessionData)

	def _initBlast(self, program, db, queryName, querySeq,
			evalue, matrix, passes):
		self.program = program
		self.db = db
		self.queryName = queryName
		self.params = (querySeq, evalue, matrix, passes)
		from WebServices.AppService_types import ns0
		from WebServices.opal_client import OpalService
		inputFile = ns0.InputFileType_Def("inputFile")
		inputFile._name = "query.fa"
		inputFile._contents = self.makeFasta(queryName, querySeq)
		service = "BlastproteinServicePort"
		argList = "-P %s -d %s -i %s -o %s -e %s -M %s -p %s" % (
				program, db, inputFile._name,
				self.outputFile, evalue, matrix, passes)
		try:
			self.opal = OpalService(service)
		except:
			import traceback, sys
			print "Traceback from Blast request:"
			traceback.print_exc(file=sys.stdout)
			print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
			from chimera import NonChimeraError
			raise NonChimeraError("Blast web service appears "
						"to be down.  See Reply Log "
						"for more details.")
		self.opal.launchJob(argList, _inputFile=[inputFile])
		from chimera.tasks import Task
		self.task = Task(self._title(), self.cancelCB,
								self.statusCB)

	def _initSession(self, program, db, queryName,
				params, running, opalData):
		self.program = program
		self.db = db
		self.queryName = queryName
		self.params = params
		from WebServices.opal_client import OpalService
		self.opal = OpalService(sessionData=opalData)
		if not running:
			self.task = None
		else:
			from chimera.tasks import Task
			self.task = Task(self._title(), self.cancelCB,
								self.statusCB)

	def _title(self):
		return "%s %s: %s" % (self.program, self.db, self.queryName)

	def sessionData(self):
		return (self.program, self.db, self.queryName, self.params,
				self.task is not None,
				self.opal.sessionData())

	def cancelCB(self):
		self.task = None

	def statusCB(self):
		self.task.updateStatus(self.opal.currentStatus())
		if not self.opal.isFinished():
			self.opal.queryStatus()
			return
		self.task = None
		fileMap = self.opal.getOutputs()
		if self.opal.isFinished() > 0:
			# Successful completion
			self.finishCB(self.getURLContent(
						fileMap[self.outputFile]))
		else:
			# Failed
			from chimera import replyobj
			replyobj.error("blast %s failed; "
					"see Reply Log for more information\n"
					% self.queryName)
			self.showURLContent("blast stderr", fileMap["stderr.txt"])
			self.showURLContent("blast stdout", fileMap["stdout.txt"])

	def makeFasta(self, name, seq):
		output = [ ">QUERY\n" ]
		maxLine = 60
		for i in range(0, len(seq), maxLine):
			end = min(i + maxLine, len(seq))
			output.append("%s\n" % seq[i:end])
		return ''.join(output)

	def getURLContent(self, url):
		import urllib2
		f = urllib2.urlopen(url)
		data = f.read()
		f.close()
		return data

	def showURLContent(self, title, url):
		from chimera import replyobj
		data = self.getURLContent(url)
		replyobj.message("%s\n-----\n%s-----\n" % (title, data))
示例#14
0
class BlastpdbService:

	outputFile = "blast.out"

	def __init__(self, queryName, querySeq, evalue, matrix, finishCB):
		from WebServices.AppService_types import ns0
		from WebServices.opal_client import OpalService
		self.queryName = queryName
		inputFile = ns0.InputFileType_Def("inputFile")
		inputFile._name = "query.fa"
		inputFile._contents = self.makeFasta(queryName, querySeq)
		service = "BlastpdbServicePort"
		argList = "-i %s -o %s -e %s -M %s" % (
				self.inputFile._name, self.outputFile,
				evalue, matrix)
		self.opal = OpalService(service)
		self.opal.launchJob(argList, _inputFile=[inputFile])
		self.finishCB = finishCB
		from chimera.tasks import Task
		self.task = Task("blastpdb %s" % queryName, self.cancelCB,
								self.statusCB)

	def cancelCB(self):
		self.task = None

	def statusCB(self):
		self.task.updateStatus(self.opal.currentStatus())
		if not self.opal.isFinished():
			self.opal.queryStatus()
			return
		self.task = None
		fileMap = self.opal.getOutputs()
		if self.opal.isFinished() > 0:
			# Successful completion
			self.finishCB(self.getURLContent(
						fileMap[self.outputFile]))
		else:
			# Failed
			from chimera import replyobj
			replyobj.error("blastpdb %s failed; "
					"see Reply Log for more information"
					% self.queryName)
			try:
				self.showURLContent("blastpdb stdout",
							fileMap["stdout"])
			except KeyError:
				pass
			try:
				self.showURLContent("blastpdb stderr",
							fileMap["stderr"])
			except KeyError:
				pass

	def makeFasta(self, name, seq):
		output = [ ">QUERY\n" ]
		maxLine = 60
		for i in range(0, len(seq), maxLine):
			end = min(i + maxLine, len(seq))
			output.append("%s\n" % seq[i:end])
		return ''.join(output)

	def getURLContent(self, url):
		import urllib2
		f = urllib2.urlopen(url)
		data = f.read()
		f.close()
		return data

	def showURLContent(self, title, url):
		from chimera import replyobj
		data = self.getURLContent(url)
		replyobj.message("%s\n-----\n%s-----\n" % (title, data))
示例#15
0
class ProfileOpalService:

  def __init__(self, pdbpath, expath, name, fig):
    from WebServices.AppService_types import ns0
    from WebServices.opal_client import OpalService
    self.pdbpath = pdbpath
    self.expath = expath
    self.name = name
    self.figure = fig

    pdbFile = ns0.InputFileType_Def("inputFile")
    pdbFile._name = "pdbfile"
    f = open(pdbpath)
    pdbFile._contents = f.read()
    f.close()
    files = [ pdbFile ]
    argList = "pdbfile"
    if expath:
      exFile = ns0.InputFileType_Def("inputFile")
      exFile._name = "exfile"
      f = open(expath)
      exFile._contents = f.read()
      f.close()
      files.append(exFile)
      argList += " exfile"
    
    try:
      self.opal = OpalService("SAXSService")
    except:
      import traceback, sys
      print "Traceback from SAXS request:"
      traceback.print_exc(file=sys.stdout)
      print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
      from chimera import NonChimeraError
      raise NonChimeraError("SAXS web service appears "
            "to be down.  See Reply Log "
            "for more details.")

    self.opal.launchJob(argList, _inputFile=files)
    from chimera.tasks import Task
    self.task = Task("SAXS " + self.name, self.cancelCB, self.statusCB)
    
  def cancelCB(self):
    self.task = None

  def statusCB(self):
    self.task.updateStatus(self.opal.currentStatus())
    if not self.opal.isFinished():
      self.opal.queryStatus()
      return
    self.task = None
    self.filemap = self.opal.getOutputs()
    if self.opal.isFinished() > 0:
      # Successful completion
      self.finished()
    else:
      # Failed
      from chimera import replyobj
      replyobj.error("SAXS %s failed; see Reply Log for more information"
		      % self.name)
      self.showFileContent("stdout.txt")
      self.showFileContent("stderr.txt")

  def finished(self):
    if self.expath:
      data = self.getFileContent("pdbfile_exfile.dat")
      p = read_profile_data(data, 3)
    else:
      data = self.getFileContent("pdbfile.dat")
      p = read_profile_data(data, 2)
    self.figure = plot_profile(p, self.name, self.figure)

  def getURLContent(self, url):
    import urllib2
    f = urllib2.urlopen(url)
    data = f.read()
    f.close()
    return data

  def getFileContent(self, filename):
    return self.getURLContent(self.filemap[filename])

  def showURLContent(self, title, url):
    from chimera import replyobj
    data = self.getURLContent(url)
    replyobj.message("%s\n-----\n%s-----\n" % (title, data))

  def showFileContent(self, filename):
    try:
      url = self.filemap[filename]
    except KeyError:
      from chimera import replyobj
      replyobj.message("SAXS profile: there is no file named \"%s\"" % filename)
    else:
      self.showURLContent("SAXS profile %s" % filename, url)
class ProfileOpalService:
    def __init__(self, pdbpath, expath, name, fig):
        from WebServices.AppService_types import ns0
        from WebServices.opal_client import OpalService
        self.pdbpath = pdbpath
        self.expath = expath
        self.name = name
        self.figure = fig

        pdbFile = ns0.InputFileType_Def("inputFile")
        pdbFile._name = "pdbfile"
        f = open(pdbpath)
        pdbFile._contents = f.read()
        f.close()
        files = [pdbFile]
        argList = "pdbfile"
        if expath:
            exFile = ns0.InputFileType_Def("inputFile")
            exFile._name = "exfile"
            f = open(expath)
            exFile._contents = f.read()
            f.close()
            files.append(exFile)
            argList += " exfile"

        try:
            self.opal = OpalService("SAXSService")
        except:
            import traceback, sys
            print "Traceback from SAXS request:"
            traceback.print_exc(file=sys.stdout)
            print """
Typically, if you get a TypeError, it's a problem on the remote server
and it should be fixed shortly.  If you get a different error or
get TypeError consistently for more than a day, please report the
problem using the Report a Bug... entry in the Help menu.  Please
include the traceback printed above as part of the problem description."""
            from chimera import NonChimeraError
            raise NonChimeraError("SAXS web service appears "
                                  "to be down.  See Reply Log "
                                  "for more details.")

        self.opal.launchJob(argList, _inputFile=files)
        from chimera.tasks import Task
        self.task = Task("SAXS " + self.name, self.cancelCB, self.statusCB)

    def cancelCB(self):
        self.task = None

    def statusCB(self):
        self.task.updateStatus(self.opal.currentStatus())
        if not self.opal.isFinished():
            self.opal.queryStatus()
            return
        self.task = None
        self.filemap = self.opal.getOutputs()
        if self.opal.isFinished() > 0:
            # Successful completion
            self.finished()
        else:
            # Failed
            from chimera import replyobj
            replyobj.error(
                "SAXS %s failed; see Reply Log for more information" %
                self.name)
            self.showFileContent("stdout.txt")
            self.showFileContent("stderr.txt")

    def finished(self):
        if self.expath:
            data = self.getFileContent("pdbfile_exfile.dat")
            p = read_profile_data(data, 3)
        else:
            data = self.getFileContent("pdbfile.dat")
            p = read_profile_data(data, 2)
        self.figure = plot_profile(p, self.name, self.figure)

    def getURLContent(self, url):
        import urllib2
        f = urllib2.urlopen(url)
        data = f.read()
        f.close()
        return data

    def getFileContent(self, filename):
        return self.getURLContent(self.filemap[filename])

    def showURLContent(self, title, url):
        from chimera import replyobj
        data = self.getURLContent(url)
        replyobj.message("%s\n-----\n%s-----\n" % (title, data))

    def showFileContent(self, filename):
        try:
            url = self.filemap[filename]
        except KeyError:
            from chimera import replyobj
            replyobj.message("SAXS profile: there is no file named \"%s\"" %
                             filename)
        else:
            self.showURLContent("SAXS profile %s" % filename, url)