Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-05-22T19:13:02.233Z
Answers.LastActivityDate: 2021-05-22T19:13:02.233Z
Answers.UserDisplayName: Nurlybek Amangeldiuly
Body: <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>
  
Tags: <python><protein-structure><pdb>
Title: How to index residues by icode in biopython?
ThreadText: # 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']
  
  ```
  
  
  ---
  
  