pxmeter 0.1.2__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.
Files changed (37) hide show
  1. {pxmeter-0.1.2/pxmeter.egg-info → pxmeter-0.1.3}/PKG-INFO +1 -1
  2. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/calc_metric.py +11 -0
  3. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/configs/run_config.py +4 -0
  4. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/mapping.py +20 -7
  5. pxmeter-0.1.3/pxmeter/metrics/clashes.py +88 -0
  6. {pxmeter-0.1.2 → pxmeter-0.1.3/pxmeter.egg-info}/PKG-INFO +1 -1
  7. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter.egg-info/SOURCES.txt +1 -0
  8. {pxmeter-0.1.2 → pxmeter-0.1.3}/setup.py +1 -1
  9. {pxmeter-0.1.2 → pxmeter-0.1.3}/LICENSE +0 -0
  10. {pxmeter-0.1.2 → pxmeter-0.1.3}/MANIFEST.in +0 -0
  11. {pxmeter-0.1.2 → pxmeter-0.1.3}/README.md +0 -0
  12. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/__init__.py +0 -0
  13. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/cli.py +0 -0
  14. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/configs/__init__.py +0 -0
  15. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/configs/data_config.py +0 -0
  16. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/constants.py +0 -0
  17. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/__init__.py +0 -0
  18. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/ccd.py +0 -0
  19. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/parser.py +0 -0
  20. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/struct.py +0 -0
  21. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/utils.py +0 -0
  22. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/data/writer.py +0 -0
  23. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/eval.py +0 -0
  24. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/metrics/__init__.py +0 -0
  25. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/metrics/lddt_metrics.py +0 -0
  26. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/metrics/rmsd.py +0 -0
  27. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/metrics/rmsd_metrics.py +0 -0
  28. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/permutation/__init__.py +0 -0
  29. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/permutation/atom.py +0 -0
  30. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/permutation/chain.py +0 -0
  31. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter/utils.py +0 -0
  32. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter.egg-info/dependency_links.txt +0 -0
  33. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter.egg-info/entry_points.txt +0 -0
  34. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter.egg-info/requires.txt +0 -0
  35. {pxmeter-0.1.2 → pxmeter-0.1.3}/pxmeter.egg-info/top_level.txt +0 -0
  36. {pxmeter-0.1.2 → pxmeter-0.1.3}/requirements.txt +0 -0
  37. {pxmeter-0.1.2 → 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.2
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(
@@ -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
  )
@@ -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.2
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
@@ -26,6 +26,7 @@ pxmeter/data/struct.py
26
26
  pxmeter/data/utils.py
27
27
  pxmeter/data/writer.py
28
28
  pxmeter/metrics/__init__.py
29
+ pxmeter/metrics/clashes.py
29
30
  pxmeter/metrics/lddt_metrics.py
30
31
  pxmeter/metrics/rmsd.py
31
32
  pxmeter/metrics/rmsd_metrics.py
@@ -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.2",
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