From 4566cd67f9a6a641ee87985cc768be9ef631399b Mon Sep 17 00:00:00 2001 From: Matvey Adzhigirey Date: Tue, 4 Dec 2012 20:10:09 -0800 Subject: [PATCH] Fix a number of crashes and special conditions - Fix an issue where non-existing interactions were analyzed. Bug fix in setIonDeterminants(): skip interactions if either titratable_group_interaction_atoms or the backbone_interaction_atoms is empty. - Set center of COO_group to self.atom if no oxygens present in residue. COO_group: If self.atom.get_bonded_elements('O') returns an emtpy list (the residue has missing side-chain), simply set the center of the group to the atom, instead of the center of the (non-existing) oxygens. - Raise more friendly exception in Group.set_center() if an empty atom set is passed in. - Cterm_group: Fix crash if residue is missing a carbon. The previous code would crash if the C-termini residue group was missing the carbon atom. - Fix a failure when a HIS residue has missing side-chain atoms. - Added an entry for Iodine (I) to the valence electrons table. --- propka/determinants.py | 7 ++++++- propka/group.py | 39 +++++++++++++++++++++++++++++---------- propka/protonate.py | 4 +++- 3 files changed, 38 insertions(+), 12 deletions(-) diff --git a/propka/determinants.py b/propka/determinants.py index b3ed586..4299432 100644 --- a/propka/determinants.py +++ b/propka/determinants.py @@ -168,11 +168,16 @@ def setIonDeterminants(conformation_container, version): def setBackBoneDeterminants(titratable_groups, backbone_groups, version): for titratable_group in titratable_groups: + titratable_group_interaction_atoms = titratable_group.interaction_atoms_for_acids + if not titratable_group_interaction_atoms: + continue + # find out which backbone groups this titratable is interacting with for backbone_group in backbone_groups: # find the interacting atoms backbone_interaction_atoms = backbone_group.get_interaction_atoms(titratable_group) - titratable_group_interaction_atoms = titratable_group.interaction_atoms_for_acids + if not backbone_interaction_atoms: + continue # find the smallest distance [backbone_atom, distance, titratable_atom] = propka.calculations.get_smallest_distance(backbone_interaction_atoms, diff --git a/propka/group.py b/propka/group.py index ac52d3e..b5c5a06 100644 --- a/propka/group.py +++ b/propka/group.py @@ -420,6 +420,9 @@ class Group: return self.interaction_atoms_for_acids #default is acid interaction atoms - cf. 3.0 def set_center(self, atoms): + if not atoms: + raise ValueError("At least one atom must be specified") + # reset center self.x = 0.0; self.y = 0.0; self.z = 0.0 @@ -614,8 +617,14 @@ class COO_group(Group): # Identify the two caroxyl oxygen atoms the_oxygens = self.atom.get_bonded_elements('O') - # set the center using the two oxygen carboxyl atoms - self.set_center(the_oxygens) + # set the center using the two oxygen carboxyl atoms (if present) + if the_oxygens: + self.set_center(the_oxygens) + else: + self.set_center([self.atom]) + # FIXME perhaps it would be better to ignore this group completely + # if the oxygen is missing from this residue? + self.set_interaction_atoms(the_oxygens, the_oxygens) return @@ -636,7 +645,12 @@ class HIS_group(Group): my_protonator.protonate_atom(r) # set the center using the ring atoms - self.set_center(ring_atoms) + if ring_atoms: + self.set_center(ring_atoms) + else: + # Missing side-chain atoms + self.set_center([self.atom]) + # FIXME perhaps it would be better to ignore this group completely? # find the hydrogens on the ring-nitrogens hydrogens = [] @@ -751,14 +765,19 @@ class Cterm_group(Group): def setup_atoms(self): # Identify the carbon and other oxygen carboxyl atoms - the_carbon = self.atom.get_bonded_elements('C') - the_other_oxygen = the_carbon[0].get_bonded_elements('O') - the_other_oxygen.remove(self.atom) + the_carbons = self.atom.get_bonded_elements('C') + if not the_carbons: + self.set_center([self.atom]) + # FIXME perhaps it would be better to ignore this group completely + # if the carbon is missing from this residue? + else: + the_other_oxygen = the_carbons[0].get_bonded_elements('O') + the_other_oxygen.remove(self.atom) - # set the center and interaction atoms - the_oxygens = [self.atom]+ the_other_oxygen - self.set_center(the_oxygens) - self.set_interaction_atoms(the_oxygens, the_oxygens) + # set the center and interaction atoms + the_oxygens = [self.atom]+ the_other_oxygen + self.set_center(the_oxygens) + self.set_interaction_atoms(the_oxygens, the_oxygens) return diff --git a/propka/protonate.py b/propka/protonate.py index 396790b..34b8a01 100644 --- a/propka/protonate.py +++ b/propka/protonate.py @@ -47,7 +47,9 @@ class Protonate: 'As':5, 'Se':6, 'Br':7, - 'Kr':8} + 'Kr':8, + 'I':7, + }