
Hi Ricardo, 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: from chimera.fetch import FETCH_PREFERENCES, FETCH_DIRECTORY import preferences cache_dir = preferences.get(FETCH_PREFERENCES, FETCH_DIRECTORY) id_code = openedAs[0].upper() if cache_dir: from OpenSave import tildeExpand cache_dir = tildeExpand(cache_dir) from os.path import join, isfile path = join(cache_dir, ‘PDB’, id_code + “.pdb”) if not isfile(path): # PDB fetch falls back to mmCIF fetch, check for that path = join(cache_dir, ‘PDB’, id_code + ‘.cif’) if not isfile(path): path = None else: path = None —Eric
On Apr 12, 2019, at 9:20 AM, Ricardo Avila <ravila@protonmail.com> wrote:
Thank you Eric.
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.
Best,
Ricardo
‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, April 11, 2019 2:49 PM, Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi Ricardo, 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 (e.g. fetched files too, which is more complicated), let me know and I can provide those details.
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Apr 10, 2019, at 12:49 PM, Ricardo Avila <ravila@protonmail.com <mailto:ravila@protonmail.com>> wrote:
Hi,
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?
Thanks in advance,
Ricardo Avila _______________________________________________ Chimera-users mailing list: Chimera-users@cgl.ucsf.edu <mailto:Chimera-users@cgl.ucsf.edu> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users <http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users>
_______________________________________________ Chimera-users mailing list: Chimera-users@cgl.ucsf.edu Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users