
Hi Artie, Here's some code to compute a dictionary mapping chain IDs to model identifiers: cid_to_spec = {} from chimerax.atomic import all_atomic_structures for s in all_atomic_structures(session): for chain in s.chains: cid_to_spec[chain.chain_id] = s.atomspec There is documentation for the chimerax.atomic module (along with several other modules) here: Python Modules — ChimeraX 1.9 documentation <https://www.cgl.ucsf.edu/chimerax/docs/devel/modules.html>. Also, aside from looking at the Python code that ships with ChimeraX (which is frequently a good learning approach), there are some ChimeraX "recipes" that provide example scripts for performing various tasks here: ChimeraX Recipes <https://rbvi.github.io/chimerax-recipes/>, which sometimes are useful for discovering how to code something similar. And don't hesitate to ask questions on this list either. :-) --Eric Eric Pettersen UCSF Computer Graphics Lab
On Jun 4, 2024, at 10:45 AM, Artie Kushner via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi there, hope you are all doing well
I'm wondering if anyone has a good idea of how to reproduce the output of the info command in the GUI inside a python script. Precisely the info command without any specifiers s.t. that all models and submodels are listed with minimal info. Like the following:
... #1.87, 4v6x Cu, shown 419 atoms, 421 bonds, 56 residues, 1 chains (Cu) #1.88, 4v6x Cv, shown 419 atoms, 421 bonds, 56 residues, 1 chains (Cv) #1.89, 4v6x Cz, shown 1741 atoms, 1769 bonds, 217 residues, 1 chains (Cz)
Perhaps there is a better way to do this, but my use case is splitting a bigger structure into multiple chains (as you can tell from above there are 89 chains in 4V6X). I'd like to be able to correlate chain IDs (ex. Cz) with the model identifiers (ex. #1.89) programmatically from within python to script against individual chains further. I'm sure there is more than one way to do it, but i haven't been able to find either so far.
Most that i found is the model_info command:
from chimerax.list_info.util import spec, model_info ... def test_func(session, structure: AtomicStructure): print(model_info(structure))<<<Missing or invalid "structure" argument: must specify 1 atomic structure, got 89 for "#1". def register_ribrepr_command(logger): from chimerax.core.commands import CmdDesc, register from chimerax.atomic import AtomicStructureArg, Chain, Residue, Atom
desc = CmdDesc( required = [("structure", AtomicStructureArg)], required_arguments = ["structure"], synopsis = "representation ", ) register("test_func", desc, test_func, logger=logger)
but it presupposes that I pass the model by spec I pass the "top-level" structure. It throws error saying that it contains 89 instead of 1 structures: Missing or invalid "structure" argument: must specify 1 atomic structure, got 89 for "#1".
Any other way of getting at the correspondence dict between chains/"submodels" created with i.e. `split chains` and their chain_id's (aka auth_asym_id 's) in Python space would work for me. Perhaps there is a way to list all objects in the "Models" section (picture below)?
Thanks in advance Artie
<image.png>
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/