def restore_selected(self): items = [item for item in self.tree.selectedItems()] model_dict = self.session.filereader_manager.filereader_dict models = list(model_dict.keys()) for item in items: parent = item.parent() mdl = models[self.tree.indexOfTopLevelItem(parent)] if parent is None: fr = model_dict[mdl][-1] else: fr = model_dict[mdl][parent.indexOfChild(item)] fr_rescol = ResidueCollection(fr) fr_rescol.update_chix(mdl) if fr.all_geom is not None and len(fr.all_geom) > 1: coordsets = fr_rescol.all_geom_coordsets(fr) mdl.remove_coordsets() mdl.add_coordsets(coordsets) for i, coordset in enumerate(coordsets): mdl.active_coordset_id = i + 1 for atom, coord in zip(mdl.atoms, coordset): atom.coord = coord mdl.active_coordset_id = 1
def job_finished(self, trigger_name, job): """when a job is finished, open or update the structure as requested""" if self.session.seqcrow_settings.settings.JOB_FINISHED_NOTIFICATION == \ 'log and popup notifications' and self.session.ui.is_gui: #it's just an error message for now #TODO: make my own logger self.session.logger.error("%s: %s" % (trigger_name, job)) else: job.session.logger.info("%s: %s" % (trigger_name, job)) if isinstance(job, LocalJob): self._thread = None if not hasattr(job, "output_name") or \ not os.path.exists(job.output_name): job.error = True else: fr = FileReader(job.output_name, just_geom=False) #XXX: finished is not added to the FileReader for ORCA and Psi4 when finished = False if 'finished' not in fr.other or not fr.other['finished']: job.error = True if job.auto_update and ( job.theory.geometry.chix_atomicstructure is not None and not job.theory.geometry.chix_atomicstructure.deleted): if os.path.exists(job.output_name): finfo = job.output_name try: finfo = (job.output_name, job.format_name, None) fr = FileReader(finfo, get_all=True, just_geom=False) if len(fr.atoms) > 0: job.session.filereader_manager.triggers.activate_trigger( ADD_FILEREADER, ([job.theory.geometry.chix_atomicstructure], [fr])) rescol = ResidueCollection(fr) rescol.update_chix( job.theory.geometry.chix_atomicstructure) except: job.update_structure() if fr.all_geom is not None and len(fr.all_geom) > 1: coordsets = rescol.all_geom_coordsets(fr) job.theory.geometry.chix_atomicstructure.remove_coordsets() job.theory.geometry.chix_atomicstructure.add_coordsets( coordsets) for i, coordset in enumerate(coordsets): job.theory.geometry.chix_atomicstructure.active_coordset_id = i + 1 for atom, coord in zip( job.theory.geometry.chix_atomicstructure.atoms, coordset): atom.coord = coord job.theory.geometry.chix_atomicstructure.active_coordset_id = job.theory.geometry.chix_atomicstructure.num_coordsets elif job.auto_open or job.auto_update: if hasattr(job, "output_name") and os.path.exists(job.output_name): if job.format_name: run( job.session, "open \"%s\" coordsets true format %s" % (job.output_name, job.format_name)) else: run(job.session, "open \"%s\" coordsets true" % job.output_name) else: self.session.logger.error("could not open output of %s" % repr(job)) self.triggers.activate_trigger(JOB_QUEUED, trigger_name) pass