def makeLegend(features): """ A function to display a legend for the features and their respective colors. @param features: A C{set} of feature names. @return: A C{list} of objects to be plotted. """ cgo = [] colors = [[0.5, 1.0, 1.0], [1.0, 0.7, 0.2], [0.73, 0.55, 0.52], [1.0, 0.5, 0.5], [0.6, 0.6, 0.1], [0.1, 0.6, 0.6], [0.698, 0.13, 0.13], [0.25, 1.00, 0.75], [0.75, 0.75, 1.0], [0.75, 1.00, 0.25], [0.0, 0.5, 1.0], [1.0, 0.5, 0.0], [0.65, 0.9, 0.65], [1.0, 0.3, 0.3], [0.2, 1.0, 0.2], [1.0, 0.2, 0.2], [0.55, 0.25, 0.60], [0.85, 0.20, 0.50], [0.619607843, 0.388235294, 0.709803922], [0.341176471, 0.090196078, 0.560784314], [1.0, 0.819607843, 0.137254902], [0.2, 0.6, 0.2], [0.5, 0.5, 1.0], [0.3, 0.3, 1.0], [1.0, 0.5, 1.0], [0.819607843, 0.0, 0.309803922], [0.090196078, 0.329411765, 0.529411765], [1.0, 0.501960784, 0.0], [1.0, 0.0, 1.0], [1.0, 1.0, 0.0], [1.0, 1.0, 1.0]] axes = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]] textY = 0.0 sphereY = 1.0 spheres = [] for i, featureName in enumerate(features): wire_text(cgo, plain, [0.0, textY, 0.0], featureName[1], axes=axes) textY -= 3.0 spheres.extend([COLOR] + colors[i] + [SPHERE, -1.5, sphereY, 0.0, 1]) sphereY -= 3.0 cgo.extend(spheres) return cgo
def reps(self, cleanup=0): rep_list = [ "lines", "sticks", "spheres", "surface", "mesh", "dots", "ribbon", "cartoon" ] try: if not cleanup: self.cmd.disable() self.cmd.set("suspend_updates", 1, quiet=1) self.cmd.mset() self.cmd.set("movie_panel", 0) self.cmd.load("$PYMOL_DATA/demo/pept.pdb", "rep1") self.cmd.alter("rep1///1-5+8-13/", "ss='S'") self.cmd.cartoon("auto") self.cmd.hide("everything", "rep1") for a in range(2, 9): self.cmd.create("rep%d" % a, "rep1") for y, x in enumerate(rep_list, 1): self.cmd.show(x, "rep%d" % y) self.cmd.reset() self.cmd.zoom("rep1", 24) util.cbay("rep2", _self=self.cmd) util.cbac("rep3", _self=self.cmd) util.cbas("rep4", _self=self.cmd) util.cbab("rep5", _self=self.cmd) util.cbaw("rep6", _self=self.cmd) util.cbay("rep8", _self=self.cmd) self.cmd.set("suspend_updates", 0, quiet=1) scale = 0.5 for b in range(1, 20): self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.refresh() self.cmd.set("suspend_updates", 1, quiet=1) xt = -3.2 yt = 1.6 for a in range(1, 5): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 yt = -yt xt = -3.2 for a in range(5, 9): self.cmd.translate([xt * scale, yt * scale, 0], object="rep%d" % a, camera=0) xt = xt + 2 for a in range(1, 9): self.cmd.origin("rep%d" % a, object="rep%d" % a) self.cmd.mset("1") st = ' '.join("rotate angle=-3,object=rep%d,axis=%s;" % (x, 'yx'[x % 2]) for x in range(1, 9)) self.cmd.mdo(1, st) self.cmd.set("suspend_updates", 0, quiet=1) self.cmd.mplay() cgo = [] axes = [[4.5, 0.0, 0.0], [0.0, 3.0, 0.0], [0.0, 0.0, 3.0]] c = 1 for a in rep_list: ext = self.cmd.get_extent("rep%d" % c) pos = [(ext[0][0] + ext[1][0]) / 2, (ext[0][1] + ext[1][1]) / 2 + 14, (ext[0][2] + ext[1][2]) / 2] c = c + 1 pos[0] = pos[0] - (measure_text(plain, a, axes) / 2) wire_text(cgo, plain, pos, a, axes) self.cmd.set("cgo_line_width", 1.5) self.cmd.set("auto_zoom", 0) self.cmd.load_cgo(cgo, 'reps') self.cmd.set("auto_zoom", 1) else: self.cmd.delete("rep*") self.cmd.mset() self.cmd.mstop() self.cmd.set("movie_panel", 1) except: traceback.print_exc()
def reps(self,cleanup=0): rep_list = [ "lines","sticks","spheres","surface","mesh","dots","ribbon","cartoon" ] try: if not cleanup: self.cmd.disable() self.cmd.set("suspend_updates",1,quiet=1) self.cmd.mset() self.cmd.set("movie_panel", 0) self.cmd.load("$PYMOL_DATA/demo/pept.pdb","rep1") self.cmd.alter("rep1///1-5+8-13/","ss='S'") self.cmd.cartoon("auto") self.cmd.hide("everything","rep1") for a in range(2,9): self.cmd.create("rep%d"%a,"rep1") for y, x in enumerate(rep_list, 1): self.cmd.show(x, "rep%d" % y) self.cmd.reset() self.cmd.zoom("rep1",24) util.cbay("rep2",_self=self.cmd) util.cbac("rep3",_self=self.cmd) util.cbas("rep4",_self=self.cmd) util.cbab("rep5",_self=self.cmd) util.cbaw("rep6",_self=self.cmd) util.cbay("rep8",_self=self.cmd) self.cmd.set("suspend_updates",0,quiet=1) scale=0.5 for b in range(1,20): self.cmd.set("suspend_updates",0,quiet=1) self.cmd.refresh() self.cmd.set("suspend_updates",1,quiet=1) xt=-3.2 yt=1.6 for a in range(1,5): self.cmd.translate([xt*scale,yt*scale,0],object="rep%d"%a,camera=0) xt=xt+2 yt=-yt xt=-3.2 for a in range(5,9): self.cmd.translate([xt*scale,yt*scale,0],object="rep%d"%a,camera=0) xt=xt+2 for a in range(1,9): self.cmd.origin("rep%d"%a,object="rep%d"%a) self.cmd.mset("1") st = ' '.join("rotate angle=-3,object=rep%d,axis=%s;" % (x, 'yx'[x % 2]) for x in range(1, 9)) self.cmd.mdo(1,st) self.cmd.set("suspend_updates",0,quiet=1) self.cmd.mplay() cgo = [] axes = [[4.5,0.0,0.0],[0.0,3.0,0.0],[0.0,0.0,3.0]] c = 1 for a in rep_list: ext = self.cmd.get_extent("rep%d"%c) pos = [(ext[0][0]+ext[1][0])/2, (ext[0][1]+ext[1][1])/2+14, (ext[0][2]+ext[1][2])/2] c = c + 1 pos[0]=pos[0]-(measure_text(plain,a,axes)/2) wire_text(cgo,plain,pos,a,axes) self.cmd.set("cgo_line_width",1.5) self.cmd.set("auto_zoom",0) self.cmd.load_cgo(cgo,'reps') self.cmd.set("auto_zoom",1) else: self.cmd.delete("rep*") self.cmd.mset() self.cmd.mstop() self.cmd.set("movie_panel",1) except: traceback.print_exc()