Exemple #1
0
    def postprocess(self):
        """
        Things to do after the main process runs
        1. Return the data throught the pipe
        """
        self.logger.debug("postprocess")

        self.logger.debug(self.results)

        # Send back the data as an echo
        rapd_send(self.reply_settings, self.results)
Exemple #2
0
    def postprocess(self):
        """
        Things to do after the main process runs
        1. Return the data throught the pipe
        """
        self.logger.debug("postprocess")

        self.logger.debug(self.results)

        # Send back the data as an echo
        rapd_send(self.reply_settings, self.results)
Exemple #3
0
  def postprocess(self):
    if self.verbose:
      self.logger.debug('RunXOalign::postprocess')
    #Save logfile for HTML output.
    self.xoalign_log = open('XOalign.log','r').readlines()
    self.xoalign_results = Parse.ParseOutputXOalign(self,self.xoalign_log)
    if self.xoalign_failed == False:
      Summary.summaryAutoCell(self)
      Summary.summaryXOalign(self)
    self.htmlSummaryXOalign()
    #Account for missing file paths from autoindex pipeline.
    output = {'STAC file1':'None','STAC file2':'None','image_path_raw_1':'None','image_path_pred_1':'None','image_path_raw_2':'None',
              'image_path_pred_2':'None','Best plots html':'None','Long summary html':'None','Short summary html':'None',}
    f = 'jon_summary_xoalign.html'
    if self.gui:
      f = f.replace('html','php')
    if os.path.exists(os.path.join(self.working_dir,f)):
      output['XOalign summary html'] = os.path.join(self.working_dir,f)
    else:
      output['XOalign summary html'] = 'None'

    #Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
    try:
      results = {}
      results.update({'Output files' : output})
      self.input.append(results)
      if self.gui:
        # self.sendBack2(self.input)
        rapd_send(self.controller_address, self.input)
    except:
      self.logger.exception('**xoalign.postprocess Could not send results to pipe.**')

    try:
      #Cleanup my mess.
      if self.clean:
        os.chdir(self.working_dir)
        rm = 'rm -rf bestfile.par XOalign.log'
        if self.verbose:
          self.logger.debug(rm)
        os.system(rm)
    except:
      self.logger.exception('**xoalign.postprocess Could not cleanup**')

    #Say job is complete.
    t = round(time.time()-self.st)
    self.logger.debug('-------------------------------------')
    self.logger.debug('RAPD XOalign complete.')
    self.logger.debug('Total elapsed time: %s seconds'%t)
    self.logger.debug('-------------------------------------')
    print '\n-------------------------------------'
    print 'RAPD XOalign complete.'
    print 'Total elapsed time: %s seconds'%t
    print '-------------------------------------'
Exemple #4
0
    def postprocess(self):
        """
        Things to do after the main process runs
        1. Return the data
        """

        self.logger.debug('SimpleMerge::postprocess')

        os.remove('info.log')
        self.results['status'] = 'SUCCESS'
        self.request.append(self.results)
        # Send the results back to the Core
        # self.sendBack2(self.request)
        rapd_send(self.reply_settings, self.request)
Exemple #5
0
    def postprocess(self):
        """
        Run summaries, make php/html files, send data back, and clean up.
        """
        if self.verbose:
            self.logger.debug("AutoStats::postprocess")

        output = {}
        status = {}
        results = {}
        failed = False
        cell_results = False
        cell_out = False
        pp_results = False
        pp_out = False

        #Make the output html files
        self.plot_xtriage()
        if self.xtriage_results:
            Summary.summaryXtriage(self)
        self.html_summary_xtriage()
        if self.molrep_results:
            Summary.summaryMolrep(self)
        self.html_summary_molrep()

        if self.gui:
            e = ".php"
        else:
            e = ".html"
        l = [("jon_summary_xtriage%s" % e, "Xtriage summary html"),
             ("plots_xtriage%s" % e, "Xtriage plots html"),
             ("jon_summary_molrep%s" % e, "Molrep summary html")]
        for i in range(len(l)):
            try:
                path = os.path.join(self.working_dir, l[i][0])
                if os.path.exists(path):
                    output[l[i][1]] = path
                else:
                    output[l[i][1]] = "None"
            except:
                self.logger.exception("**Could not update paths of %s file**" % l[i][0])
                output[l[i][1]] = "FAILED"
                failed = True

        # Get rapd_agent_cell results back
        try:
            cell_results = self.cell_output.get()
            if cell_results.has_key("status"):
                if cell_results["status"] == "FAILED":
                    failed = True
                del cell_results["status"]
            if cell_results.has_key("Output files"):
                cell_out = cell_results["Output files"]
                del cell_results["Output files"]
        except:
            self.logger.exception("**Error importing rapd_agent_cell results**")

        # Get rapd_agent_pp results back
        try:
            if self.pp:
                pp_results = self.pp_output.get()
                if pp_results.has_key("status"):
                    if pp_results["status"] == "FAILED":
                        failed = True
                    del pp_results["status"]
                if pp_results.has_key("Output files"):
                    pp_out = pp_results["Output files"]
                    del pp_results["Output files"]
            else:
                # Put together the dict from LabelitPP and create an html summary.
                pp_results = {"LabelitPP results": {"HK0 jpg":None, "H0L jpg":None, "0KL jpg":None}}
                Utils.failedHTML(self, ("jon_summary_pp", "Cannot create precession photos from merged datasets."))
                if os.path.exists(os.path.join(self.working_dir, "jon_summary_pp%s" % e)):
                    pp_out = {"LabelitPP summary html":os.path.join(self.working_dir, "jon_summary_pp%s" % e)}
                else:
                    pp_out = {"LabelitPP summary html":"None"}

        except:
            self.logger.exception("**Error importing rapd_agent_cell results**")

        # Get proper status.
        if failed:
            status["status"] = "FAILED"
        else:
            status["status"] = "SUCCESS"

        # Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
        try:
            results.update(status)
            if self.xtriage_results:
                results.update(self.xtriage_results)
            if self.molrep_results:
                results.update(self.molrep_results)
            if cell_results:
                results.update(cell_results)
            if pp_results:
                results.update(pp_results)
            if output:
                if cell_out:
                    output.update(cell_out)
                if pp_out:
                    output.update(pp_out)
                results.update(output)
            self.command_input.insert(0, "STATS")
            self.command_input.append(results)
            if self.gui:
                rapd_send(self.controller_address, self.command_input)

        except:
            self.logger.exception("**Could not send results to pipe**")

        try:
            #Cleanup my mess.
            if self.clean:
                if failed == False:
                    if self.verbose:
                        self.logger.debug("Cleaning up files")
                    os.system("rm -rf *.ps *.btc *.tab *.xml *.com molrep.doc molrep.log logfile.log xtriage.log phaser2.log PHASER.mtz")
        except:
            self.logger.exception("**Could not cleanup**")

        #Say job is complete.
        t = round(time.time()-self.st)
        self.logger.debug("-------------------------------------")
        self.logger.debug("RAPD AutoStat complete.")
        self.logger.debug("Total elapsed time: %s seconds" % t)
        self.logger.debug("-------------------------------------")
        print "\n-------------------------------------"
        print "RAPD AutoStat complete."
        print "Total elapsed time: %s seconds" % t
        print "-------------------------------------"
