https://pymolwiki.org/index.php?title=Find_symbol&feed=atom&action=historyFind symbol - Revision history2024-03-29T11:06:53ZRevision history for this page on the wikiMediaWiki 1.35.7https://pymolwiki.org/index.php?title=Find_symbol&diff=11434&oldid=prevInchoate: Created page with "= Overview = This script looks for the given symbol in a given module(s). This can be handy if you forgot which module something is in or just want to query for a substring in a..."2013-09-27T13:51:10Z<p>Created page with "= Overview = This script looks for the given symbol in a given module(s). This can be handy if you forgot which module something is in or just want to query for a substring in a..."</p>
<p><b>New page</b></p><div>= Overview =<br />
<br />
This script looks for the given symbol in a given module(s). This can be handy if you forgot which module something is in or just want to query for a substring in a set of modules.<br />
<br />
= Usage =<br />
<source lang="python"><br />
# search pymol and pymol.cmd for any symbol starting with 'mov'<br />
<br />
fs("mov")<br />
['cmd.get_movie_length',<br />
'cmd.get_movie_locked',<br />
'cmd.get_movie_playing',<br />
'cmd.mmove',<br />
'cmd.move',<br />
'cmd.movie',<br />
'cmd.moving',<br />
'cmd.remove',<br />
'cmd.remove_picked']<br />
<br />
# Search PyMOL's CMD module for something called align<br />
<br />
fs("align", "cmd")<br />
['cmd.align', 'cmd.alignto', 'cmd.cealign', 'cmd.get_raw_alignment']<br />
</source><br />
<br />
= The Code =<br />
<source lang="python"><br />
import pymol<br />
import inspect<br />
import pprint<br />
<br />
def fs(needle,haystack=["pymol","cmd"]):<br />
"""<br />
This script will find the 'needle' in the 'haystack,' where the former is<br />
a symbol to be found in the latter, which is a module.<br />
"""<br />
<br />
if type("") == type(haystack):<br />
<br />
haystack = [haystack,]<br />
<br />
for mod in haystack:<br />
<br />
found_list = map(lambda x: "%s.%s" % (mod,x), [name for name,obj in inspect.getmembers(eval(mod)) if needle in name])<br />
<br />
pprint.pprint(found_list)<br />
<br />
return found_list<br />
</source><br />
<br />
[[Category:System_Scripts]]<br />
[[Category:Script_Library]]</div>Inchoate