From ce48c704cf34c0ed45da04ec468bfc23c1ae6f9e Mon Sep 17 00:00:00 2001
From: Gabriel Studer <gabriel.studer@unibas.ch>
Date: Tue, 13 Sep 2022 14:46:38 +0200
Subject: [PATCH] lDDT: filter out hydrogens/deuterium in CustomCompound

---
 modules/mol/alg/pymod/lddt.py | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/modules/mol/alg/pymod/lddt.py b/modules/mol/alg/pymod/lddt.py
index f905cf416..77ce6690d 100644
--- a/modules/mol/alg/pymod/lddt.py
+++ b/modules/mol/alg/pymod/lddt.py
@@ -22,14 +22,15 @@ class CustomCompound:
     def FromResidue(res):
         """ Construct custom compound from residue
 
-        :param res: Residue from which reference atom names are extracted
+        :param res: Residue from which reference atom names are extracted,
+                    hydrogen/deuterium atoms are filtered out
         :type res: :class:`ost.mol.ResidueView`/:class:`ost.mol.ResidueHandle`
         :returns: :class:`CustomCompound`
         """
-        atom_names = [a.GetName() for a in res.atoms]
-        if len(atom_names) != len(set(atom_names)):
+        at_names = [a.name for a in res.atoms if a.element not in ["H", "D"]]
+        if len(at_names) != len(set(at_names)):
             raise RuntimeError("Duplicate atoms detected in CustomCompound")
-        compound = CustomCompound(atom_names)
+        compound = CustomCompound(at_names)
         return compound
 
 class SymmetrySettings:
-- 
GitLab