Skip to content

Commit

Permalink
Allowing gnina to fail.
Browse files Browse the repository at this point in the history
  • Loading branch information
bieniekmateusz committed Jul 10, 2023
1 parent 2105f5f commit 162ace2
Showing 1 changed file with 18 additions and 27 deletions.
45 changes: 18 additions & 27 deletions fegrow/package.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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)
Expand Down

0 comments on commit 162ace2

Please sign in to comment.