From: <gre...@un...> - 2005-08-10 00:55:45
|
Same script, but with hydrogen bonds between nucleotides. Load the pdb file 127D, run the script and type =91DrawNT=92 in PyMol = command line=85 =20 =20 I have a question, maybe Warren you can answer: I wanted to use the set_color command to define a new color for the = Hydrogen bonds (MyRGBColor =3D [x,y,z] and then cmd.set_color(=93MyColor=94, = MyRGBColor)) And finally apply the created color to the Hydrogen bonds (cmd.distance('MyDistance', Selection1, Selection2) and then cmd.color("MyColor", "MyDistance")) The question is: how can I then delete the created MyColor object? I = tried the cmd.delete command, it does not generate an error but apparently the color is still defined=85 Any idea?! =20 =20 =20 Cheers, Greg =20 =20 =20 =20 from pymol import cmd from pymol.cgo import * from Numeric import * import sys,re =20 # COLOR SETTINGS: AColor=3D[0.2,1,0.2] TColor=3D[1,0.2,0.2] CColor=3D[0.3,0.3,1] GColor=3D[1,0.55,0.15] HColor=3D=94magenta=94 =20 def DrawNT(select=3D"all"): CurrentView =3D cmd.get_view(1) CurrentResi =3D 0 FirstRun =3D 1 NTPlate =3D [BEGIN,TRIANGLE_FAN] =20 # THYMINE BaseT =3D cmd.get_model("resn T") for atoms in BaseT.atom: if (CurrentResi !=3D atoms.resi): CurrentResi =3D atoms.resi if FirstRun =3D=3D 0: NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+TColor) else: NTPlate.extend([COLOR]+TColor) FirstRun =3D 0 if (atoms.name =3D=3D "N1") or (atoms.name =3D=3D "C2") or = (atoms.name =3D=3D "N3") or (atoms.name =3D=3D "C4") or (atoms.name =3D=3D "C5") or = (atoms.name =3D=3D "C6"): =20 NTPlate.extend([VERTEX] + atoms.coord) if atoms.name =3D=3D "N3": Sel1 =3D '%s/%s/%s/%s'%(atoms.segi,atoms.chain,atoms.resi,atoms.name) cmd.select('Sel2','%s around 3.1 and name N1 and not chain %s'%(Sel1,atoms.chain)) cmd.distance('Dst', Sel1, "Sel2") elif atoms.name =3D=3D "O4": Sel1 =3D '%s/%s/%s/%s'%(atoms.segi,atoms.chain,atoms.resi,atoms.name) cmd.select('Sel2','%s around 3.1 and name N6 and not chain %s'%(Sel1,atoms.chain)) cmd.distance('Dst', Sel1, "Sel2") # ADENINE BaseA =3D cmd.get_model("resn A") for atoms in BaseA.atom: if (CurrentResi !=3D atoms.resi): CurrentResi =3D atoms.resi if FirstRun =3D=3D 0: NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+AColor) else: NTPlate.extend([COLOR]+AColor) FirstRun =3D 0 if (atoms.name =3D=3D "N1") or (atoms.name =3D=3D "C2") or = (atoms.name =3D=3D "N3") or (atoms.name =3D=3D "C4") or (atoms.name =3D=3D "C5") or = (atoms.name =3D=3D "C6"): =20 NTPlate.extend([VERTEX] + atoms.coord) if (atoms.name =3D=3D "C4"): TmpC4 =3D atoms.coord elif (atoms.name =3D=3D "C5"): TmpC5 =3D atoms.coord elif (atoms.name =3D=3D "N7"): NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+AColor) NTPlate.extend([VERTEX] + TmpC4) NTPlate.extend([VERTEX] + TmpC5) NTPlate.extend([VERTEX] + atoms.coord) elif (atoms.name =3D=3D "C8") or (atoms.name =3D=3D "N9"): NTPlate.extend([VERTEX] + atoms.coord) =20 # CYTOSINE BaseC =3D cmd.get_model("resn C") for atoms in BaseC.atom: if (CurrentResi !=3D atoms.resi): CurrentResi =3D atoms.resi if FirstRun =3D=3D 0: NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+CColor) else: NTPlate.extend([COLOR]+CColor) FirstRun =3D 0 if (atoms.name =3D=3D "N1") or (atoms.name =3D=3D "C2") or = (atoms.name =3D=3D "N3") or (atoms.name =3D=3D "C4") or (atoms.name =3D=3D "C5") or = (atoms.name =3D=3D "C6"): =20 NTPlate.extend([VERTEX] + atoms.coord) if atoms.name =3D=3D "O2": Sel1 =3D '%s/%s/%s/%s'%(atoms.segi,atoms.chain,atoms.resi,atoms.name) cmd.select('Sel2','%s around 3.1 and name N2 and not chain %s'%(Sel1,atoms.chain)) cmd.distance('Dst', Sel1, "Sel2") elif atoms.name =3D=3D "N3": Sel1 =3D '%s/%s/%s/%s'%(atoms.segi,atoms.chain,atoms.resi,atoms.name) cmd.select('Sel2','%s around 3.1 and name N1 and not chain %s'%(Sel1,atoms.chain)) cmd.distance('Dst', Sel1, "Sel2") elif atoms.name =3D=3D "N4": Sel1 =3D '%s/%s/%s/%s'%(atoms.segi,atoms.chain,atoms.resi,atoms.name) cmd.select('Sel2','%s around 3.1 and name O6 and not chain %s'%(Sel1,atoms.chain)) cmd.distance('Dst', Sel1, "Sel2") =20 # GUANINE BaseG =3D cmd.get_model("resn G") for atoms in BaseG.atom: if (CurrentResi !=3D atoms.resi): CurrentResi =3D atoms.resi if FirstRun =3D=3D 0: NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+GColor) else: NTPlate.extend([COLOR]+GColor) FirstRun =3D 0 if (atoms.name =3D=3D "N1") or (atoms.name =3D=3D "C2") or = (atoms.name =3D=3D "N3") or (atoms.name =3D=3D "C4") or (atoms.name =3D=3D "C5") or = (atoms.name =3D=3D "C6"): NTPlate.extend([VERTEX] + atoms.coord) if (atoms.name =3D=3D "C4"): TmpC4 =3D atoms.coord elif (atoms.name =3D=3D "C5"): TmpC5 =3D atoms.coord elif (atoms.name =3D=3D "N7"): NTPlate.append(END) NTPlate.extend([BEGIN,TRIANGLE_FAN]) NTPlate.extend([COLOR]+GColor) NTPlate.extend([VERTEX] + TmpC4) NTPlate.extend([VERTEX] + TmpC5) NTPlate.extend([VERTEX] + atoms.coord) elif (atoms.name =3D=3D "C8") or (atoms.name =3D=3D "N9"): NTPlate.extend([VERTEX] + atoms.coord) NTPlate.append(END) cmd.load_cgo(NTPlate,"PLAIN_NT") cmd.select("chain1", "name C3*+C4*+C5*+O5*+P+O3*") cmd.show("cartoon", "chain1") cmd.cartoon("dumbbell", "chain1") cmd.set("cartoon_nucleic_acid_mode", 1, "chain1") cmd.delete("chain1") cmd.hide("label", "Dst") cmd.color(HColor, "Dst") cmd.delete("Sel2") cmd.set_view(CurrentView) cmd.extend("DrawNT",DrawNT) |