Skip to content

Commit 212d7c7

Browse files
committed
better handling if mkdssp is not installed
1 parent b881335 commit 212d7c7

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

alphafold3_pytorch/alphafold3.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
import sh
34
from math import pi, sqrt
45
from pathlib import Path
56
from itertools import product
@@ -4083,6 +4084,14 @@ def __init__(
40834084

40844085
self.dssp_path = dssp_path
40854086

4087+
@property
4088+
def can_calculate_unresolved_protein_rasa(self):
4089+
try:
4090+
sh.which('mkdssp')
4091+
return True
4092+
except:
4093+
return False
4094+
40864095
@typecheck
40874096
def compute_gpde(
40884097
self,
@@ -4314,6 +4323,8 @@ def _compute_unresolved_rasa(
43144323
atom_mask: True for valid atom, False for missing/padding atom
43154324
"""
43164325

4326+
assert self.can_calculate_unresolved_protein_rasa, 'mkdssp needs to be installed'
4327+
43174328
residue_constants = get_residue_constants(res_chem_index=IS_PROTEIN)
43184329

43194330
device = atom_pos.device

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "alphafold3-pytorch"
3-
version = "0.2.100"
3+
version = "0.2.101"
44
description = "Alphafold 3 - Pytorch"
55
authors = [
66
{ name = "Phil Wang", email = "[email protected]" }
@@ -45,6 +45,7 @@ dependencies = [
4545
"pyyaml",
4646
"rdkit>=2023.9.6",
4747
"scikit-learn>=1.5.0",
48+
"sh>=2.0.7",
4849
"shortuuid",
4950
"taylor-series-linear-attention>=0.1.9",
5051
"timeout_decorator>=0.5.0",

tests/test_af3.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,13 +1106,6 @@ def test_model_selection_score():
11061106

11071107
def test_unresolved_protein_rasa():
11081108

1109-
# skip the test if dssp not installed
1110-
1111-
try:
1112-
subprocess.check_output(["which", "mkdssp"])
1113-
except:
1114-
pytest.skip("mkdssp not found, test_unresolved_protein_rasa skipped")
1115-
11161109
# rest of the test
11171110

11181111
mmcif_filepath = os.path.join('data', 'test', '7a4d-assembly1.cif')
@@ -1138,6 +1131,9 @@ def test_unresolved_protein_rasa():
11381131

11391132
compute_model_selection_score = ComputeModelSelectionScore()
11401133

1134+
if not compute_model_selection_score.can_calculate_unresolved_protein_rasa:
1135+
pytest.skip("mkdssp not available for calculating unresolved protein rasa")
1136+
11411137
unresolved_rasa = compute_model_selection_score.compute_unresolved_rasa(
11421138
unresolved_cid=[1],
11431139
unresolved_residue_mask=unresolved_residue_mask,

0 commit comments

Comments
 (0)