Skip to content

Bio.PDB.Dice fails with PDBs including icodes #1053

Closed

Description

@he-leon

Hi!

Using Bio.PDB.Dice.extract with PDB structures including insertion codes results in a TypeError when a warning should be printed:

/usr/lib/python2.7/site-packages/Bio/PDB/Dice.py in accept_residue(self, residue)
     44         if icode != " ":
---> 45             warnings.warn("WARNING: Icode at %s" % residue.get_id(),
     46                           RuntimeWarning)
     47         if self.start <= resseq <= self.end:

TypeError: not all arguments converted during string formatting

Script to reproduce the error:

import Bio.PDB
import urllib2
pdbid = "5AB3" #includes insertion codes 
parser = Bio.PDB.PDBParser()
url_handle = urllib2.urlopen("https://files.rcsb.org/view/%s.pdb" % pdbid) 
struct = parser.get_structure(pdbid, url_handle)
url_handle.close()
Bio.PDB.Dice.extract(struct, "A", 60, 100, "5AB3_A_60_100.pdb")

Fix:
Add correct list index in Dice.py to print the warning correctly:

warnings.warn("WARNING: Icode at %s" % residue.get_id()[1],
                          RuntimeWarning)

Best
Leonhard

Activity

  1. peterjc commented on Feb 2, 2017

    @peterjc
    Member

    It might be more useful to report the full residue information, how about switching %s to %r to print the repr(...) instead?

    Would you like to submit this as a pull request?

  2. added a commit that references this issue on Oct 31, 2017
    2fa28cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions