From 2427d5b220cc6ee0ee12e3d0e24fc0c782ebe919 Mon Sep 17 00:00:00 2001
From: Xavier Robin <xavalias-github@xavier.robin.name>
Date: Tue, 2 May 2023 15:16:19 +0200
Subject: [PATCH] fix: remove H with selection rather than Molck

This makes the ligand scoring script more independent of an up-to-date
compound library, which is a strong requirement of Molck.
This was a problem for the April 2023 Modeling Championship where the
script was run with an out of date library and the element of an atom of
the ligand was silently changed, preventing the symmetry correction to
find isomorphisms and resulting in the absence of scores.
---
 actions/ost-compare-ligand-structures | 25 +++++--------------------
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/actions/ost-compare-ligand-structures b/actions/ost-compare-ligand-structures
index ee7575218..abe20e849 100644
--- a/actions/ost-compare-ligand-structures
+++ b/actions/ost-compare-ligand-structures
@@ -60,8 +60,6 @@ import ost
 from ost import conop
 from ost import io
 from ost.mol.alg import ligand_scoring
-from ost.mol.alg import Molck, MolckSettings
-
 
 
 def _ParseArgs():
@@ -234,8 +232,6 @@ def _LoadStructure(structure_path, format="auto", fault_tolerant=False):
                             f"{structure_path}.")
         format = ext[-1].lower()
 
-    # increase loglevel, as we would pollute the info log with weird stuff
-    ost.PushVerbosityLevel(ost.LogLevel.Error)
     # Load the structure
     if format in ["mmcif", "cif"]:
         entity, seqres = io.LoadMMCIF(structure_path, seqres=True,
@@ -250,22 +246,11 @@ def _LoadStructure(structure_path, format="auto", fault_tolerant=False):
         raise Exception(f"Unknown/ unsupported file extension found for "
                         f"file {structure_path}.")
 
-    # Molck it
-    molck_settings = MolckSettings(rm_unk_atoms=True,
-                                   rm_non_std=False,
-                                   rm_hyd_atoms=True,
-                                   rm_oxt_atoms=False,
-                                   rm_zero_occ_atoms=False,
-                                   colored=False,
-                                   map_nonstd_res=False,
-                                   assign_elem=True)
-    # Cleanup a copy of the structures
-    Molck(entity, conop.GetDefaultLib(), molck_settings)
-    
-    # restore old loglevel and return
-    ost.PopVerbosityLevel()
-    entity.SetName(structure_path)
-    return entity
+    # Remove hydrogens
+    cleaned_entity = ost.mol.CreateEntityFromView(entity.Select("ele != H"),
+                                                  include_exlusive_atoms=False)
+    cleaned_entity.SetName(structure_path)
+    return cleaned_entity
 
 
 def _LoadLigands(ligands):
-- 
GitLab