def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('AutoStats::Queue') try: timed_out = False timer = 0 jobs = self.jobs_output.keys() if jobs != ['None']: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() jobs.remove(job) del self.pids[self.jobs_output[job]] counter -= 1 time.sleep(0.2) timer += 0.2 """ if self.verbose: if round(timer%1,1) in (0.0,1.0): print 'Waiting for AutoStat jobs to finish '+str(timer)+' seconds' """ if self.stats_timer: if timer >= self.stats_timer: timed_out = True break if timed_out: if self.verbose: self.logger.debug('AutoStat timed out.') print 'AutoStat timed out.' for pid in self.pids.values(): #jobs are not sent to cluster Utils.killChildren(self, pid) for job in jobs: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() if self.verbose: self.logger.debug('AutoStats Queue finished.') except: self.logger.exception('**ERROR in Autostat.Queue**')
def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('AutoStats::Queue') try: timed_out = False timer = 0 jobs = self.jobs_output.keys() if jobs != ['None']: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() jobs.remove(job) del self.pids[self.jobs_output[job]] counter -= 1 time.sleep(0.2) timer += 0.2 """ if self.verbose: if round(timer%1,1) in (0.0,1.0): print 'Waiting for AutoStat jobs to finish '+str(timer)+' seconds' """ if self.stats_timer: if timer >= self.stats_timer: timed_out = True break if timed_out: if self.verbose: self.logger.debug('AutoStat timed out.') print 'AutoStat timed out.' for pid in self.pids.values(): #jobs are not sent to cluster Utils.killChildren(self,pid) for job in jobs: if self.jobs_output[job] == 'xtriage': self.postprocessXtriage() if self.jobs_output[job] == 'molrep': self.postprocessMolrep() if self.jobs_output[job] == 'NCS': self.postprocessNCS() if self.verbose: self.logger.debug('AutoStats Queue finished.') except: self.logger.exception('**ERROR in Autostat.Queue**')
def run_queue(self): """ queue system. """ if self.verbose: self.logger.debug("AutoStats::Queue") try: timed_out = False timer = 0 jobs = self.jobs_output.keys() if jobs != ["None"]: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: if self.jobs_output[job] == "xtriage": self.postprocess_xtriage() if self.jobs_output[job] == "molrep": self.postprocessMolrep() if self.jobs_output[job] == "NCS": self.postprocess_ncs() jobs.remove(job) del self.pids[self.jobs_output[job]] counter -= 1 time.sleep(0.2) timer += 0.2 if self.stats_timer: if timer >= self.stats_timer: timed_out = True break if timed_out: if self.verbose: self.logger.debug("AutoStat timed out.") print "AutoStat timed out." for pid in self.pids.values(): # jobs are not sent to cluster Utils.killChildren(self, pid) for job in jobs: if self.jobs_output[job] == "xtriage": self.postprocess_xtriage() if self.jobs_output[job] == "molrep": self.postprocessMolrep() if self.jobs_output[job] == "NCS": self.postprocess_ncs() if self.verbose: self.logger.debug("AutoStats Queue finished.") except: self.logger.exception("**ERROR in Autostat.Queue**")
def checkSolution(self): """ Check if solution is found. If not alter input and rerun. """ if self.verbose: self.logger.debug('AutoMolRep::checkSolution') try: solution = False keys = self.phaser_results.keys() keys0 = [key for key in keys if key[-1] == '0'] keys1 = [key for key in keys if key[-1] == '1'] for key in keys0: sg = self.phaser_results[key].get('AutoMR results').get( 'AutoMR sg') if sg not in ('No solution', 'Timed out', 'NA'): solution = True if solution: #Kill the jobs and remove the results for k in keys1: if self.cluster_use: #Utils.killChildrenCluster(self,self.output['pids'][k]) BLspec.killChildrenCluster(self, self.output['pids'][k]) else: Utils.killChildren(self, self.output['pids'][k]) del self.phaser_results[k] else: self.run_before = True #Remove results from quick run if no solution found. for k in keys0: del self.phaser_results[k] #Run the full Phaser jobs. if self.cluster_use == False: self.preprocessPhaser() else: self.phaser_jobs = keys1 self.postprocess(False) self.Queue() except: self.logger.exception('**ERROR in AutoMolRep.checkSolution**')
def checkSolution(self): """ Check if solution is found. If not alter input and rerun. """ if self.verbose: self.logger.debug('AutoMolRep::checkSolution') try: solution = False keys = self.phaser_results.keys() keys0 = [key for key in keys if key[-1] == '0'] keys1 = [key for key in keys if key[-1] == '1'] for key in keys0: sg = self.phaser_results[key].get('AutoMR results').get('AutoMR sg') if sg not in ('No solution','Timed out','NA'): solution = True if solution: #Kill the jobs and remove the results for k in keys1: if self.cluster_use: #Utils.killChildrenCluster(self,self.output['pids'][k]) BLspec.killChildrenCluster(self,self.output['pids'][k]) else: Utils.killChildren(self,self.output['pids'][k]) del self.phaser_results[k] else: self.run_before = True #Remove results from quick run if no solution found. for k in keys0: del self.phaser_results[k] #Run the full Phaser jobs. if self.cluster_use == False: self.preprocessPhaser() else: self.phaser_jobs = keys1 self.postprocess(False) self.Queue() except: self.logger.exception('**ERROR in AutoMolRep.checkSolution**')
def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('AutoMolRep::Queue') try: timed_out = False timer = 0 jobs = self.output['jobs'].keys() #set which jobs to watch. if self.run_before: jobs = [job for job in jobs if self.output['jobs'][job][-1] == '1'] else: jobs = [job for job in jobs if self.output['jobs'][job][-1] == '0'] counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) if self.verbose: self.logger.debug('Finished Phaser on %s'%self.output['jobs'][job]) Utils.folders(self,self.output['jobs'][job]) if self.adf: if os.path.exists('adf.com'): del self.output['pids'][self.output['jobs'][job]] counter -= 1 else: key = self.output['jobs'].pop(job) p = self.postprocessPhaser(key) if p == 'ADF': #Calculate ADF map. adf = Process(target=Utils.calcADF,name='ADF%s'%key,args=(self,key)) adf.start() jobs.append(adf) self.output['jobs'][adf] = key else: counter -= 1 self.postprocess(False) else: self.postprocessPhaser(self.output['jobs'][job]) del self.output['pids'][self.output['jobs'][job]] self.postprocess(False) counter -= 1 time.sleep(0.2) timer += 0.2 if self.verbose: number = round(timer%1,1) if number in (0.0,1.0): print 'Waiting for Phaser to finish %s seconds'%timer if self.phaser_timer: if timer >= self.phaser_timer: timed_out = True break if timed_out: self.logger.debug('Phaser timed out.') print 'Phaser timed out.' for job in jobs: self.phaser_results[self.output['jobs'][job]] = {'AutoMR results':Parse.setPhaserFailed('Timed out')} if self.cluster_use: #Utils.killChildrenCluster(self,self.output['pids'][self.output['jobs'][job]]) BLspec.killChildrenCluster(self,self.output['pids'][self.output['jobs'][job]]) else: Utils.killChildren(self,self.output['pids'][self.output['jobs'][job]]) #Check if solution has been found. if self.run_before == False: self.checkSolution() self.logger.debug('Phaser finished.') except: self.logger.exception('**ERROR in AutoMolRep.Queue**')
def run_queue(self): """ queue system. """ self.logger.debug("PDBQuery::run_queue") try: timed_out = False timer = 0 if self.jobs != {}: jobs = self.jobs.keys() while len(jobs) != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) code = self.jobs.pop(job) xutils.folders(self, "Phaser_%s" % code) new_jobs = [] if self.test == False: del self.pids[code] #if self.verbose: self.logger.debug("Finished Phaser on %s" % code) p = self.postprocess_phaser(code) # if p.count("rigid"): # if os.path.exists("rigid.log") == False: # j = Process(target=self.process_refine, args=(code, )) # j.start() # new_jobs.append(j) # if self.test: # time.sleep(5) # if p.count("ADF"): # if os.path.exists("adf.com") == False: # j = Process(target=xutils.calcADF, args=(self, code)) # j.start() # new_jobs.append(j) # if len(new_jobs) > 0: # for j1 in new_jobs: # self.jobs[j1] = code # jobs.append(j1) time.sleep(0.2) timer += 0.2 if self.phaser_timer: if timer >= self.phaser_timer: timed_out = True break if timed_out: for j in self.jobs.values(): if self.pids.has_key(j): if self.cluster_use: # TODO # BLspec.killChildrenCluster(self,self.pids[j]) pass else: xutils.killChildren(self, self.pids[j]) if self.phaser_results.has_key(j) == False: self.phaser_results[j] = {"AutoMR results": Parse.setPhaserFailed("Timed out")} if self.verbose: self.logger.debug("PDBQuery timed out.") print "PDBQuery timed out." if self.verbose: self.logger.debug("PDBQuery.run_queue finished.") except: self.logger.exception("**ERROR in PDBQuery.run_queue**")
def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('AutoMolRep::Queue') try: timed_out = False timer = 0 jobs = self.output['jobs'].keys() #set which jobs to watch. if self.run_before: jobs = [ job for job in jobs if self.output['jobs'][job][-1] == '1' ] else: jobs = [ job for job in jobs if self.output['jobs'][job][-1] == '0' ] counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) if self.verbose: self.logger.debug('Finished Phaser on %s' % self.output['jobs'][job]) Utils.folders(self, self.output['jobs'][job]) if self.adf: if os.path.exists('adf.com'): del self.output['pids'][self.output['jobs'] [job]] counter -= 1 else: key = self.output['jobs'].pop(job) p = self.postprocessPhaser(key) if p == 'ADF': #Calculate ADF map. adf = Process(target=Utils.calcADF, name='ADF%s' % key, args=(self, key)) adf.start() jobs.append(adf) self.output['jobs'][adf] = key else: counter -= 1 self.postprocess(False) else: self.postprocessPhaser(self.output['jobs'][job]) del self.output['pids'][self.output['jobs'][job]] self.postprocess(False) counter -= 1 time.sleep(0.2) timer += 0.2 if self.verbose: number = round(timer % 1, 1) if number in (0.0, 1.0): print 'Waiting for Phaser to finish %s seconds' % timer if self.phaser_timer: if timer >= self.phaser_timer: timed_out = True break if timed_out: self.logger.debug('Phaser timed out.') print 'Phaser timed out.' for job in jobs: self.phaser_results[self.output['jobs'][job]] = { 'AutoMR results': Parse.setPhaserFailed('Timed out') } if self.cluster_use: #Utils.killChildrenCluster(self,self.output['pids'][self.output['jobs'][job]]) BLspec.killChildrenCluster( self, self.output['pids'][self.output['jobs'][job]]) else: Utils.killChildren( self, self.output['pids'][self.output['jobs'][job]]) #Check if solution has been found. if self.run_before == False: self.checkSolution() self.logger.debug('Phaser finished.') except: self.logger.exception('**ERROR in AutoMolRep.Queue**')
def run_queue(self, run_before=False): """ Run queue for Labelit. """ if self.verbose: self.logger.debug("LabelitPP::run_queue") try: timed_out = False timer = 0 rerun = False jobs = self.pp_jobs.keys() if jobs != ["None"]: counter = len(jobs) while counter != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) del self.pids[self.pp_jobs[job]] job = self.postprocess_labelit_precession(self.pp_jobs[job]) if job == "kill": timed_out = True rerun = True counter = 0 break else: counter -= 1 time.sleep(0.2) timer += 0.2 if self.output == None: if self.verbose: if round(timer%1, 1) in (0.0, 1.0): print "Waiting for Labelit.precession_photo to finish %s seconds"%timer if self.labelitpp_timer: if timer >= self.labelitpp_timer: timed_out = True # Check folders to see why it timed out. self.clean = False break if timed_out: if self.verbose: self.logger.debug("Labelitpp timed out.") print "Labelitpp timed out." for pid in self.pids.values(): # TODO if False: # self.cluster_use: pass # Utils.killChildrenCluster(self,pid) # BLspec.killChildrenCluster(self, pid) else: Utils.killChildren(self, pid) if rerun: if run_before == False: self.pp_jobs = {} self.pids = {} self.process_labelit_precession() self.run_queue(True) if self.verbose: self.logger.debug("LabelitPP finished.") except: self.logger.exception("**Error in LabelitPP.run_queue**")
def Queue(self): """ queue system. """ if self.verbose: self.logger.debug('PDBQuery::Queue') try: timed_out = False timer = 0 if self.jobs != {}: jobs = self.jobs.keys() while len(jobs) != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) code = self.jobs.pop(job) Utils.folders(self,'Phaser_%s'%code) new_jobs = [] if self.test == False: del self.pids[code] #if self.verbose: self.logger.debug('Finished Phaser on %s'%code) p = self.postprocessPhaser(code) if p.count('rigid'): if os.path.exists('rigid.log') == False: j = Process(target=self.processRefine,args=(code,)) j.start() new_jobs.append(j) if self.test: time.sleep(5) if p.count('ADF'): if os.path.exists('adf.com') == False: j = Process(target=Utils.calcADF,args=(self,code)) j.start() new_jobs.append(j) if len(new_jobs) > 0: for j1 in new_jobs: self.jobs[j1] = code jobs.append(j1) time.sleep(0.2) timer += 0.2 if self.phaser_timer: if timer >= self.phaser_timer: timed_out = True break if timed_out: for j in self.jobs.values(): if self.pids.has_key(j): if self.cluster_use: BLspec.killChildrenCluster(self,self.pids[j]) else: Utils.killChildren(self,self.pids[j]) if self.phaser_results.has_key(j) == False: self.phaser_results[j] = {'AutoMR results': Parse.setPhaserFailed('Timed out')} if self.verbose: self.logger.debug('PDBQuery timed out.') print 'PDBQuery timed out.' if self.verbose: self.logger.debug('PDBQuery.Queue finished.') except: self.logger.exception('**ERROR in PDBQuery.Queue**')
def run_queue(self): """ queue system. """ if self.verbose: self.logger.debug("PDBQuery::run_queue") try: timed_out = False timer = 0 if self.jobs != {}: jobs = self.jobs.keys() while len(jobs) != 0: for job in jobs: if job.is_alive() == False: jobs.remove(job) code = self.jobs.pop(job) Utils.folders(self, "Phaser_%s" % code) new_jobs = [] if self.test == False: del self.pids[code] #if self.verbose: self.logger.debug("Finished Phaser on %s" % code) p = self.postprocess_phaser(code) if p.count("rigid"): if os.path.exists("rigid.log") == False: j = Process(target=self.process_refine, args=(code, )) j.start() new_jobs.append(j) if self.test: time.sleep(5) if p.count("ADF"): if os.path.exists("adf.com") == False: j = Process(target=Utils.calcADF, args=(self, code)) j.start() new_jobs.append(j) if len(new_jobs) > 0: for j1 in new_jobs: self.jobs[j1] = code jobs.append(j1) time.sleep(0.2) timer += 0.2 if self.phaser_timer: if timer >= self.phaser_timer: timed_out = True break if timed_out: for j in self.jobs.values(): if self.pids.has_key(j): if self.cluster_use: # TODO # BLspec.killChildrenCluster(self,self.pids[j]) pass else: Utils.killChildren(self, self.pids[j]) if self.phaser_results.has_key(j) == False: self.phaser_results[j] = {"AutoMR results": Parse.setPhaserFailed("Timed out")} if self.verbose: self.logger.debug("PDBQuery timed out.") print "PDBQuery timed out." if self.verbose: self.logger.debug("PDBQuery.run_queue finished.") except: self.logger.exception("**ERROR in PDBQuery.run_queue**")