Exemple #6
0
  def postprocess(self,final=True):
    """
    Things to do after the main process runs
    1. Return the data through the pipe
    """
    if self.verbose:
      self.logger.debug('AutoMolRep::postprocess')
    #Run summary files for each program to print to screen
    output = {}
    results = {}
    output_files = False
    status = False
    cell_results = False
    failed = False
    #Setup output file name
    if self.phaser_results:
      Summary.summaryCell(self,'phaser')
    if self.input_pdb:
      self.htmlSummaryPhaser()
    else:
      Utils.failedHTML(self,('jon_summary_cell','Input PDB file does not exist.'))
    try:
      if self.gui:
        sl = 'jon_summary_cell.php'
      else:
        sl = 'jon_summary_cell.html'
      if os.path.exists(os.path.join(self.working_dir,sl)):
        output['Cell summary html'] = os.path.join(self.working_dir,sl)
      else:
        output['Cell summary html'] = 'None'
    except:
      self.logger.exception('**Could not update path of cell summary html file in AutoMolRep.postprocess.**')
      output['Cell summary html'] = 'FAILED'

    try:
      #Only tar up files at end to see if they show up in the user dir.
      #if final:
      if self.input_pdb:
        #pdb = os.path.basename(self.input_pdb)
        for sg in self.phaser_results.keys():
          dir1 = self.phaser_results[sg].get('AutoMR results').get('AutoMR dir')
          l = ['pdb','mtz','adf','peak']
          if dir1 not in ('No solution','Timed out','NA','DL Failed','Still running'):
            #pack all the output files in a tar and save the path in results.
            os.chdir(dir1)
            #tar = '%s_%s.tar'%(pdb[:-4],sg)
            tar = '%s_%s.tar'%(sg.split('_')[0],sg.split('_')[1])
            if os.path.exists('%s.bz2'%tar) == False:
              for p in l:
                f = self.phaser_results[sg].get('AutoMR results').get('AutoMR %s'%p)
                if os.path.exists(f):
                  os.system('tar -rf %s %s'%(tar,f))
              if os.path.exists(tar):
                os.system('bzip2 -qf %s'%tar)
              #Remove old tar's in working dir, if they exist and copy new one over.
              if os.path.exists(os.path.join(self.working_dir,'%s.bz2'%tar)):
                os.system('rm -rf %s'%os.path.join(self.working_dir,'%s.bz2'%tar))
              shutil.copy('%s.bz2'%tar,self.working_dir)
            self.phaser_results[sg].get('AutoMR results').update({'AutoMR tar': os.path.join(self.working_dir,'%s.bz2'%tar)})
          else:
            self.phaser_results[sg].get('AutoMR results').update({'AutoMR tar': 'None'})
      cell_results = { 'Cell analysis results': self.phaser_results }

    except:
      self.logger.exception('**Could not AutoMR results in AutoMolRep.postprocess.**')
      cell_results = { 'Cell analysis results': 'FAILED'}
      self.clean = False
      failed = True

    try:
      output_files = {'Output files' : output}
    except:
      self.logger.exception('**Could not update the output dict in AutoMolRep.postprocess.**')

    #Get proper status.
    if final:
      if failed:
        status = {'status': 'FAILED'}
      else:
        status = {'status': 'SUCCESS'}
    else:
      status = {'status': 'WORKING'}

    #Put all the result dicts from all the programs run into one resultant dict and pass it back.
    try:
      if self.gui == False:
          if self.input[0] == "SAD":
              self.input.remove("SAD")
              self.input.insert(0,'MR')
      if status:
          results.update(status)
      if cell_results:
          results.update(cell_results)
      # Utils.pp(self,cell_results)
      if output_files:
          results.update(output_files)
      # Utils.pp(results)
      if self.gui:
          if results:
              if len(self.input) == 6:
                  # Delete the previous Phaser results sent back.
                  del self.input[5]
              self.input.append(results)
          rapd_send(self.controller_address, self.input)

    except:
        self.logger.exception('**Could not send results to pipe in AutoMolRep.postprocess.**')

    if final:
      try:
        #Cleanup my mess.
        if self.clean:
          os.chdir(self.working_dir)
          if self.verbose:
            self.logger.debug('Cleaning up Phaser files and folders')
          os.system('rm -rf Phaser_* *.com *.pdb *.mtz *.sum')

      except:
        self.logger.exception('**Could not cleanup in AutoMolRep.postprocess**')

      #Say job is complete.
      t = round(time.time()-self.st)
      self.logger.debug(50*'-')
      self.logger.debug('RAPD AutoMolRep complete.')
      self.logger.debug('Total elapsed time: %s seconds'%t)
      self.logger.debug(50*'-')
      print 50*'-'
      print 'RAPD AutoMolRep complete.'
      print 'Total elapsed time: %s seconds'%t
      print 50*'-'
