[chimerax-users] Python code for obtaining chain information

Tristan Croll tic20 at cam.ac.uk
Mon May 16 01:22:21 PDT 2022


Hi Shubham,

Assuming your model is already assigned to a variable, you shouldn't actually have to import any module for that task. If you don't have your model yet, you can do it in a few ways:

# If it's not already open
from chimerax.open_command.cmd import provider_open
m = provider_open(session, ['path/to/file.cif'])[0]

# If it's the only model open
from chimerax.atomic import AtomicStructure
m = session.models.list(type=AtomicStructure)[0]

If you have multiple models open, you'll need some slightly more involved code to work out which one is yours (e.g. based on model name). Anyway, moving on... once you have the model handle as m, then you can get the IDs of all polymeric chains as simply:

chain_ids = m.chains.chain_ids

If instead you want all​ chain_ids, including any used solely for ligands/water:

chain_ids = m.residues.unique_chain_ids

Best,
Tristan
________________________________
From: ChimeraX-users <chimerax-users-bounces at cgl.ucsf.edu> on behalf of Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users at cgl.ucsf.edu>
Sent: 15 May 2022 18:55
To: chimerax-users at cgl.ucsf.edu <chimerax-users at cgl.ucsf.edu>
Subject: [chimerax-users] Python code for obtaining chain information


Hi,

I hope you are doing well.

I have a python script in which I need generate a list of all the chains present in a structure: e.g [A,B]

However, I do not know which module to import in order to write a code for this.



Regards,

Shubham



Sent from Mail<https://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D550986&data=05%7C01%7Ctic20%40universityofcambridgecloud.onmicrosoft.com%7Cbbad1c776bec489e2b9208da369cf46e%7C49a50445bdfa4b79ade3547b4f3986e9%7C0%7C0%7C637882345470023062%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000%7C%7C%7C&sdata=ubrajKQcD5u9E5Aqu3RQJ7TqkDq5otEY4rRoLt9SMIU%3D&reserved=0> for Windows


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.rbvi.ucsf.edu/pipermail/chimerax-users/attachments/20220516/850589fa/attachment.html>


More information about the ChimeraX-users mailing list