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@cgl.ucsf.edu> on behalf of Shubham Devesh Ramgoolam via ChimeraX-users <chimerax-users@cgl.ucsf.edu>
Sent: 15 May 2022 18:55
To: chimerax-users@cgl.ucsf.edu <chimerax-users@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 for Windows