Exemple #7
0
    def postprocess(self, final=True):
        """
    Things to do after the main process runs
    1. Return the data through the pipe
    """
        if self.verbose:
            self.logger.debug('AutoMolRep::postprocess')
        #Run summary files for each program to print to screen
        output = {}
        results = {}
        output_files = False
        status = False
        cell_results = False
        failed = False
        #Setup output file name
        if self.phaser_results:
            Summary.summaryCell(self, 'phaser')
        if self.input_pdb:
            self.htmlSummaryPhaser()
        else:
            Utils.failedHTML(
                self, ('jon_summary_cell', 'Input PDB file does not exist.'))
        try:
            if self.gui:
                sl = 'jon_summary_cell.php'
            else:
                sl = 'jon_summary_cell.html'
            if os.path.exists(os.path.join(self.working_dir, sl)):
                output['Cell summary html'] = os.path.join(
                    self.working_dir, sl)
            else:
                output['Cell summary html'] = 'None'
        except:
            self.logger.exception(
                '**Could not update path of cell summary html file in AutoMolRep.postprocess.**'
            )
            output['Cell summary html'] = 'FAILED'

        try:
            #Only tar up files at end to see if they show up in the user dir.
            #if final:
            if self.input_pdb:
                #pdb = os.path.basename(self.input_pdb)
                for sg in self.phaser_results.keys():
                    dir1 = self.phaser_results[sg].get('AutoMR results').get(
                        'AutoMR dir')
                    l = ['pdb', 'mtz', 'adf', 'peak']
                    if dir1 not in ('No solution', 'Timed out', 'NA',
                                    'DL Failed', 'Still running'):
                        #pack all the output files in a tar and save the path in results.
                        os.chdir(dir1)
                        #tar = '%s_%s.tar'%(pdb[:-4],sg)
                        tar = '%s_%s.tar' % (sg.split('_')[0],
                                             sg.split('_')[1])
                        if os.path.exists('%s.bz2' % tar) == False:
                            for p in l:
                                f = self.phaser_results[sg].get(
                                    'AutoMR results').get('AutoMR %s' % p)
                                if os.path.exists(f):
                                    os.system('tar -rf %s %s' % (tar, f))
                            if os.path.exists(tar):
                                os.system('bzip2 -qf %s' % tar)
                            #Remove old tar's in working dir, if they exist and copy new one over.
                            if os.path.exists(
                                    os.path.join(self.working_dir,
                                                 '%s.bz2' % tar)):
                                os.system('rm -rf %s' % os.path.join(
                                    self.working_dir, '%s.bz2' % tar))
                            shutil.copy('%s.bz2' % tar, self.working_dir)
                        self.phaser_results[sg].get('AutoMR results').update({
                            'AutoMR tar':
                            os.path.join(self.working_dir, '%s.bz2' % tar)
                        })
                    else:
                        self.phaser_results[sg].get('AutoMR results').update(
                            {'AutoMR tar': 'None'})
            cell_results = {'Cell analysis results': self.phaser_results}

        except:
            self.logger.exception(
                '**Could not AutoMR results in AutoMolRep.postprocess.**')
            cell_results = {'Cell analysis results': 'FAILED'}
            self.clean = False
            failed = True

        try:
            output_files = {'Output files': output}
        except:
            self.logger.exception(
                '**Could not update the output dict in AutoMolRep.postprocess.**'
            )

        #Get proper status.
        if final:
            if failed:
                status = {'status': 'FAILED'}
            else:
                status = {'status': 'SUCCESS'}
        else:
            status = {'status': 'WORKING'}

        #Put all the result dicts from all the programs run into one resultant dict and pass it back.
        try:
            if self.gui == False:
                if self.input[0] == "SAD":
                    self.input.remove("SAD")
                    self.input.insert(0, 'MR')
            if status:
                results.update(status)
            if cell_results:
                results.update(cell_results)
            # Utils.pp(self,cell_results)
            if output_files:
                results.update(output_files)
            # Utils.pp(results)
            if self.gui:
                if results:
                    if len(self.input) == 6:
                        # Delete the previous Phaser results sent back.
                        del self.input[5]
                    self.input.append(results)
                rapd_send(self.controller_address, self.input)

        except:
            self.logger.exception(
                '**Could not send results to pipe in AutoMolRep.postprocess.**'
            )

        if final:
            try:
                #Cleanup my mess.
                if self.clean:
                    os.chdir(self.working_dir)
                    if self.verbose:
                        self.logger.debug(
                            'Cleaning up Phaser files and folders')
                    os.system('rm -rf Phaser_* *.com *.pdb *.mtz *.sum')

            except:
                self.logger.exception(
                    '**Could not cleanup in AutoMolRep.postprocess**')

            #Say job is complete.
            t = round(time.time() - self.st)
            self.logger.debug(50 * '-')
            self.logger.debug('RAPD AutoMolRep complete.')
            self.logger.debug('Total elapsed time: %s seconds' % t)
            self.logger.debug(50 * '-')
            print 50 * '-'
            print 'RAPD AutoMolRep complete.'
            print 'Total elapsed time: %s seconds' % t
            print 50 * '-'
Exemple #8
0
    def postprocess(self):
        """
        Pass info back to the core.
        """
        if self.verbose:
            self.logger.debug("LabelitPP::postprocess")

        failed = False
        output_files = False
        jpg = {}

        # Change to working dir.
        os.chdir(self.working_dir)

        # Save the path for the jpg files
        l = ["0KL", "H0L", "HK0"]
        for i in range(len(l)):
            try:
                if os.path.exists("pp%s.jpg"%i):
                    jpg["%s jpg" % l[i]] = os.path.join(self.working_dir, "pp%s.jpg"%i)
                else:
                    jpg["%s jpg" % l[i]] = None
                    self.clean = False
            except:
                self.logger.exception("**Could not save LabelitPP results**")
                failed = True
        self.labelitpp_results = {"LabelitPP results": jpg}

        # Create and save path of html summary file
        self.html_summary_pp()

        try:
            output = {}
            if self.gui:
                html = "jon_summary_pp.php"
            else:
                html = "jon_summary_pp.html"
            if os.path.exists(html):
                output["LabelitPP summary html"] = os.path.join(self.working_dir, html)
            else:
                output["LabelitPP summary html"] = "None"
            output_files = {"Output files": output}
        except:
            self.logger.exception("**Could not save LabelitPP html path**")
            failed = True

        status = {}
        if failed:
            status["status"] = "FAILED"
        else:
            status["status"] = "SUCCESS"

        #Send back results
        try:
            results = {}
            results.update(status)
            if self.labelitpp_results:
                results.update(self.labelitpp_results)
            if output_files:
                results.update(output_files)
            if self.output != None:
                self.output.put(results)
            else:
                if self.gui:
                    self.input.append(results)
                    #   self.sendBack2(self.input)
                    rapd_send(self.controller_address, self.input)
        except:
            self.logger.exception("**Could not send results to pipe.**")

        try:
            #Cleanup my mess.
            if self.clean:
                if self.verbose:
                    self.logger.debug("Cleaning up files and folders")
                if os.path.exists(self.labelit_dir):
                    os.system("rm -rf %s"%self.labelit_dir)
                    # os.system("rm -rf Labelit*")
        except:
            self.logger.exception("**Could not cleanup**")

        # Say job is complete.
        t = round(time.time()-self.st)
        self.logger.debug("-------------------------------------")
        self.logger.debug("RAPD labelit.precession_photo complete.")
        self.logger.debug("Total elapsed time: %s seconds" % t)
        self.logger.debug("-------------------------------------")
        if self.output == None:
            print "\n-------------------------------------"
            print "RAPD labelit.precession_photo complete."
            print "Total elapsed time: %s seconds" % t
            print "-------------------------------------"
