https://wiki.pymol.org/api.php?action=feedcontributions&user=Gawells&feedformat=atom
PyMOL Wiki - User contributions [en]
2024-03-28T19:44:35Z
User contributions
MediaWiki 1.35.1
https://wiki.pymol.org/index.php?title=Grepsel&diff=8290
Grepsel
2005-11-28T08:05:42Z
<p>Gawells: A bit cleaner, fixed problems with non-greedy metacharacters</p>
<hr />
<div><source lang="python"><br />
#Create named selections using regular expressions for the protein sequence<br />
<br />
import pymol<br />
import re<br />
<br />
aa = { 'ASP' : 'D' , 'GLU' : 'E' , 'GLN' : 'Q' , 'ASN' : 'N' , 'SER' : 'S' ,<br />
'THR' : 'T' , 'CYS' : 'C' , 'HIS' : 'H' , 'ARG' : 'R' , 'LYS' : 'K' ,<br />
'MET' : 'M' , 'ALA' : 'A' , 'ILE' : 'I' , 'LEU' : 'L' , 'VAL' : 'V' ,<br />
'GLY' : 'G' , 'PRO' : 'P' , 'TRP' : 'W' , 'PHE' : 'F' , 'TYR' : 'Y' ,<br />
'SCY' : 'U' , 'ASX' : 'B' , 'GLX' : 'Z' , 'XXX' : 'X'}<br />
<br />
#made this before the sequence view option, probably another way to do it now<br />
<br />
def seqoneint(model):<br />
pymol.stored.seq = []<br />
cmd.iterate("%s and name ca"%model,"stored.seq.append(resn)")<br />
seq = ""<br />
for x in pymol.stored.seq:<br />
if aa.has_key(x):<br />
res = aa[x]<br />
seq = seq+res<br />
else:<br />
seq = seq + '-'<br />
return seq<br />
<br />
<br />
<br />
def grepsel(model="(all)",stretch="",prefix="",combined="0",single="1"):<br />
'''<br />
DESCRIPTION<br />
<br />
Create selections matching motifs, using python regular expression syntax.<br />
Motif is automatically converted to uppercase. Motif selections are labelled<br />
as "prefix_motif_###", where ### is the index for the first residue of the<br />
match. Prefix defaults to selection name. combined = 1 creates one selection<br />
for all occurences. single = 1 creates one selection for each occurance<br />
(the default).<br />
<br />
USAGE<br />
<br />
grepsel selection, motif, [prefix, [combined, [single ]]]<br />
<br />
EXAMPLES<br />
<br />
Create selections for all motifs matching "ESS" (selection_ESS_###,...):<br />
grepsel selection, ess<br />
<br />
Create selections for the PxGY motif with prefix m (m_P.CY_###,...):<br />
grepsel selection, p.gy, m<br />
'''<br />
<br />
if selection == "(all)":<br />
selection = "all"<br />
if prefix == "":<br />
prefix=selection<br />
<br />
stretch = stretch.upper() <br />
seq = seqoneint(selection)<br />
pymol.stored.resi = []<br />
pymol.stored.chain = []<br />
cmd.iterate("%s and name ca"%selection,"stored.resi.append(resi);stored.chain.append(chain)")<br />
motif = re.compile(stretch)<br />
occurrences = motif.finditer(seq)<br />
stretchmod = stretch.replace("+","\+")<br />
stretchmod = stretchmod.replace("?","\?")<br />
<br />
print stretchmod<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch), "none")<br />
<br />
<br />
for find in occurrences: <br />
<br />
mb = pymol.stored.resi[find.start()]<br />
me = pymol.stored.resi[find.end()-1]<br />
<br />
ch = pymol.stored.chain[find.start()]<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,me,ch), "chain %s and (i; %s-%s)"%(ch,int(mb),int(me)))<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch),"\"%s_%s\" | (%s and chain %s and (i; %s-%s))"%(prefix,stretchmod,selection,ch,int(mb),int(me)))<br />
<br />
cmd.select("none")<br />
cmd.delete("sel*")<br />
<br />
cmd.extend("grepsel",grepsel)<br />
</source><br />
<br />
<br />
[[Category:Script_Library|Grep selections]]</div>
Gawells
https://wiki.pymol.org/index.php?title=Grepsel&diff=8289
Grepsel
2005-11-28T08:01:39Z
<p>Gawells: </p>
<hr />
<div><source lang="python"><br />
#Create named selections using regular expressions for the protein sequence<br />
<br />
import pymol<br />
import re<br />
<br />
aa = { 'ASP' : 'D' , 'GLU' : 'E' , 'GLN' : 'Q' , 'ASN' : 'N' , 'SER' : 'S' ,<br />
'THR' : 'T' , 'CYS' : 'C' , 'HIS' : 'H' , 'ARG' : 'R' , 'LYS' : 'K' ,<br />
'MET' : 'M' , 'ALA' : 'A' , 'ILE' : 'I' , 'LEU' : 'L' , 'VAL' : 'V' ,<br />
'GLY' : 'G' , 'PRO' : 'P' , 'TRP' : 'W' , 'PHE' : 'F' , 'TYR' : 'Y' ,<br />
'SCY' : 'U' , 'ASX' : 'B' , 'GLX' : 'Z' , 'XXX' : 'X'}<br />
<br />
#made this before the sequence view option, probably another way to do it now<br />
<br />
def seqoneint(model):<br />
pymol.stored.seq = []<br />
cmd.iterate("%s and name ca"%model,"stored.seq.append(resn)")<br />
seq = ""<br />
for x in pymol.stored.seq:<br />
if aa.has_key(x):<br />
res = aa[x]<br />
seq = seq+res<br />
else:<br />
seq = seq + '-'<br />
return seq<br />
<br />
<br />
<br />
def grepsel(model="(all)",stretch="",prefix="",combined="0",single="1"):<br />
'''<br />
DESCRIPTION<br />
Create selections matching motifs, using python regular expression syntax.<br />
Motif is automatically converted to uppercase. Motif selections are labelled<br />
as "prefix_motif_###", where ### is the index for the first residue of the<br />
match. Prefix defaults to selection name. combined = 1 creates one selection<br />
for all occurences. single = 1 creates one selection for each occurance<br />
(the default).<br />
<br />
USAGE<br />
<br />
grepsel selection, expression, [prefix, [combined, [single ]]]<br />
<br />
EXAMPLES<br />
<br />
Make selections for all motifs matching "ESS" (model_ESS_###,...):<br />
grepsel model, ess<br />
<br />
Make selections for the PxGY motif with prefix m (m_P.CY_###,...):<br />
grepsel model, p.gy, m<br />
<br />
'''<br />
<br />
if selection == "(all)":<br />
selection = "all"<br />
if prefix == "":<br />
prefix=selection<br />
<br />
stretch = stretch.upper() <br />
seq = seqoneint(selection)<br />
pymol.stored.resi = []<br />
pymol.stored.chain = []<br />
cmd.iterate("%s and name ca"%selection,"stored.resi.append(resi);stored.chain.append(chain)")<br />
motif = re.compile(stretch)<br />
occurrences = motif.finditer(seq)<br />
stretchmod = stretch.replace("+","\+")<br />
stretchmod = stretchmod.replace("?","\?")<br />
<br />
print stretchmod<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch), "none")<br />
<br />
<br />
for find in occurrences: <br />
<br />
mb = pymol.stored.resi[find.start()]<br />
me = pymol.stored.resi[find.end()-1]<br />
<br />
ch = pymol.stored.chain[find.start()]<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,me,ch), "chain %s and (i; %s-%s)"%(ch,int(mb),int(me)))<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch),"\"%s_%s\" | (%s and chain %s and (i; %s-%s))"%(prefix,stretchmod,selection,ch,int(mb),int(me)))<br />
<br />
cmd.select("none")<br />
cmd.delete("sel*")<br />
<br />
cmd.extend("grepsel",grepsel)<br />
</source><br />
<br />
<br />
[[Category:Script_Library|Grep selections]]</div>
Gawells
https://wiki.pymol.org/index.php?title=Grepsel&diff=8288
Grepsel
2005-09-10T10:24:37Z
<p>Gawells: fixed selection from "chainless" models</p>
<hr />
<div><source lang="python"><br />
#Create named selections using regular expressions for the protein sequence<br />
<br />
import pymol<br />
import re<br />
<br />
aa = { 'ASP' : 'D' , 'GLU' : 'E' , 'GLN' : 'Q' , 'ASN' : 'N' , 'SER' : 'S' ,<br />
'THR' : 'T' , 'CYS' : 'C' , 'HIS' : 'H' , 'ARG' : 'R' , 'LYS' : 'K' ,<br />
'MET' : 'M' , 'ALA' : 'A' , 'ILE' : 'I' , 'LEU' : 'L' , 'VAL' : 'V' ,<br />
'GLY' : 'G' , 'PRO' : 'P' , 'TRP' : 'W' , 'PHE' : 'F' , 'TYR' : 'Y' ,<br />
'SCY' : 'U' , 'ASX' : 'B' , 'GLX' : 'Z' , 'XXX' : 'X'}<br />
<br />
#made this before the sequence view option, probably another way to do it now<br />
<br />
def seqoneint(model):<br />
pymol.stored.seq = []<br />
cmd.iterate("%s and name ca"%model,"stored.seq.append(resn)")<br />
seq = ""<br />
for x in pymol.stored.seq:<br />
if aa.has_key(x):<br />
res = aa[x]<br />
seq = seq+res<br />
else:<br />
seq = seq + '-'<br />
return seq<br />
<br />
<br />
<br />
def grepsel(model="(all)",stretch="",prefix="",combined="0",single="1"):<br />
'''<br />
DESCRIPTION<br />
<br />
Make selections matching regular expressions. Selections are labelled<br />
as "prefix_expression_###", where ### is the index for the first residue<br />
of the match. Prefix defaults to model name. combined = 1 creates one<br />
selection for all occurences. single = 1 creates one selection for each<br />
occurance (the default).<br />
<br />
USAGE<br />
<br />
grepsel selection, expression, [prefix, [combined, [single ]]]<br />
<br />
EXAMPLES<br />
<br />
Make selections for all motifs matching "ESS" (model_ESS_###,...):<br />
grepsel model, ess<br />
<br />
Make selections for the PxGY motif with prefix m (m_P.CY_###,...):<br />
grepsel model, p.gy, m<br />
<br />
'''<br />
<br />
<br />
if model == "(all)":<br />
model = "all"<br />
if prefix == "":<br />
prefix=model<br />
<br />
stretch = stretch.upper() <br />
seq = seqoneint(model)<br />
pymol.stored.resi = []<br />
pymol.stored.chain = []<br />
cmd.iterate("%s and name ca"%model,"stored.resi.append(resi);stored.chain.append(chain)")<br />
motif = re.compile(stretch)<br />
occurrences = motif.finditer(seq)<br />
if combined == "1":<br />
cmd.do("select %s_%s, none"%(prefix,stretch))<br />
<br />
for match in occurrences:<br />
fx = match.start()<br />
pos = 0<br />
for fy in range(int(fx),int(fx)+len(stretch)):<br />
ch = pymol.stored.chain[fy]<br />
ri = pymol.stored.resi[fy]<br />
if pos == 0:<br />
pos = ri<br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "none") <br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "%s_%s_%s%s | ///%s/%s/"%(prefix,stretch,pos,ch,ch,ri))<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch), "%s_%s | ////%s/"%(prefix,stretch,ri))<br />
cmd.select("none")<br />
cmd.delete("sel*")<br />
<br />
cmd.extend("grepsel",grepsel)<br />
</source><br />
<br />
<br />
[[Category:Script_Library|Grep selections]]</div>
Gawells
https://wiki.pymol.org/index.php?title=Category:Script_Library&diff=3869
Category:Script Library
2005-07-20T16:15:14Z
<p>Gawells: </p>
<hr />
<div>* [[Stereo_Ray]] -- This script will create two resolution specific ray traced images rotated appropriately for inclusion into a single file to represent a stereo view of the desired macromolecule.<br />
<br />
* [[Translate_And_Measure]] -- prints '''overlap''' if any of the atoms in molA or molB were within 4 Angstrom after translating by 1 along X<br />
<br />
* [[Show aromatics]] -- This script will display a backbone "worm" for your protein, with all of the sidechains for aromatic residues displayed as green "sticks". Usage: Save this as "show_aromatics.pml", load your protein in PyMOL, and run the script (select "Run" from the "File" menu). (PyMOL script; TStout)<br />
<br />
* [[Show hydrophobics]] -- This script will display a backbone "worm" for your protein, with all of the sidechains for hydrophobic residues displayed as orange "sticks". Usage: Same as "show aromatics". (PyMOL script; TStout)<br />
<br />
* [[Show charged]] -- This script will display a backbone "worm" for your protein, with all of the sidechains for charged residues displayed as red (negative) or blue (posititve) "sticks". Usage: Same as "show aromatics". (PyMOL script; TStout)<br />
<br />
* [[Show hydrophilic]] -- This script will display a backbone "worm" for your protein, with all of the sidechains for hydrophilic residues displayed as green "sticks". Usage: Same as "show aromatics". (PyMOL script; TStout)<br />
<br />
* [[Perp Maker]] -- Creates a perpendicular plane through the center of your protein with respect to the camera's current position. (If you translate the protein towards the camera a bit, you get a nice surface, sometimes.) A stupid little script I wrote in response to a request a few months ago (and it doesn't even conform to the request!) Load a protein, run the script (read the documentation in the script). (Jason Vertrees/[[User:Tree|Tree]])<br />
<br />
* [[Axes]] -- Creates a 3D-CGO object that shows the three coordinate axes.<br />
<br />
* [[CGO Text]] -- Creates a 3D-CGO text object.<br />
<br />
* [[List Selection]] -- Prints a list of all residues in a selection (both Python and .pml).<br />
<br />
* [[List Colors]] -- Lists the color of all residues in a selection (both Python and .pml).<br />
<br />
* [[List Secondary Structures]] -- Secondary structures (both predefined and those calculated with the 'dss' command) can be exported as a long string ('HHHHLLLLSSS').<br />
<br />
* [[Split Movement]] -- Moves two parts of one object into different directions.<br />
<br />
* [[Selection Exists]] -- Python method that returns true if a selection of a given name exists.<br />
<br />
* [[Get Coordinates I]] -- Retrieves atom coordinates as Python objects.<br />
<br />
* [[Get Coordinates II]] -- Retrieves atom coordinates as Python array (list object).<br />
<br />
* [[grepset]] -- List all settings matching a given keyword. - ''by EHP''<br />
<br />
* [[disconnect]] -- unbond a single atom from its neighbors. - ''by EHP''<br />
<br />
* [[mouse_modes]] -- customize the default mouse bindings for Viewing or Editing modes. - ''by EHP''<br />
<br />
* [[Measure Distance]] -- Measures the distance between two atoms (Python script).<br />
<br />
* [[Read PDB-String]] -- Parses a string in PDB format to a PyMOL object.<br />
<br />
* [[Color Objects]] -- Colors all objects differently (Python script).<br />
<br />
* [[Key Wait]] -- Process key events in a Python script.<br />
<br />
* [[Bounding Box]] -- Create a bounding box around a selection (Python script; requires numarray and Scientific; gilleain)<br />
<br />
* [[Ellipsoid]] -- Create callback object (opengl) ellipsoids. (Python script; gilleain)<br />
<br />
* [[pdbsurvey]] -- Surveys the pdb for recently added structures that are relevant to a user-specified keywords list (in a text file)<br />
<br />
* [[TransformSelectionByCameraView]] -- Transforms the selection by the camera view.<br />
<br />
* [[WFMesh]] -- Imports wavefront object mesh files; Starwars as an example!<br />
<br />
* [[grepsel]] -- Make named selections using regular expressions (protein sequence).<br />
<br />
[[Category:Scripting|Script Library]]</div>
Gawells
https://wiki.pymol.org/index.php?title=Grepsel&diff=8287
Grepsel
2005-07-20T16:11:33Z
<p>Gawells: </p>
<hr />
<div><source lang="python"><br />
#Create named selections using regular expressions for the protein sequence<br />
<br />
import pymol<br />
import re<br />
<br />
aa = { 'ASP' : 'D' , 'GLU' : 'E' , 'GLN' : 'Q' , 'ASN' : 'N' , 'SER' : 'S' ,<br />
'THR' : 'T' , 'CYS' : 'C' , 'HIS' : 'H' , 'ARG' : 'R' , 'LYS' : 'K' ,<br />
'MET' : 'M' , 'ALA' : 'A' , 'ILE' : 'I' , 'LEU' : 'L' , 'VAL' : 'V' ,<br />
'GLY' : 'G' , 'PRO' : 'P' , 'TRP' : 'W' , 'PHE' : 'F' , 'TYR' : 'Y' ,<br />
'SCY' : 'U' , 'ASX' : 'B' , 'GLX' : 'Z' , 'XXX' : 'X'}<br />
<br />
#made this before the sequence view option, probably another way to do it now<br />
<br />
def seqoneint(model):<br />
pymol.stored.seq = []<br />
cmd.iterate("%s and name ca"%model,"stored.seq.append(resn)")<br />
seq = ""<br />
for x in pymol.stored.seq:<br />
if aa.has_key(x):<br />
res = aa[x]<br />
seq = seq+res<br />
else:<br />
seq = seq + '-'<br />
return seq<br />
<br />
<br />
<br />
def grepsel(model="(all)",stretch="",prefix="",combined="0",single="1"):<br />
'''<br />
DESCRIPTION<br />
<br />
Make selections matching regular expressions. Selections are labelled<br />
as "prefix_expression_###", where ### is the index for the first residue<br />
of the match. Prefix defaults to model name. combined = 1 creates one<br />
selection for all occurences. single = 1 creates one selection for each<br />
occurance (the default).<br />
<br />
USAGE<br />
<br />
grepsel selection, expression, [prefix, [combined, [single ]]]<br />
<br />
EXAMPLES<br />
<br />
Make selections for all motifs matching "ESS" (model_ESS_###,...):<br />
grepsel model, ess<br />
<br />
Make selections for the PxGY motif with prefix m (m_P.CY_###,...):<br />
grepsel model, p.gy, m<br />
<br />
'''<br />
<br />
<br />
if model == "(all)":<br />
model = "all"<br />
if prefix == "":<br />
prefix=model<br />
<br />
stretch = stretch.upper() <br />
seq = seqoneint(model)<br />
pymol.stored.resi = []<br />
pymol.stored.chain = []<br />
cmd.iterate("%s and name ca"%model,"stored.resi.append(resi);stored.chain.append(chain)")<br />
motif = re.compile(stretch)<br />
occurrences = motif.finditer(seq)<br />
if combined == "1":<br />
cmd.do("select %s_%s, none"%(prefix,stretch))<br />
<br />
for match in occurrences:<br />
fx = match.start()<br />
pos = 0<br />
for fy in range(int(fx),int(fx)+len(stretch)):<br />
ch = pymol.stored.chain[fy]<br />
ri = pymol.stored.resi[fy]<br />
if pos == 0:<br />
pos = ri<br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "none") <br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "%s_%s_%s%s | %s/%s/"%(prefix,stretch,pos,ch,ch,ri))<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch), "%s_%s | %s//"%(prefix,stretch,ri))<br />
cmd.select("none")<br />
cmd.delete("sel*")<br />
<br />
cmd.extend("grepsel",grepsel)<br />
</source><br />
<br />
<br />
[[Category:Script_Library|Grep selections]]</div>
Gawells
https://wiki.pymol.org/index.php?title=Grepsel&diff=8286
Grepsel
2005-07-20T16:09:54Z
<p>Gawells: </p>
<hr />
<div><source lang="python"><br />
#Create named selections using regular expressions for the protein sequence<br />
<br />
import pymol<br />
import re<br />
<br />
aa = { 'ASP' : 'D' , 'GLU' : 'E' , 'GLN' : 'Q' , 'ASN' : 'N' , 'SER' : 'S' ,<br />
'THR' : 'T' , 'CYS' : 'C' , 'HIS' : 'H' , 'ARG' : 'R' , 'LYS' : 'K' ,<br />
'MET' : 'M' , 'ALA' : 'A' , 'ILE' : 'I' , 'LEU' : 'L' , 'VAL' : 'V' ,<br />
'GLY' : 'G' , 'PRO' : 'P' , 'TRP' : 'W' , 'PHE' : 'F' , 'TYR' : 'Y' ,<br />
'SCY' : 'U' , 'ASX' : 'B' , 'GLX' : 'Z' , 'XXX' : 'X'}<br />
<br />
#made this before the sequence view option, probably another way to do it now<br />
<br />
def seqoneint(model):<br />
pymol.stored.seq = []<br />
cmd.iterate("%s and name ca"%model,"stored.seq.append(resn)")<br />
seq = ""<br />
for x in pymol.stored.seq:<br />
if aa.has_key(x):<br />
res = aa[x]<br />
seq = seq+res<br />
else:<br />
seq = seq + '-'<br />
return seq<br />
<br />
<br />
<br />
def grepsel(model="(all)",stretch="",prefix="",combined="0",single="1"):<br />
'''<br />
DESCRIPTION<br />
<br />
Make selections matching regular expressions. Selections are labelled<br />
as "prefix_expression_###", where ### is the index for the first residue<br />
of the match. Prefix defaults to model name. combined = 1 creates one<br />
selection for all occurences. single = 1 creates one selection for each<br />
occurance (the default).<br />
<br />
USAGE<br />
<br />
grepsel selection, expression, [prefix, [combined, [single ]]]<br />
<br />
EXAMPLES<br />
<br />
Make selections for all motifs matching "ESS" (model_ESS_###,...):<br />
grepsel model, ess<br />
<br />
Make selections for the PxGY motif with prefix m (m_P.CY_###,...):<br />
grepsel model, p.gy, m<br />
<br />
'''<br />
<br />
<br />
if model == "(all)":<br />
model = "all"<br />
if prefix == "":<br />
prefix=model<br />
<br />
stretch = stretch.upper() <br />
seq = seqoneint(model)<br />
pymol.stored.resi = []<br />
pymol.stored.chain = []<br />
cmd.iterate("%s and name ca"%model,"stored.resi.append(resi);stored.chain.append(chain)")<br />
motif = re.compile(stretch)<br />
occurrences = motif.finditer(seq)<br />
if combined == "1":<br />
cmd.do("select %s_%s, none"%(prefix,stretch))<br />
<br />
for match in occurrences:<br />
fx = match.start()<br />
pos = 0<br />
for fy in range(int(fx),int(fx)+len(stretch)):<br />
ch = pymol.stored.chain[fy]<br />
ri = pymol.stored.resi[fy]<br />
if pos == 0:<br />
pos = ri<br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "none") <br />
if single == "1":<br />
cmd.select("%s_%s_%s%s"%(prefix,stretch,pos,ch), "%s_%s_%s%s | %s/%s/"%(prefix,stretch,pos,ch,ch,ri))<br />
if combined == "1":<br />
cmd.select("%s_%s"%(prefix,stretch), "%s_%s | %s//"%(prefix,stretch,ri))<br />
cmd.select("none")<br />
cmd.delete("sel*")<br />
<br />
cmd.extend("grepsel",grepsel)<br />
</source><br />
<br />
<br />
[[Category:Script_Library|grep selections]]</div>
Gawells