gemmi-protools 0.1.6__py3-none-any.whl → 0.1.8__py3-none-any.whl
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.
Potentially problematic release.
This version of gemmi-protools might be problematic. Click here for more details.
- gemmi_protools/utils/fixer.py +37 -6
- {gemmi_protools-0.1.6.dist-info → gemmi_protools-0.1.8.dist-info}/METADATA +1 -1
- {gemmi_protools-0.1.6.dist-info → gemmi_protools-0.1.8.dist-info}/RECORD +6 -6
- {gemmi_protools-0.1.6.dist-info → gemmi_protools-0.1.8.dist-info}/WHEEL +1 -1
- {gemmi_protools-0.1.6.dist-info → gemmi_protools-0.1.8.dist-info}/licenses/LICENSE +0 -0
- {gemmi_protools-0.1.6.dist-info → gemmi_protools-0.1.8.dist-info}/top_level.txt +0 -0
gemmi_protools/utils/fixer.py
CHANGED
|
@@ -14,6 +14,7 @@ from typing import Union, Optional
|
|
|
14
14
|
|
|
15
15
|
import pdbfixer
|
|
16
16
|
from openmm import app
|
|
17
|
+
import openmm
|
|
17
18
|
from typeguard import typechecked
|
|
18
19
|
|
|
19
20
|
from gemmi_protools.io.cif_opts import _is_cif
|
|
@@ -21,7 +22,21 @@ from gemmi_protools.io.pdb_opts import _is_pdb
|
|
|
21
22
|
|
|
22
23
|
|
|
23
24
|
@typechecked
|
|
24
|
-
def _load_by_pbdfixer(path: Union[str, pathlib.Path]) -> pdbfixer.PDBFixer:
|
|
25
|
+
def _load_by_pbdfixer(path: Union[str, pathlib.Path], use_platform=True) -> pdbfixer.PDBFixer:
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
path:
|
|
30
|
+
use_platform: default True, if False, auto select platform
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
|
|
34
|
+
"""
|
|
35
|
+
if use_platform:
|
|
36
|
+
platform = openmm.Platform.getPlatformByName('CPU')
|
|
37
|
+
else:
|
|
38
|
+
platform = None
|
|
39
|
+
|
|
25
40
|
cur_path = pathlib.Path(path)
|
|
26
41
|
if _is_pdb(path) or _is_cif(path):
|
|
27
42
|
s1 = cur_path.suffixes[-1]
|
|
@@ -29,15 +44,15 @@ def _load_by_pbdfixer(path: Union[str, pathlib.Path]) -> pdbfixer.PDBFixer:
|
|
|
29
44
|
|
|
30
45
|
if s1 in [".pdb", ".cif"]:
|
|
31
46
|
# s1 suffix
|
|
32
|
-
fixer = pdbfixer.PDBFixer(filename=path)
|
|
47
|
+
fixer = pdbfixer.PDBFixer(filename=path, platform=platform)
|
|
33
48
|
else:
|
|
34
49
|
# s2 suffix
|
|
35
50
|
with gzip.open(path, "rb") as gz_handle:
|
|
36
51
|
with io.TextIOWrapper(gz_handle, encoding="utf-8") as text_io:
|
|
37
52
|
if s2 == ".pdb.gz":
|
|
38
|
-
fixer = pdbfixer.PDBFixer(pdbfile=text_io)
|
|
53
|
+
fixer = pdbfixer.PDBFixer(pdbfile=text_io, platform=platform)
|
|
39
54
|
else:
|
|
40
|
-
fixer = pdbfixer.PDBFixer(pdbxfile=text_io)
|
|
55
|
+
fixer = pdbfixer.PDBFixer(pdbxfile=text_io, platform=platform)
|
|
41
56
|
else:
|
|
42
57
|
raise ValueError("Only support .cif, .cif.gz, .pdb or .pdb.gz file, but got %s" % path)
|
|
43
58
|
return fixer
|
|
@@ -50,7 +65,10 @@ def clean_structure(input_file: Union[str, pathlib.Path],
|
|
|
50
65
|
add_missing_atoms: str = "heavy",
|
|
51
66
|
keep_heterogens: str = "all",
|
|
52
67
|
replace_nonstandard: bool = True,
|
|
53
|
-
ph: Union[float, int] = 7.0
|
|
68
|
+
ph: Union[float, int] = 7.0,
|
|
69
|
+
check_mode: bool = True,
|
|
70
|
+
threshold: float = 0.3,
|
|
71
|
+
use_platform=True
|
|
54
72
|
):
|
|
55
73
|
"""
|
|
56
74
|
|
|
@@ -69,6 +87,10 @@ def clean_structure(input_file: Union[str, pathlib.Path],
|
|
|
69
87
|
none: remove all heterogens
|
|
70
88
|
:param replace_nonstandard: default True, replace all non-standard residues to standard ones
|
|
71
89
|
:param ph: default 7.0, ph values to add missing hydrogen atoms
|
|
90
|
+
:param check_mode: default True to check the ratio of residues with missing atoms
|
|
91
|
+
:param threshold: float, default 0.3, only use when check_mode=True
|
|
92
|
+
:param use_platform: default True to use CPU platform, if False, auto select platform
|
|
93
|
+
|
|
72
94
|
:return:
|
|
73
95
|
str, status message of fixing
|
|
74
96
|
if successful, return Finish, otherwise message of error
|
|
@@ -80,7 +102,16 @@ def clean_structure(input_file: Union[str, pathlib.Path],
|
|
|
80
102
|
######################################################
|
|
81
103
|
# load structure
|
|
82
104
|
######################################################
|
|
83
|
-
fixer = _load_by_pbdfixer(input_file)
|
|
105
|
+
fixer = _load_by_pbdfixer(input_file, use_platform=use_platform)
|
|
106
|
+
|
|
107
|
+
######################################################
|
|
108
|
+
# check
|
|
109
|
+
######################################################
|
|
110
|
+
fixer.findMissingResidues()
|
|
111
|
+
fixer.findMissingAtoms()
|
|
112
|
+
ratio = len(fixer.missingAtoms) / fixer.topology.getNumResidues()
|
|
113
|
+
if ratio > threshold:
|
|
114
|
+
return dict(input=input_file, msg="Too many residues with missing atoms: %.2f" % ratio)
|
|
84
115
|
|
|
85
116
|
######################################################
|
|
86
117
|
# replace non-standard residues
|
|
@@ -11,10 +11,10 @@ gemmi_protools/io/struct_info.py,sha256=9nBj1Zer03S8_Wks7L7uRlc9PlbfCKzoaT32pKR5
|
|
|
11
11
|
gemmi_protools/utils/__init__.py,sha256=F6e1xNT_7lZAWQgNIneH06o2qtWYrHNr_xPUPTwwx5E,29
|
|
12
12
|
gemmi_protools/utils/align.py,sha256=CZcrvjy-ZbX2u7OAn-YGblbxaj9YFUDX4CFZcpbpnB8,6959
|
|
13
13
|
gemmi_protools/utils/dockq.py,sha256=XmMwVEy-H4p6sH_HPcDWA3TP77OWdih0fE_BQJDr4pU,4189
|
|
14
|
-
gemmi_protools/utils/fixer.py,sha256=
|
|
14
|
+
gemmi_protools/utils/fixer.py,sha256=oiNtLCjQLFk4JHeO4exEkMH8QoEiKsJZIJRebkGGfBM,9545
|
|
15
15
|
gemmi_protools/utils/ppi.py,sha256=VWYsdxWwQoS1xwEYj5KB96Zz3F8r5Eyuw6NT3ReD-wc,2330
|
|
16
|
-
gemmi_protools-0.1.
|
|
17
|
-
gemmi_protools-0.1.
|
|
18
|
-
gemmi_protools-0.1.
|
|
19
|
-
gemmi_protools-0.1.
|
|
20
|
-
gemmi_protools-0.1.
|
|
16
|
+
gemmi_protools-0.1.8.dist-info/licenses/LICENSE,sha256=JuQvKcgj6n11y5y6nXr9rABv3gJSswc4eTCd5WZBtSY,1062
|
|
17
|
+
gemmi_protools-0.1.8.dist-info/METADATA,sha256=j0xy5aqbEvdlqoNrEdCSiBpmLVOpe3URit-85PBWa1s,567
|
|
18
|
+
gemmi_protools-0.1.8.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
19
|
+
gemmi_protools-0.1.8.dist-info/top_level.txt,sha256=P12mYJi5O5EKIn5u-RFaWxuix431CgLacSRD7rBid_U,15
|
|
20
|
+
gemmi_protools-0.1.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|