Exemple #9
0
    def postprocess(self):
        """
    Run summaries, make php/html files, send data back, and clean up.
    """
        if self.verbose:
            self.logger.debug('AutoStats::postprocess')

        output = {}
        status = {}
        results = {}
        failed = False
        cell_results = False
        cell_out = False
        pp_results = False
        pp_out = False

        #Make the output html files
        self.plotXtriage()
        if self.xtriage_results:
            Summary.summaryXtriage(self)
        self.htmlSummaryXtriage()
        if self.molrep_results:
            Summary.summaryMolrep(self)
        self.htmlSummaryMolrep()

        if self.gui:
            e = '.php'
        else:
            e = '.html'
        l = [('jon_summary_xtriage%s' % e, 'Xtriage summary html'),
             ('plots_xtriage%s' % e, 'Xtriage plots html'),
             ('jon_summary_molrep%s' % e, 'Molrep summary html')]
        for i in range(len(l)):
            try:
                path = os.path.join(self.working_dir, l[i][0])
                if os.path.exists(path):
                    output[l[i][1]] = path
                else:
                    output[l[i][1]] = 'None'
            except:
                self.logger.exception(
                    '**Could not update paths of %s file.**' % l[i][0])
                output[l[i][1]] = 'FAILED'
                failed = True

        #Get rapd_agent_cell results back
        try:
            cell_results = self.cell_output.get()
            if cell_results.has_key('status'):
                if cell_results['status'] == 'FAILED':
                    failed = True
                del cell_results['status']
            if cell_results.has_key('Output files'):
                cell_out = cell_results['Output files']
                del cell_results['Output files']
        except:
            self.logger.exception(
                '**Error importing rapd_agent_cell results**')

        #Get rapd_agent_pp results back
        try:
            if self.pp:
                pp_results = self.pp_output.get()
                if pp_results.has_key('status'):
                    if pp_results['status'] == 'FAILED':
                        failed = True
                    del pp_results['status']
                if pp_results.has_key('Output files'):
                    pp_out = pp_results['Output files']
                    del pp_results['Output files']
            else:
                #Put together the dict from LabelitPP and create an html summary.
                pp_results = {
                    'LabelitPP results': {
                        'HK0 jpg': None,
                        'H0L jpg': None,
                        '0KL jpg': None
                    }
                }
                Utils.failedHTML(
                    self,
                    ('jon_summary_pp',
                     'Cannot create precession photos from merged datasets.'))
                if os.path.exists(
                        os.path.join(self.working_dir,
                                     'jon_summary_pp%s' % e)):
                    pp_out = {
                        'LabelitPP summary html':
                        os.path.join(self.working_dir, 'jon_summary_pp%s' % e)
                    }
                else:
                    pp_out = {'LabelitPP summary html': 'None'}

        except:
            self.logger.exception(
                '**Error importing rapd_agent_cell results**')
        #Get proper status.
        if failed:
            status['status'] = 'FAILED'
        else:
            status['status'] = 'SUCCESS'
        #Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
        try:
            results.update(status)
            if self.xtriage_results:
                results.update(self.xtriage_results)
            if self.molrep_results:
                results.update(self.molrep_results)
            if cell_results:
                results.update(cell_results)
            if pp_results:
                results.update(pp_results)
            if output:
                if cell_out:
                    output.update(cell_out)
                if pp_out:
                    output.update(pp_out)
                results.update(output)
            self.input.insert(0, 'STATS')
            self.input.append(results)
            if self.gui:
                rapd_send(self.controller_address, self.input)

        except:
            self.logger.exception("**Could not send results to pipe.**")

        try:
            #Cleanup my mess.
            if self.clean:
                if failed == False:
                    if self.verbose:
                        self.logger.debug('Cleaning up files')
                    os.system(
                        'rm -rf *.ps *.btc *.tab *.xml *.com molrep.doc molrep.log logfile.log xtriage.log phaser2.log PHASER.mtz'
                    )
        except:
            self.logger.exception('**Could not cleanup**')

        #Say job is complete.
        t = round(time.time() - self.st)
        self.logger.debug('-------------------------------------')
        self.logger.debug('RAPD AutoStat complete.')
        self.logger.debug('Total elapsed time: %s seconds' % t)
        self.logger.debug('-------------------------------------')
        print '\n-------------------------------------'
        print 'RAPD AutoStat complete.'
        print 'Total elapsed time: %s seconds' % t
        print '-------------------------------------'
