From 162ace202104925cab5f01f714e27ce153c47437 Mon Sep 17 00:00:00 2001 From: bieniekmat Date: Mon, 10 Jul 2023 13:26:59 +0100 Subject: [PATCH] Allowing gnina to fail. --- fegrow/package.py | 45 ++++++++++++++++++--------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/fegrow/package.py b/fegrow/package.py index 15f8a694..17a22d9d 100644 --- a/fegrow/package.py +++ b/fegrow/package.py @@ -1,19 +1,15 @@ import copy -import itertools import stat -from typing import Optional, List, Union, Tuple +from typing import Optional, List, Union import os import tempfile import subprocess import re from pathlib import Path from urllib.request import urlretrieve -from collections import OrderedDict import numpy as np -import matplotlib.pyplot as plt -from matplotlib.colors import to_hex -from prody.proteins.functions import showProtein, view3D +from prody.proteins.functions import view3D import py3Dmol import rdkit from rdkit import Chem @@ -512,7 +508,7 @@ def _check_download_gnina(): os.chmod(gnina, mode | stat.S_IEXEC) # check if it works - subprocess.run(["./gnina", "--help"], capture_output=True, cwd=RMol.gnina_dir) + subprocess.run(["./gnina", "--help"], capture_output=True, check=True, cwd=RMol.gnina_dir) def gnina(self, receptor_file): """ @@ -537,26 +533,21 @@ def gnina(self, receptor_file): w.write(self, confId=conformer.GetId()) # run the code on the sdf - try: - process = subprocess.run( - [ - "./gnina", - "--score_only", - "-l", - tmp.name, - "-r", - receptor.absolute(), - "--seed", - "0", - "--stripH", - "False", - ], - capture_output=True, - check=True, - cwd=RMol.gnina_dir, - ) - except subprocess.CalledProcessError as E: - raise Exception('Gnina Failed', process.stderr, E) + process = subprocess.run( + [ + RMol.gnina_dir / "gnina", + "--score_only", + "-l", + tmp.name, + "-r", + receptor, + "--seed", + "0", + "--stripH", + "False", + ], + capture_output=True, + check=True) output = process.stdout.decode("utf-8") CNNaffinities_str = re.findall(r"CNNaffinity: (-?\d+.\d+)", output)