pxmeter 0.1.1__tar.gz → 0.1.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pxmeter-0.1.1/pxmeter.egg-info → pxmeter-0.1.3}/PKG-INFO +1 -1
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/calc_metric.py +11 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/cli.py +5 -2
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/configs/data_config.py +26 -8
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/configs/run_config.py +4 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/ccd.py +2 -15
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/mapping.py +20 -7
- pxmeter-0.1.3/pxmeter/metrics/clashes.py +88 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3/pxmeter.egg-info}/PKG-INFO +1 -1
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter.egg-info/SOURCES.txt +1 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/setup.py +1 -1
- {pxmeter-0.1.1 → pxmeter-0.1.3}/LICENSE +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/MANIFEST.in +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/README.md +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/__init__.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/configs/__init__.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/constants.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/__init__.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/parser.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/struct.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/utils.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/data/writer.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/eval.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/metrics/__init__.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/metrics/lddt_metrics.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/metrics/rmsd.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/metrics/rmsd_metrics.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/permutation/__init__.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/permutation/atom.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/permutation/chain.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter/utils.py +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter.egg-info/dependency_links.txt +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter.egg-info/entry_points.txt +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter.egg-info/requires.txt +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/pxmeter.egg-info/top_level.txt +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/requirements.txt +0 -0
- {pxmeter-0.1.1 → pxmeter-0.1.3}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pxmeter
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: PXMeter is a comprehensive toolkit for evaluating the quality of structures generated by biomolecular structure prediction models.
|
|
5
5
|
Author: Bytedance Inc.
|
|
6
6
|
Author-email: ai4s-bio@bytedance.com
|
|
@@ -34,6 +34,7 @@ from pxmeter.configs.run_config import RUN_CONFIG
|
|
|
34
34
|
from pxmeter.constants import IONS, LIGAND
|
|
35
35
|
from pxmeter.data.ccd import get_ccd_mol_from_chain_atom_array
|
|
36
36
|
from pxmeter.data.struct import Structure
|
|
37
|
+
from pxmeter.metrics.clashes import check_clashes_by_vdw
|
|
37
38
|
from pxmeter.metrics.lddt_metrics import LDDT
|
|
38
39
|
from pxmeter.metrics.rmsd_metrics import RMSDMetrics
|
|
39
40
|
|
|
@@ -554,6 +555,16 @@ class MetricResult:
|
|
|
554
555
|
meta_info_dict["ref_to_model_chain_mapping"] = chain_map
|
|
555
556
|
meta_info_dict["ref_chain_info"] = cls._get_chain_info(ref_struct)
|
|
556
557
|
|
|
558
|
+
# Calculate clashes
|
|
559
|
+
if metric_config.calc_clashes:
|
|
560
|
+
clashes = check_clashes_by_vdw(
|
|
561
|
+
model_struct.atom_array,
|
|
562
|
+
vdw_scale_factor=metric_config.clashes.vdw_scale_factor,
|
|
563
|
+
)
|
|
564
|
+
complex_result_dict["clashes"] = len(
|
|
565
|
+
{x for a, b in clashes for x in (a, b)}
|
|
566
|
+
)
|
|
567
|
+
|
|
557
568
|
# Calculate RMSD (if ligand and pocket specified in ref_features)
|
|
558
569
|
if metric_config.calc_rmsd and interested_lig_label_asym_id:
|
|
559
570
|
rmsd_metrics = RMSDMetrics(
|
|
@@ -18,9 +18,10 @@ from pathlib import Path
|
|
|
18
18
|
import click
|
|
19
19
|
|
|
20
20
|
from pxmeter.configs.data_config import (
|
|
21
|
+
CCD_BLOCKS_JSON,
|
|
21
22
|
COMPONENTS_FILE,
|
|
22
23
|
download_ccd_cif,
|
|
23
|
-
|
|
24
|
+
make_precomputed_json_from_ccd,
|
|
24
25
|
ONE_LETTER_CODE_JSON,
|
|
25
26
|
)
|
|
26
27
|
from pxmeter.eval import evaluate, MetricResult
|
|
@@ -176,4 +177,6 @@ def update():
|
|
|
176
177
|
Update the CCD database.
|
|
177
178
|
"""
|
|
178
179
|
download_ccd_cif(output_path=COMPONENTS_FILE.parent)
|
|
179
|
-
|
|
180
|
+
make_precomputed_json_from_ccd(
|
|
181
|
+
COMPONENTS_FILE, CCD_BLOCKS_JSON, ONE_LETTER_CODE_JSON
|
|
182
|
+
)
|
|
@@ -55,7 +55,9 @@ def download_ccd_cif(output_path: Path):
|
|
|
55
55
|
logging.info("Download CCD CIF file successfully: %s", output_cif)
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
def
|
|
58
|
+
def make_precomputed_json_from_ccd(
|
|
59
|
+
components_file: Path, ccd_blocks_json: Path, one_letter_code_json: Path
|
|
60
|
+
):
|
|
59
61
|
"""
|
|
60
62
|
Make a one-letter code JSON file from the CCD CIF file.
|
|
61
63
|
|
|
@@ -65,17 +67,23 @@ def make_one_letter_code_json_from_ccd(components_file: Path, output_json: Path)
|
|
|
65
67
|
ccd_cif = gemmi.cif.read(str(components_file))
|
|
66
68
|
|
|
67
69
|
ccd_code_to_one_letter_code = {}
|
|
70
|
+
ccd_code_to_block = {}
|
|
68
71
|
for block in ccd_cif:
|
|
69
72
|
ccd_code = block.find_value("_chem_comp.id")
|
|
70
73
|
one_letter_code = block.find_value("_chem_comp.one_letter_code")
|
|
74
|
+
ccd_code_to_block[ccd_code] = block.as_string()
|
|
71
75
|
if one_letter_code is None or one_letter_code == "?":
|
|
72
76
|
continue
|
|
73
77
|
ccd_code_to_one_letter_code[ccd_code] = one_letter_code
|
|
74
78
|
|
|
75
|
-
with open(
|
|
76
|
-
json.dump(
|
|
79
|
+
with open(ccd_blocks_json, "w") as f:
|
|
80
|
+
json.dump(ccd_code_to_block, f, indent=4)
|
|
81
|
+
|
|
82
|
+
logging.info("Make CCD_BLOCKS_JSON successfully: %s", ccd_blocks_json)
|
|
77
83
|
|
|
78
|
-
|
|
84
|
+
with open(one_letter_code_json, "w") as f:
|
|
85
|
+
json.dump(ccd_code_to_one_letter_code, f, indent=4)
|
|
86
|
+
logging.info("Make ONE_LETTER_CODE_JSON successfully: %s", one_letter_code_json)
|
|
79
87
|
|
|
80
88
|
|
|
81
89
|
# default is <repo_dir>/ccd_cache/components.cif Your path for components file
|
|
@@ -84,20 +92,30 @@ def make_one_letter_code_json_from_ccd(components_file: Path, output_json: Path)
|
|
|
84
92
|
repo_dir = Path(__file__).absolute().parent.parent.parent
|
|
85
93
|
ccd_file_in_repo = repo_dir / "ccd_cache" / "components.cif"
|
|
86
94
|
COMPONENTS_FILE = Path(os.environ.get("PXM_CCD_FILE", ccd_file_in_repo))
|
|
87
|
-
|
|
95
|
+
|
|
96
|
+
CCD_BLOCKS_JSON = COMPONENTS_FILE.with_suffix(".json")
|
|
97
|
+
ONE_LETTER_CODE_JSON = COMPONENTS_FILE.parent / "one_letter_code.json"
|
|
88
98
|
|
|
89
99
|
if not COMPONENTS_FILE.exists():
|
|
90
100
|
logging.debug(
|
|
91
101
|
"CCD CIF file not found. Downloading CCD CIF file to %s", COMPONENTS_FILE.parent
|
|
92
102
|
)
|
|
93
103
|
download_ccd_cif(output_path=COMPONENTS_FILE.parent)
|
|
94
|
-
|
|
104
|
+
make_precomputed_json_from_ccd(
|
|
105
|
+
COMPONENTS_FILE, CCD_BLOCKS_JSON, ONE_LETTER_CODE_JSON
|
|
106
|
+
)
|
|
95
107
|
else:
|
|
96
108
|
logging.debug("Load CCD CIF file from: %s", COMPONENTS_FILE)
|
|
97
109
|
|
|
98
|
-
if not ONE_LETTER_CODE_JSON.exists():
|
|
99
|
-
|
|
110
|
+
if not ONE_LETTER_CODE_JSON.exists() or not CCD_BLOCKS_JSON.exists():
|
|
111
|
+
make_precomputed_json_from_ccd(
|
|
112
|
+
COMPONENTS_FILE, CCD_BLOCKS_JSON, ONE_LETTER_CODE_JSON
|
|
113
|
+
)
|
|
100
114
|
|
|
101
115
|
logging.debug("Load CCD one-letter code from: %s", ONE_LETTER_CODE_JSON)
|
|
102
116
|
with open(ONE_LETTER_CODE_JSON, "r") as f:
|
|
103
117
|
CCD_ONE_LETTER_CODE = json.load(f)
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
with open(CCD_BLOCKS_JSON, "r") as f:
|
|
121
|
+
CCD_BLOCKS = json.load(f)
|
|
@@ -23,6 +23,7 @@ RUN_CONFIG = ConfigDict(
|
|
|
23
23
|
"enumerate_all_anchors": True,
|
|
24
24
|
},
|
|
25
25
|
"metric": {
|
|
26
|
+
"calc_clashes": True,
|
|
26
27
|
"calc_lddt": True,
|
|
27
28
|
"calc_dockq": True,
|
|
28
29
|
"calc_rmsd": True,
|
|
@@ -32,6 +33,9 @@ RUN_CONFIG = ConfigDict(
|
|
|
32
33
|
"nucleotide_threshold": 30.0,
|
|
33
34
|
"non_nucleotide_threshold": 15.0,
|
|
34
35
|
},
|
|
36
|
+
"clashes": {
|
|
37
|
+
"vdw_scale_factor": 0.5,
|
|
38
|
+
},
|
|
35
39
|
},
|
|
36
40
|
}
|
|
37
41
|
)
|
|
@@ -24,7 +24,7 @@ from pdbeccdutils.core import ccd_reader
|
|
|
24
24
|
from rdkit import Chem
|
|
25
25
|
from rdkit.Geometry import Point3D
|
|
26
26
|
|
|
27
|
-
from pxmeter.configs.data_config import
|
|
27
|
+
from pxmeter.configs.data_config import CCD_BLOCKS
|
|
28
28
|
from pxmeter.data.utils import (
|
|
29
29
|
get_inter_residue_bonds,
|
|
30
30
|
get_mol_graph_matches,
|
|
@@ -34,17 +34,6 @@ from pxmeter.data.utils import (
|
|
|
34
34
|
logging.getLogger("rdkit").setLevel(logging.ERROR)
|
|
35
35
|
|
|
36
36
|
|
|
37
|
-
@functools.lru_cache
|
|
38
|
-
def _gemmi_load_ccd_cif() -> gemmi.cif.Document:
|
|
39
|
-
"""
|
|
40
|
-
Load the CCD components file using the gemmi library.
|
|
41
|
-
|
|
42
|
-
Returns:
|
|
43
|
-
gemmi.cif.Document: gemmi ccd components file
|
|
44
|
-
"""
|
|
45
|
-
return gemmi.cif.read(str(COMPONENTS_FILE))
|
|
46
|
-
|
|
47
|
-
|
|
48
37
|
@functools.lru_cache
|
|
49
38
|
def get_ccd_mol_from_cif(ccd_code: str) -> Chem.Mol:
|
|
50
39
|
"""
|
|
@@ -57,10 +46,8 @@ def get_ccd_mol_from_cif(ccd_code: str) -> Chem.Mol:
|
|
|
57
46
|
mol (Chem.Mol): The RDKit molecule object corresponding to the given CCD code.
|
|
58
47
|
Returns None if the CCD code is not found.
|
|
59
48
|
"""
|
|
60
|
-
ccd_cif = _gemmi_load_ccd_cif()
|
|
61
|
-
|
|
62
49
|
try:
|
|
63
|
-
ccd_block =
|
|
50
|
+
ccd_block = gemmi.cif.read_string(CCD_BLOCKS[ccd_code])[0]
|
|
64
51
|
except KeyError:
|
|
65
52
|
return
|
|
66
53
|
ccd_reader_result = ccd_reader._parse_pdb_mmcif(ccd_block, sanitize=True)
|
|
@@ -924,15 +924,28 @@ class MappingCIF:
|
|
|
924
924
|
# This step will be change the res_id, res_name, atom_name in self.model_struct.atom_array
|
|
925
925
|
self._align_model_lig_atom_to_ref(self.model_struct, model_to_ref_atom_mapping)
|
|
926
926
|
|
|
927
|
+
# Re-order model struct by res_id for each chain
|
|
928
|
+
order = []
|
|
929
|
+
for chain_id in np.unique(self.model_struct.uni_chain_id):
|
|
930
|
+
chain_mask = np.where(self.model_struct.uni_chain_id == chain_id)[0]
|
|
931
|
+
# Remove unmapped ligands
|
|
932
|
+
valid_chain_mask = chain_mask[
|
|
933
|
+
~(
|
|
934
|
+
(
|
|
935
|
+
(self.model_struct.atom_array.res_name[chain_mask] == ".")
|
|
936
|
+
& (self.model_struct.atom_array.atom_name[chain_mask] == ".")
|
|
937
|
+
)
|
|
938
|
+
| (
|
|
939
|
+
self.model_struct.atom_array.res_id[chain_mask] < 0
|
|
940
|
+
) # -1 for unmapped residues
|
|
941
|
+
)
|
|
942
|
+
]
|
|
943
|
+
res_ids = self.model_struct.atom_array.res_id[valid_chain_mask]
|
|
944
|
+
order.extend(valid_chain_mask[np.argsort(res_ids)])
|
|
945
|
+
|
|
927
946
|
# Remove unmapped ligand of model and reset unique atom id
|
|
928
947
|
self.model_struct = self.model_struct.select_substructure(
|
|
929
|
-
|
|
930
|
-
(
|
|
931
|
-
(self.model_struct.atom_array.res_name == ".")
|
|
932
|
-
& (self.model_struct.atom_array.atom_name == ".")
|
|
933
|
-
)
|
|
934
|
-
| (self.model_struct.atom_array.res_id < 0) # -1 for unmapped residues
|
|
935
|
-
),
|
|
948
|
+
order,
|
|
936
949
|
reset_uni_id=True,
|
|
937
950
|
)
|
|
938
951
|
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Copyright 2025 ByteDance and/or its affiliates.
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from typing import Sequence
|
|
16
|
+
|
|
17
|
+
import numpy as np
|
|
18
|
+
from biotite.structure import AtomArray
|
|
19
|
+
from biotite.structure.info.radii import vdw_radius_single
|
|
20
|
+
from scipy.spatial import KDTree
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def check_clashes_by_vdw(
|
|
24
|
+
atom_array: AtomArray,
|
|
25
|
+
query_mask: Sequence[bool] = None,
|
|
26
|
+
vdw_scale_factor: float = 0.5,
|
|
27
|
+
) -> list[tuple[int, int]]:
|
|
28
|
+
"""
|
|
29
|
+
Check clashes between atoms in the given atom array.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
atom_array (AtomArray): The atom array to check for clashes.
|
|
33
|
+
query_mask (bool, optional): A boolean mask to select atoms to check for clashes.
|
|
34
|
+
If None, all atoms are checked.
|
|
35
|
+
vdw_scale_factor (float, optional): The scale factor to apply to the Van der Waals radii.
|
|
36
|
+
Defaults to 0.5.
|
|
37
|
+
|
|
38
|
+
Returns:
|
|
39
|
+
list[tuple[int, int]]: A list of tuples representing the indices of atoms that are in clash.
|
|
40
|
+
"""
|
|
41
|
+
if query_mask is None:
|
|
42
|
+
# query all atoms
|
|
43
|
+
query_mask = np.ones(len(atom_array), dtype=bool)
|
|
44
|
+
elif not np.any(query_mask):
|
|
45
|
+
# no query atoms, return empty list
|
|
46
|
+
return []
|
|
47
|
+
|
|
48
|
+
if query_mask is None:
|
|
49
|
+
query_mask = np.ones(len(atom_array), dtype=bool)
|
|
50
|
+
|
|
51
|
+
query_idx_in_ref = np.where(query_mask)[0]
|
|
52
|
+
|
|
53
|
+
vdw_radii = np.array([vdw_radius_single(e) for e in atom_array.element])
|
|
54
|
+
query_vdw_radii = vdw_radii[query_mask]
|
|
55
|
+
|
|
56
|
+
clashes = []
|
|
57
|
+
query_tree = KDTree(atom_array.coord)
|
|
58
|
+
for query_idx, nbs_idx in enumerate(
|
|
59
|
+
query_tree.query_ball_point(atom_array.coord[query_mask], r=3.0)
|
|
60
|
+
):
|
|
61
|
+
query_bonds, _query_bond_types = atom_array.bonds.get_bonds(
|
|
62
|
+
query_idx_in_ref[query_idx]
|
|
63
|
+
)
|
|
64
|
+
query_vdw = query_vdw_radii[query_idx]
|
|
65
|
+
if query_vdw is None:
|
|
66
|
+
# undefined vdw for elem, use 1.7 as "C"
|
|
67
|
+
query_vdw = vdw_radius_single("C")
|
|
68
|
+
|
|
69
|
+
for nb_idx in nbs_idx:
|
|
70
|
+
if query_idx_in_ref[query_idx] == nb_idx:
|
|
71
|
+
# clash with self
|
|
72
|
+
continue
|
|
73
|
+
|
|
74
|
+
if nb_idx in query_bonds:
|
|
75
|
+
# clash with bonded atoms
|
|
76
|
+
continue
|
|
77
|
+
|
|
78
|
+
nb_vdw = vdw_radii[nb_idx]
|
|
79
|
+
if nb_vdw is None:
|
|
80
|
+
# undefined vdw for elem, use 1.7 as "C"
|
|
81
|
+
nb_vdw = vdw_radius_single("C")
|
|
82
|
+
|
|
83
|
+
dist = np.linalg.norm(
|
|
84
|
+
atom_array.coord[query_mask][query_idx] - atom_array.coord[nb_idx]
|
|
85
|
+
)
|
|
86
|
+
if dist < vdw_scale_factor * (query_vdw + nb_vdw):
|
|
87
|
+
clashes.append((query_idx_in_ref[query_idx], nb_idx))
|
|
88
|
+
return clashes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pxmeter
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.3
|
|
4
4
|
Summary: PXMeter is a comprehensive toolkit for evaluating the quality of structures generated by biomolecular structure prediction models.
|
|
5
5
|
Author: Bytedance Inc.
|
|
6
6
|
Author-email: ai4s-bio@bytedance.com
|
|
@@ -20,7 +20,7 @@ with open("requirements.txt") as f:
|
|
|
20
20
|
setup(
|
|
21
21
|
name="pxmeter",
|
|
22
22
|
python_requires=">=3.11",
|
|
23
|
-
version="0.1.
|
|
23
|
+
version="0.1.3",
|
|
24
24
|
description="PXMeter is a comprehensive toolkit for evaluating the quality of \
|
|
25
25
|
structures generated by biomolecular structure prediction models.",
|
|
26
26
|
author="Bytedance Inc.",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|