Exemple #10
0
  def postprocess(self):
    """
    Put everything together and send back dict.
    """
    if self.verbose:
      self.logger.debug('PDBQuery::postprocess')
    output = {}
    status = False
    output_files = False
    cell_results = False
    failed = False

    #Add tar info to automr results and take care of issue if no SCA file was input.
    try:
      def check_bz2(tar):
        #Remove old tar's in working dir, if they exist and copy new one over.
        if os.path.exists(os.path.join(self.working_dir,'%s.bz2'%tar)):
          os.system('rm -rf %s'%os.path.join(self.working_dir,'%s.bz2'%tar))
        shutil.copy('%s.bz2'%tar,self.working_dir)

      if self.cell_output:
        for pdb in self.phaser_results.keys():
          pdb_file = self.phaser_results[pdb].get('AutoMR results').get('AutoMR pdb')
          mtz_file = self.phaser_results[pdb].get('AutoMR results').get('AutoMR mtz')
          adf_file = self.phaser_results[pdb].get('AutoMR results').get('AutoMR adf')
          peak_file = self.phaser_results[pdb].get('AutoMR results').get('AutoMR peak')
          if pdb_file not in ('No solution','Timed out','NA','Still running','DL Failed'):
            #pack all the output files into a tar and save the path
            os.chdir(self.phaser_results[pdb].get('AutoMR results').get('AutoMR dir'))
            tar = '%s.tar'%pdb
            #Speed up in testing mode.
            if os.path.exists('%s.bz2'%tar):
              check_bz2(tar)
              self.phaser_results[pdb].get('AutoMR results').update({'AutoMR tar': os.path.join(self.working_dir,'%s.bz2'%tar)})
            else:
              l = [pdb_file,mtz_file,adf_file,peak_file,pdb_file.replace('.pdb','_refine_001.pdb'),mtz_file.replace('.mtz','_refine_001.mtz')]
              for p in l:
                if os.path.exists(p):
                  os.system('tar -rf %s %s'%(tar,p))
              if os.path.exists(tar):
                os.system('bzip2 -qf %s'%tar)
                check_bz2(tar)
                self.phaser_results[pdb].get('AutoMR results').update({'AutoMR tar': os.path.join(self.working_dir,'%s.bz2'%tar)})
              else:
                self.phaser_results[pdb].get('AutoMR results').update({'AutoMR tar': 'None'})
          #Save everthing into one dict
          if pdb in self.cell_output.keys():
            self.phaser_results[pdb].update(self.cell_output[pdb])
          else:
            self.phaser_results[pdb].update(self.cell_output[pdb[:pdb.rfind('_')]])
        cell_results = { 'Cell analysis results': self.phaser_results}
      else:
        cell_results = { 'Cell analysis results': 'None' }
    except:
      self.logger.exception('**Could not AutoMR results in postprocess.**')
      cell_results = { 'Cell analysis results': 'FAILED'}
      failed = True

    try:
      #Create the output html file
      os.chdir(self.working_dir)
      Summary.summaryCell(self,'pdbquery')
      self.htmlSummary()
      if self.gui:
        sl = 'jon_summary_cell.php'
      else:
        sl = 'jon_summary_cell.html'
      if os.path.exists(os.path.join(self.working_dir,sl)):
        output['Cell summary html'] = os.path.join(self.working_dir,sl)
      else:
        output['Cell summary html'] = 'None'
    except:
      self.logger.exception('**Could not update path of shelx summary html file.**')
      output['Cell summary html']   = 'FAILED'
      failed = True

    try:
      output_files = {'Output files' : output}
    except:
      self.logger.exception('**Could not update the output dict.**')

    #Get proper status.
    if failed:
      status = {'status': 'FAILED'}
      self.clean = False
    else:
      status = {'status': 'SUCCESS'}

    #Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
    try:
      results = {}
      if status:
        results.update(status)
      if cell_results:
        results.update(cell_results)
      if output_files:
        results.update(output_files)
      if results:
        self.input.append(results)
      if self.output != None:
        self.output.put(results)
      else:
        if self.gui:
        #   self.sendBack2(self.input)
          rapd_send(self.controller_address, self.input)
    except:
      self.logger.exception('**Could not send results to pipe.**')

    try:
      #Cleanup my mess.
      if self.clean:
        os.chdir(self.working_dir)
        os.system('rm -rf Phaser_* temp.mtz')
        if self.verbose:
          self.logger.debug('Cleaning up Phaser files and folders')
    except:
      self.logger.exception('**Could not cleanup**')

    #Say job is complete.
    t = round(time.time()-self.st)
    self.logger.debug(50*'-')
    self.logger.debug('RAPD PDBQuery complete.')
    self.logger.debug('Total elapsed time: %s seconds'%t)
    self.logger.debug(50*'-')
    if self.output == None:
      print 50*'-'
      print '\nRAPD PDBQuery complete.'
      print 'Total elapsed time: %s seconds'%t
      print 50*'-'
