<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Ricardo,<div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>Volume models also have an ‘openedAs’ attribute. For PDB files, if the first component of the openedAs attribute isn’t an existing file, and it’s exactly 4 characters long and the second component of the tuple is ‘PDB’, then it’s probably a fetched PDB file. For that case, use this code to try to get the path:</div><div class=""><br class=""></div><div class="">from chimera.fetch import FETCH_PREFERENCES, FETCH_DIRECTORY</div><div class="">import preferences</div><div class="">cache_dir = preferences.get(FETCH_PREFERENCES, FETCH_DIRECTORY)</div><div class="">id_code = openedAs[0].upper()</div><div class="">if cache_dir:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from OpenSave import tildeExpand</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>cache_dir = tildeExpand(cache_dir)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>from os.path import join, isfile</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>path = join(cache_dir, ‘PDB’, id_code + “.pdb”)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>if not isfile(path):</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span># PDB fetch falls back to mmCIF fetch, check for that</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>path = join(cache_dir, ‘PDB’, id_code + ‘.cif’)</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>if not isfile(path):</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>path = None</div><div class="">else:</div><div class=""><span class="Apple-tab-span" style="white-space:pre"> </span>path = None</div><div class=""><br class=""></div><div class="">—Eric</div><div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Apr 12, 2019, at 9:20 AM, Ricardo Avila <<a href="mailto:ravila@protonmail.com" class="">ravila@protonmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Thank you Eric.<br class=""></div><div class=""><br class=""></div><div class="">I was able to implement the feature I wanted for PDBs opened from a single file. I think it would be nice to be able to do it for fetched files too, so I would appreciate some help on that. I was also wondering if opened volumes have the same 'openedAs' attribute.<br class=""></div><div class=""><br class=""></div><div class="">Best,<br class=""></div><div class=""><br class=""></div><div class="">Ricardo<br class=""></div><div class=""><br class=""></div><div class="">‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐<br class=""></div><div class=""> On Thursday, April 11, 2019 2:49 PM, Eric Pettersen <<a href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>> wrote:<br class=""></div><div class=""> <br class=""></div><blockquote class="protonmail_quote" type="cite"><div class="">Hi Ricardo,<br class=""></div><div class=""><span style="white-space:pre" class=""></span>Every opened model in Chimera has an ‘openedAs’ attribute which is either None or a 4-tuple. For models that were directly opened from a single file on the file system (rather than fetched to a file for instance), openedAs will be a tuple whose first component is the full path to that file. If you need more that that (<i class="">e.g.</i><span class="" style="font-style: normal;"> fetched files too, which is more complicated), let me know and I can provide those details.</span><br class=""></div><div class=""><br class=""></div><div class="">—Eric<br class=""></div><div class=""><div class=""><br class=""></div><div class=""><div class="" style="letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div class=""><span style="white-space: pre;" class=""></span>Eric Pettersen<br class=""></div><div class=""><span style="white-space: pre;" class=""></span>UCSF Computer Graphics Lab<br class=""></div></div></div><div class=""><div class=""><br class=""></div><blockquote class="" type="cite"><div class="">On Apr 10, 2019, at 12:49 PM, Ricardo Avila <<a class="" href="mailto:ravila@protonmail.com">ravila@protonmail.com</a>> wrote:<br class=""></div><div class=""><br class=""></div><div class=""><div class="">Hi,<br class=""></div><div class=""><br class=""></div><div class="">I am trying to write an extension for a tool that requires PDB files or MRC structures as input. I would like to be able to pass the model or volume that is currently loaded in Chimera to this separate executable, but for this I need to get the file path to the model's object. Is this possible to do from the Python API?<br class=""></div><div class=""><br class=""></div><div class="">Thanks in advance,<br class=""></div><div class=""><br class=""></div><div class="">Ricardo Avila<br class=""></div><div class="">_______________________________________________<br class=""></div><div class="">Chimera-users mailing list: <a class="" href="mailto:Chimera-users@cgl.ucsf.edu">Chimera-users@cgl.ucsf.edu</a><br class=""></div><div class="">Manage subscription: <a class="" href="http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users">http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br class=""></div></div></blockquote></div></div></blockquote><div class=""><br class=""></div>_______________________________________________<br class="">Chimera-users mailing list: <a href="mailto:Chimera-users@cgl.ucsf.edu" class="">Chimera-users@cgl.ucsf.edu</a><br class="">Manage subscription: <a href="http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users" class="">http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users</a><br class=""></div></blockquote></div><br class=""></div></body></html>