https://pymolwiki.org/index.php?title=FilterByMol&feed=atom&action=history
FilterByMol - Revision history
2024-03-28T22:01:51Z
Revision history for this page on the wiki
MediaWiki 1.35.7
https://pymolwiki.org/index.php?title=FilterByMol&diff=7665&oldid=prev
Newacct at 08:13, 27 November 2009
2009-11-27T08:13:34Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 08:13, 27 November 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l40" >Line 40:</td>
<td colspan="2" class="diff-lineno">Line 40:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>from os import path</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>from os import path</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>from pymol import stored</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>from pymol import stored</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div><del style="font-weight: bold; text-decoration: none;">from string import zfill</del></div></td><td colspan="2"> </td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>theFiles = glob("../*.pdb");</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>theFiles = glob("../*.pdb");</div></td></tr>
<tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l61" >Line 61:</td>
<td colspan="2" class="diff-lineno">Line 60:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # prepare the output parameters</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> # prepare the output parameters</div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> curOut = path.basename(f).split(".")[0] + "_" + <del class="diffchange diffchange-inline">zfill(</del>str(mol_cnt)<del class="diffchange diffchange-inline">,</del>5) + "_het.pdb"</div></td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> curOut = path.basename(f).split(".")[0] + "_" + str(mol_cnt)<ins class="diffchange diffchange-inline">.zfill(</ins>5) + "_het.pdb"</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> curSel = "current"</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> curSel = "current"</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> </div></td></tr>
</table>
Newacct
https://pymolwiki.org/index.php?title=FilterByMol&diff=6357&oldid=prev
Inchoate at 12:39, 30 April 2009
2009-04-30T12:39:24Z
<p></p>
<table class="diff diff-contentalign-left diff-editfont-monospace" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="en">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">← Older revision</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">Revision as of 12:39, 30 April 2009</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l77" >Line 77:</td>
<td colspan="2" class="diff-lineno">Line 77:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Script_Library]]</div></td><td class='diff-marker'> </td><td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div>[[Category:Script_Library]]</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;">[[Category:System_Scripts]]</ins></div></td></tr>
</table>
Inchoate
https://pymolwiki.org/index.php?title=FilterByMol&diff=5661&oldid=prev
Inchoate: New page: == Overview == This script filters through all the PDBs in the parent dir (you can easily the the directory it scans). For each molecule, it saves '''just''' the ligands/heteroatoms (excl...
2008-11-10T20:31:54Z
<p>New page: == Overview == This script filters through all the PDBs in the parent dir (you can easily the the directory it scans). For each molecule, it saves '''just''' the ligands/heteroatoms (excl...</p>
<p><b>New page</b></p><div>== Overview ==<br />
This script filters through all the PDBs in the parent dir (you can easily the the directory it scans). For each molecule, it saves '''just''' the ligands/heteroatoms (excluding the waters). This gives you a simple way to filter through a database of proteins looking only at their ligands.<br />
<br />
This script, as noted below, works on the objects at the level of a '''molecule'''. While we can [[iterate]] over atom number (ID), residue number (resi), etc we do not have any such "MOLID". So, we provide this simple workaround. You might need this file because if you have a residue (like #111 from 3BEP) that consists of a molecule and an atom then there's no other way to save the separate pieces (of molecule/atom) into two (or more files). As you can see in the following listing, if we iterate over the hetero atoms (and not waters) in 3BEP we get,<br />
<source lang="python"><br />
PyMOL>iterate bymol het, print resi, resn, ID, chain, segi, alt<br />
111 5CY 6473 C <br />
111 5CY 6474 C <br />
111 5CY 6476 C <br />
111 5CY 6477 C <br />
111 5CY 6478 C <br />
111 5CY 6479 C <br />
111 5CY 6480 C <br />
111 5CY 6481 C <br />
111 5CY 6482 C <br />
111 5CY 6483 C <br />
111 5CY 6484 C <br />
111 5CY 6485 C <br />
111 5CY 6486 C <br />
111 5CY 6487 C <br />
111 5CY 6488 C <br />
111 5CY 6489 C <br />
111 5CY 6490 C <br />
</source><br />
which does not allow us to separate the two pieces.<br />
<br />
== The Code ==<br />
<source lang="python"><br />
python<br />
<br />
#<br />
# This simple script will filter through all PDBs in a directory, and for each one<br />
# save all the ligands/heterotoms (that aren't waters) to their own file. This<br />
# script operates at the level of molecules, not residues, atoms, etc. Thus, if<br />
# you have a ligand that PyMOL is treating as ONE residue, but is actually two<br />
# separate molecules, or a molecule and an atom, then you will get multiple files.<br />
#<br />
<br />
from glob import glob<br />
from os import path<br />
from pymol import stored<br />
from string import zfill<br />
<br />
theFiles = glob("../*.pdb");<br />
<br />
for f in theFiles:<br />
# load the file<br />
cmd.load(f);<br />
# remove the protein and waters<br />
cmd.remove("polymer or resn HOH");<br />
<br />
cmd.select("input", "all")<br />
cmd.select("processed", "none")<br />
mol_cnt = 0<br />
<br />
while cmd.count_atoms("input"):<br />
# filter through the selections, updating the lists<br />
cmd.select("current","bymolecule first input")<br />
cmd.select("processed","processed or current")<br />
cmd.select("input","input and not current")<br />
<br />
# prepare the output parameters<br />
curOut = path.basename(f).split(".")[0] + "_" + zfill(str(mol_cnt),5) + "_het.pdb"<br />
curSel = "current"<br />
<br />
# save the file<br />
cmd.save( curOut, curSel );<br />
print "Saved " + curSel + " to " + curOut<br />
<br />
mol_cnt = mol_cnt + 1;<br />
<br />
# remove all to move to next molecule<br />
cmd.delete("*"); <br />
<br />
python end<br />
</source><br />
<br />
[[Category:Script_Library]]</div>
Inchoate