From 2712b59f081b5c82e7b1a237e6b95f59e7b0d7eb Mon Sep 17 00:00:00 2001 From: Aviv Rosenberg Date: Sat, 15 Jun 2024 17:53:05 +0300 Subject: [PATCH 1/2] prec: Handle unknown residues in canonical sequence --- src/pp5/prec.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pp5/prec.py b/src/pp5/prec.py index 23a5a81..57efa63 100644 --- a/src/pp5/prec.py +++ b/src/pp5/prec.py @@ -906,7 +906,9 @@ def __init__( else: # This residue is not modelled (missing from the structure), need to add unmodelled_res_name_single = pdb_meta_aa_seq[curr_meta_seq_idx] - unmodelled_res_name = ACIDS_1TO3[unmodelled_res_name_single] + unmodelled_res_name = ACIDS_1TO3.get( + unmodelled_res_name_single, UNKNOWN_AA + ) unmodelled_count = 0 # number of consecutive unmodelled residues # We need to determine the residue sequence index for the missing @@ -946,7 +948,7 @@ def __init__( # Sanity check matching_aa_seq = str.join( - "", [ACIDS_3TO1[r.get_resname()] for r in matching_residues] + "", [ACIDS_3TO1.get(r.get_resname(), UNKNOWN_AA) for r in matching_residues] ) assert pdb_meta_aa_seq == matching_aa_seq From d11aed5cd8b38833676c301206d0109727b9602c Mon Sep 17 00:00:00 2001 From: Aviv Rosenberg Date: Sat, 15 Jun 2024 18:06:43 +0300 Subject: [PATCH 2/2] ResidueContacts: bugfix for residues without any in-chain contacts --- src/pp5/contacts.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/pp5/contacts.py b/src/pp5/contacts.py index e8eab6e..c21fe65 100644 --- a/src/pp5/contacts.py +++ b/src/pp5/contacts.py @@ -570,13 +570,12 @@ def _format(_contacts: Sequence[ResidueContact]) -> Sequence[str]: for _contact in _contacts ) - contact_smax = max( - [ - c.seq_dist - for c in contacts - if (c.seq_dist is not None and c.type == CONTACT_TYPE_AAA) - ] - ) + seq_dists = [ + c.seq_dist + for c in contacts + if (c.seq_dist is not None and c.type == CONTACT_TYPE_AAA) + ] + contact_smax = max(seq_dists) if seq_dists else 0 contact_ooc = _format([c for c in contacts if c.type == CONTACT_TYPE_OOC]) contact_non_aa = _format([c for c in contacts if c.type == CONTACT_TYPE_LIG]) contact_aas = _format([c for c in contacts if c.type == CONTACT_TYPE_AAA])