Exemple #11
0
    def postprocess(self):
        """
        Put everything together and send back dict.
        """
        if self.verbose:
            self.logger.debug("PDBQuery::postprocess")

        output = {}
        status = False
        output_files = False
        cell_results = False
        failed = False

        # Add tar info to automr results and take care of issue if no SCA file was input.
        try:
            def check_bz2(tar):
                # Remove old tar's in working dir, if they exist and copy new one over.
                if os.path.exists(os.path.join(self.working_dir, "%s.bz2" % tar)):
                    os.system("rm -rf %s" % os.path.join(self.working_dir, "%s.bz2" % tar))
                shutil.copy("%s.bz2" % tar, self.working_dir)

            if self.cell_output:
                for pdb in self.phaser_results.keys():
                    pdb_file = self.phaser_results[pdb].get("AutoMR results").get("AutoMR pdb")
                    mtz_file = self.phaser_results[pdb].get("AutoMR results").get("AutoMR mtz")
                    adf_file = self.phaser_results[pdb].get("AutoMR results").get("AutoMR adf")
                    peak_file = self.phaser_results[pdb].get("AutoMR results").get("AutoMR peak")
                    if pdb_file not in ("No solution", "Timed out", "NA", "Still running", "DL Failed"):
                        #pack all the output files into a tar and save the path
                        os.chdir(self.phaser_results[pdb].get("AutoMR results").get("AutoMR dir"))
                        tar = "%s.tar" % pdb
                        #Speed up in testing mode.
                        if os.path.exists("%s.bz2" % tar):
                            check_bz2(tar)
                            self.phaser_results[pdb].get("AutoMR results").update({"AutoMR tar": os.path.join(self.working_dir, "%s.bz2" % tar)})
                        else:
                            l = [pdb_file, mtz_file, adf_file, peak_file, pdb_file.replace(".pdb", "_refine_001.pdb"), mtz_file.replace(".mtz", "_refine_001.mtz")]
                            for p in l:
                                if os.path.exists(p):
                                    os.system("tar -rf %s %s" % (tar, p))
                            if os.path.exists(tar):
                                os.system("bzip2 -qf %s" % tar)
                                check_bz2(tar)
                                self.phaser_results[pdb].get("AutoMR results").update({"AutoMR tar": os.path.join(self.working_dir, "%s.bz2" % tar)})
                            else:
                                self.phaser_results[pdb].get("AutoMR results").update({"AutoMR tar": "None"})
                    #Save everthing into one dict
                    if pdb in self.cell_output.keys():
                        self.phaser_results[pdb].update(self.cell_output[pdb])
                    else:
                        self.phaser_results[pdb].update(self.cell_output[pdb[:pdb.rfind("_")]])
                cell_results = {"Cell analysis results":self.phaser_results}
            else:
                cell_results = {"Cell analysis results":"None"}
        except:
            self.logger.exception("**Could not AutoMR results in postprocess.**")
            cell_results = {"Cell analysis results":"FAILED"}
            failed = True

        try:
            # Create the output html file
            os.chdir(self.working_dir)
            Summary.summaryCell(self, "pdbquery")
            self.html_summary()
            if self.gui:
                sl = "jon_summary_cell.php"
            else:
                sl = "jon_summary_cell.html"
            if os.path.exists(os.path.join(self.working_dir, sl)):
                output["Cell summary html"] = os.path.join(self.working_dir, sl)
            else:
                output["Cell summary html"] = "None"
        except:
            self.logger.exception("**Could not update path of shelx summary html file.**")
            output["Cell summary html"] = "FAILED"
            failed = True

        try:
            output_files = {"Output files":output}
        except:
            self.logger.exception("**Could not update the output dict.**")

        #Get proper status.
        if failed:
            status = {"status":"FAILED"}
            self.clean = False
        else:
            status = {"status":"SUCCESS"}

        #Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
        try:
            results = {}
            if status:
                results.update(status)
            if cell_results:
                results.update(cell_results)
            if output_files:
                results.update(output_files)
            if results:
                self.input.append(results)
            if self.output != None:
                self.output.put(results)
            else:
                if self.gui:
                #   self.sendBack2(self.input)
                    rapd_send(self.controller_address, self.input)
        except:
            self.logger.exception("**Could not send results to pipe**")

        try:
            # Cleanup my mess.
            if self.clean:
                os.chdir(self.working_dir)
                os.system("rm -rf Phaser_* temp.mtz")
                if self.verbose:
                    self.logger.debug("Cleaning up Phaser files and folders")
        except:
            self.logger.exception("**Could not cleanup**")

        # Say job is complete.
        t = round(time.time()-self.st)
        self.logger.debug(50*"-")
        self.logger.debug("RAPD PDBQuery complete.")
        self.logger.debug("Total elapsed time: %s seconds" % t)
        self.logger.debug(50*"-")
        if self.output == None:
            print 50*"-"
            print "\nRAPD PDBQuery complete."
            print "Total elapsed time: %s seconds" % t
            print 50*"-"
