def libadd_ring(self): """add ring to library or open it in a new model""" selection = self.session.seqcrow_ordered_selection_manager.selection if not selection.single_structure: raise RuntimeError("selected atoms must be on the same model") rescol = ResidueCollection(selection[0].structure) walk_atoms = rescol.find( [AtomSpec(atom.atomspec) for atom in selection]) if len(walk_atoms) < 1: raise RuntimeError("no walk direction could be determined") ring_name = self.ring_name.text() ring = Ring(rescol, name=ring_name, end=walk_atoms) ring.comment = "E:%s" % ",".join( [str(rescol.atoms.index(atom) + 1) for atom in walk_atoms]) if len(ring_name) == 0: chimerax_ring = ResidueCollection(ring).get_chimera(self.session) chimerax_ring.name = "ring preview" self.session.models.add([chimerax_ring]) bild_obj = show_walk_highlight(ring, chimerax_ring, [0.9, 0.4, 0.3, 0.9], self.session) self.session.models.add(bild_obj, parent=chimerax_ring) else: check_aaronlib_dir() filename = os.path.join(AARONLIB, "Rings", ring_name + ".xyz") if os.path.exists(filename): exists_warning = QMessageBox() exists_warning.setIcon(QMessageBox.Warning) exists_warning.setText( "%s already exists.\nWould you like to overwrite?" % filename) exists_warning.setStandardButtons(QMessageBox.Yes | QMessageBox.No) rv = exists_warning.exec_() if rv == QMessageBox.Yes: ring.write(outfile=filename) self.tool_window.status("%s added to ring library" % ring_name) else: self.tool_window.status( "%s has not been added to ring library" % ring_name) else: ring.write(outfile=filename) self.tool_window.status("%s added to ring library" % ring_name)
nargs=1, required=True, dest='walk', help="comma-separated list of atoms to define" + "the direction the ring is traversed (1-indexed)" ) args = libaddring_parser.parse_args() ring = Ring(args.infile) walk_atoms = args.walk.split(',') ring.find_end(len(walk_atoms), walk_atoms) ring.comment = "E:%s" % args.walk if args.name is None: print(ring.write(outfile=False)) else: ring_lib = Ring.AARON_LIBS ring_file = os.path.join(os.path.dirname(Ring.AARON_LIBS), args.name + '.xyz') if os.path.exists(ring_file): overwrite = input( "%s already exists.\nWould you like to overwrite it? (YES/no)\n" % ring_file ) if overwrite != "YES": print("%s to overwrite, not overwriting" % overwrite) sys.exit(0) ring.write(outfile=ring_file)