<p>Okay, I found the answer myself. It is possible to index not only by RES_NUM, but by its id (check with residue.get_id()), so the below example would work:</p>
<pre><code>#structure[0][RES_CHAIN][het, resseq, icode]
structure[0][RES_CHAIN][' ', 27, 'A']
</code></pre>

CC BY-SA 4.0
2021-05-22T19:13:02.233Z
2021-05-22T19:13:02.233Z
Nurlybek Amangeldiuly
<p>I am indexing a structure by the code below:</p>
<pre><code>PDB_CODE = '1lve'
RES_CHAIN = 'A'
RES_NUM = 27    

structure = PDBParser(is_pqr=True).get_structure(PDB_CODE, PDB_CODE+&quot;.pqr&quot;)
residue = structure[0][RES_CHAIN][RES_NUM]
</code></pre>
<p>However, the 1lve contains residues with the same RES_NUM but different icodes 'A' to 'F' so my code either ignores them or throws an error if I pass '27A'. Does biopython allow this kind of structure indexing directly?</p>

<python><protein-structure><pdb>
How to index residues by icode in biopython?
# How to index residues by icode in biopython?

(Asked by: username_0 on 2021-05-22)

I am indexing a structure by the code below:
PDB_CODE = '1lve'
RES_CHAIN = 'A'
RES_NUM = 27    

structure = PDBParser(is_pqr=True).get_structure(PDB_CODE, PDB_CODE+".pqr")
residue = structure[0][RES_CHAIN][RES_NUM]

However, the 1lve contains residues with the same RES_NUM but different icodes 'A' to 'F' so my code either ignores them or throws an error if I pass '27A'. Does biopython allow this kind of structure indexing directly?

**Tags:** python, protein-structure, pdb

---

## 1 answers

### Answer by username_0 on 2021-05-22. Score: 0 | Accepted answer

Okay, I found the answer myself. It is possible to index not only by RES_NUM, but by its id (check with residue.get_id()), so the below example would work:
#structure[0][RES_CHAIN][het, resseq, icode]
structure[0][RES_CHAIN][' ', 27, 'A']


---

