def testGetTitle(self): cmd.fragment('gly', 'm1') cmd.create('m1', 'm1', 1, 2) title = cmd.get_title('m1', 1) self.assertEqual(title, '') cmd.set_title('m1', 1, 'foo bar') title = cmd.get_title('m1', 1) self.assertEqual(title, 'foo bar') title = cmd.get_title('m1', 2) self.assertEqual(title, '') cmd.set_title('m1', 2, 'second state') title = cmd.get_title('m1', 2) self.assertEqual(title, 'second state')
def poke_pymol(self, matrix): """Forces PyMOL object to move. Argument: matrix -- transformation-rotation-transformation matrix in PyMOL format. """ for attached_structure in Registry.objects[self.derived_from].attachment: if cmd.get_title(*Registry.get(attached_structure, "name", "state")) == "PD": cmd.transform_object(Registry.get(attached_structure, "name"), matrix)
def load_state_dict(self): # establish relationship between names and states # ASSUMPTION: identifiers will be unique self.state_dict = {} sd = self.state_dict so = self.object if so != None: cnt = cmd.count_states(so) for a in range(1, cnt + 1): sd[cmd.get_title(so, a)] = a
def accept(self): # accept compound and advance if self.object == None: print " Filter-Error: Please choose an object first" else: state = cmd.get_state() ident = cmd.get_title(self.object, state) print " Filter: Accepting '%s'" % ident self.count(ident, accept_str) cmd.forward() cmd.refresh_wizard()
def _update_transformation(self): """Checks if PyMOL object matrix has changed and updates self, if so.""" try: if cmd.get_title(*Registry.get(self.attachment.main_object, "name", "state")) == "PD": matrix = cmd.get_object_matrix(Registry.get(self.attachment.main_object, "name")) self.reset() self.add_rotation([matrix[:3], matrix[4:7], matrix[8:11]]) self.add_translation([matrix[3], matrix[7], matrix[11]]) self.add_prerotational_translation(list(matrix[12:15])) except AttributeError: return
def defer(self): # defer compound and advance if self.object == None: print " Filter-Error: Please choose an object first" else: state = cmd.get_state() ident = cmd.get_title(self.object, state) print " Filter: Deferring '%s'" % ident self.check_object_dict() self.count(ident, defer_str) cmd.forward() cmd.refresh_wizard()
def get_prompt(self): # returns text prompt self.prompt = None if self.object == None: self.prompt = ["Please select a multi-state object..."] else: cnt = cmd.count_states(self.object) self.prompt = [ "%s: %d total, %d accepted, %d rejected, %d deferred, %d remaining" % (self.object, self.tota, self.acce, self.reje, self.defe, self.togo) ] state = cmd.get_state() ident = cmd.get_title(self.object, state) sdo = self.dict[self.object] if sdo.has_key(ident): self.prompt.append("%s: %s" % (ident, sdo[ident])) else: self.prompt.append("%s?" % (ident)) return self.prompt
def get_prompt(self): # returns text prompt self.prompt = None if self.object == None: self.prompt = ['Please select a multi-state object...'] else: cnt = cmd.count_states(self.object) self.prompt = [ '%s: %d total, %d accepted, %d rejected, %d deferred, %d remaining' % (self.object, self.tota, self.acce, self.reje, self.defe, self.togo) ] state = cmd.get_state() ident = cmd.get_title(self.object, state) sdo = self.dict[self.object] if sdo.has_key(ident): self.prompt.append('%s: %s' % (ident, sdo[ident])) else: self.prompt.append('%s?' % (ident)) return self.prompt
def test_set_title(self): text = 'foo' cmd.pseudoatom('m1') cmd.set_title('m1', 1, text) self.assertEqual(cmd.get_title('m1', 1), text)