Exemple #12
0
  def postprocess(self):
    """
    Run summaries, make php/html files, send data back, and clean up.
    """
    if self.verbose:
      self.logger.debug('AutoStats::postprocess')

    output = {}
    status = {}
    results = {}
    failed = False
    cell_results = False
    cell_out = False
    pp_results = False
    pp_out = False

    #Make the output html files
    self.plotXtriage()
    if self.xtriage_results:
      Summary.summaryXtriage(self)
    self.htmlSummaryXtriage()
    if self.molrep_results:
      Summary.summaryMolrep(self)
    self.htmlSummaryMolrep()

    if self.gui:
      e = '.php'
    else:
      e = '.html'
    l = [('jon_summary_xtriage%s'%e,'Xtriage summary html'),
          ('plots_xtriage%s'%e,'Xtriage plots html'),
          ('jon_summary_molrep%s'%e,'Molrep summary html')]
    for i in range(len(l)):
      try:
        path = os.path.join(self.working_dir,l[i][0])
        if os.path.exists(path):
          output[l[i][1]] = path
        else:
          output[l[i][1]] = 'None'
      except:
        self.logger.exception('**Could not update paths of %s file.**'%l[i][0])
        output[l[i][1]] = 'FAILED'
        failed = True

    #Get rapd_agent_cell results back
    try:
      cell_results = self.cell_output.get()
      if cell_results.has_key('status'):
        if cell_results['status'] == 'FAILED':
          failed = True
        del cell_results['status']
      if cell_results.has_key('Output files'):
        cell_out = cell_results['Output files']
        del cell_results['Output files']
    except:
      self.logger.exception('**Error importing rapd_agent_cell results**')

    #Get rapd_agent_pp results back
    try:
      if self.pp:
        pp_results = self.pp_output.get()
        if pp_results.has_key('status'):
          if pp_results['status'] == 'FAILED':
            failed = True
          del pp_results['status']
        if pp_results.has_key('Output files'):
          pp_out = pp_results['Output files']
          del pp_results['Output files']
      else:
        #Put together the dict from LabelitPP and create an html summary.
        pp_results = {'LabelitPP results': {'HK0 jpg':None,'H0L jpg':None,'0KL jpg':None}}
        Utils.failedHTML(self,('jon_summary_pp','Cannot create precession photos from merged datasets.'))
        if os.path.exists(os.path.join(self.working_dir,'jon_summary_pp%s'%e)):
          pp_out = {'LabelitPP summary html':os.path.join(self.working_dir,'jon_summary_pp%s'%e)}
        else:
          pp_out = {'LabelitPP summary html':'None'}

    except:
      self.logger.exception('**Error importing rapd_agent_cell results**')
    #Get proper status.
    if failed:
      status['status'] = 'FAILED'
    else:
      status['status'] = 'SUCCESS'
    #Put all the result dicts from all the programs run into one resultant dict and pass it along the pipe.
    try:
        results.update(status)
        if self.xtriage_results:
            results.update(self.xtriage_results)
        if self.molrep_results:
            results.update(self.molrep_results)
        if cell_results:
            results.update(cell_results)
        if pp_results:
            results.update(pp_results)
        if output:
            if cell_out:
                output.update(cell_out)
            if pp_out:
                output.update(pp_out)
            results.update(output)
        self.input.insert(0,'STATS')
        self.input.append(results)
        if self.gui:
            rapd_send(self.controller_address, self.input)

    except:
        self.logger.exception("**Could not send results to pipe.**")

    try:
      #Cleanup my mess.
      if self.clean:
        if failed == False:
          if self.verbose:
            self.logger.debug('Cleaning up files')
          os.system('rm -rf *.ps *.btc *.tab *.xml *.com molrep.doc molrep.log logfile.log xtriage.log phaser2.log PHASER.mtz')
    except:
      self.logger.exception('**Could not cleanup**')

    #Say job is complete.
    t = round(time.time()-self.st)
    self.logger.debug('-------------------------------------')
    self.logger.debug('RAPD AutoStat complete.')
    self.logger.debug('Total elapsed time: %s seconds'%t)
    self.logger.debug('-------------------------------------')
    print '\n-------------------------------------'
    print 'RAPD AutoStat complete.'
    print 'Total elapsed time: %s seconds'%t
    print '-------------------------------------'