Skip to content

Commit

Permalink
Added detection of undefined atoms
Browse files Browse the repository at this point in the history
  • Loading branch information
jlgelpi committed Nov 29, 2023
1 parent 034fb4a commit e99a187
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion biobb_structure_checking/libs/residue_lib_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def get_atom_def(self, res_id, at_id):
""" Gets an atom definition given residue and atom names."""
resid_def = self.residues[res_id]
i = 1
while resid_def.ats[i].id != at_id and i < len(resid_def.ats):
while resid_def.ats[i].id != at_id and i < len(resid_def.ats) - 1:
i = i + 1
if resid_def.ats[i].id == at_id:
return resid_def.ats[i]
Expand Down
18 changes: 16 additions & 2 deletions biobb_structure_checking/structure_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ def update_atom_charges(self, force_field):
oxt_ok = rcode[0] != 'C' or len(rcode) != 4
res_chr = 0.
for atm in res.get_atoms():
atm.pqr_charge = self.res_library.get_atom_def(rcode, atm.id).chrg
atm_def = self.res_library.get_atom_def(rcode, atm.id)
if atm_def is None:
raise UnknownAtomforResidueError(mu.residue_id(res), atm.id)
atm.pqr_charge = atm_def.chrg
if atm.id in ff_data['residue_data'][can_rcode3]:
atm.xtra['atom_type'] = ff_data['residue_data'][can_rcode3][atm.id]
elif atm.id in ff_data['residue_data']['*'][ch_type_label]:
Expand Down Expand Up @@ -1760,28 +1763,39 @@ def _guess_modeller_env():
return 'KEY_MODELLER', 'MODINSTALL', 'modeller'
# ===============================================================================


class WrongServerError(Exception):
def __init__(self):
self.message = 'ERROR: Biounits supported only on MMB server'

class UnknownFileTypeError(Exception):
def __init__(self, typ):
self.message = f'ERROR: unknown filetype ({typ})'

class OutputPathNotProvidedError(Exception):
def __init__(self):
self.message = 'ERROR: output PDB path not provided'

class NotAValidResidueError(Exception):
def __init__(self, res):
self.message = f'Warning: {res} is not a valid residue in this context'

class NotEnoughAtomsError(Exception):
def __init__(self):
self.message = 'Warning: not enough backbone to build missing atoms'

class ParseError(Exception):
def __init__(self, err_id, err_txt):
self.message = f'{err_id} ({err_txt}) found when parsing input structure'

class UnknownFFError(Exception):
def __init__(self, ff):
self.message = f'{ff} is not a valid ff for assigning atom types'
self.message = f'{ff} is not a valid ff for assigning atom types and charges'

class SequencesDoNotMatch(Exception):
def __init__(self):
self.message = "Sequence lengths do not match"

class UnknownAtomforResidueError(Exception):
def __init__(self, res_id, atm_id):
self.message = f"Non valid atom {atm_id} for residue {res_id}"

0 comments on commit e99a187

Please sign in to comment.