prodigy-prot 2.3.0__py2.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.
@@ -0,0 +1,3 @@
1
+ from pathlib import Path
2
+
3
+ NACCESS_CONFIG = Path(Path(__file__).parents[0], "data/naccess.config")
prodigy_prot/cli.py ADDED
@@ -0,0 +1,127 @@
1
+ """
2
+ Binding affinity predictor based on Intermolecular Contacts (ICs).
3
+ """
4
+
5
+ import argparse
6
+ import logging
7
+ import sys
8
+ from argparse import RawTextHelpFormatter
9
+ from pathlib import Path
10
+
11
+ from Bio.PDB.Structure import Structure
12
+
13
+ from prodigy_prot.modules.parsers import (get_parser, parse_structure,
14
+ validate_structure)
15
+ from prodigy_prot.modules.prodigy import Prodigy
16
+
17
+ # setup logging
18
+ logging.basicConfig(level=logging.INFO, stream=sys.stdout, format="%(message)s")
19
+ log = logging.getLogger("Prodigy")
20
+
21
+
22
+ ap = argparse.ArgumentParser(description=__doc__, formatter_class=RawTextHelpFormatter)
23
+ ap.add_argument(
24
+ "input_path",
25
+ help="Path to either: \n- Structure in PDB or mmCIF format\n- Directory containing structure files",
26
+ )
27
+ ap.add_argument(
28
+ "--distance-cutoff",
29
+ type=float,
30
+ default=5.5,
31
+ help="Distance cutoff to calculate ICs",
32
+ )
33
+ ap.add_argument(
34
+ "--acc-threshold",
35
+ type=float,
36
+ default=0.05,
37
+ help="Accessibility threshold for BSA analysis",
38
+ )
39
+ ap.add_argument(
40
+ "--temperature",
41
+ type=float,
42
+ default=25.0,
43
+ help="Temperature (C) for Kd prediction",
44
+ )
45
+ ap.add_argument("--contact_list", action="store_true", help="Output a list of contacts")
46
+ ap.add_argument(
47
+ "--pymol_selection",
48
+ action="store_true",
49
+ help="Output a script to highlight the interface (pymol)",
50
+ )
51
+ ap.add_argument(
52
+ "-q",
53
+ "--quiet",
54
+ action="store_true",
55
+ help="Outputs only the predicted affinity value",
56
+ )
57
+ _co_help = """
58
+ By default, all intermolecular contacts are taken into consideration,
59
+ a molecule being defined as an isolated group of amino acids sharing
60
+ a common chain identifier. In specific cases, for example
61
+ antibody-antigen complexes, some chains should be considered as a
62
+ single molecule.
63
+
64
+ Use the --selection option to provide collections of chains that should
65
+ be considered for the calculation. Separate by a space the chains that
66
+ are to be considered _different_ molecules. Use commas to include multiple
67
+ chains as part of a single group:
68
+
69
+ --selection A B => Contacts calculated (only) between chains A and B.
70
+ --selection A,B C => Contacts calculated (only) between \
71
+ chains A and C; and B and C.
72
+ --selection A B C => Contacts calculated (only) between \
73
+ chains A and B; B and C; and A and C.
74
+ """
75
+ sel_opt = ap.add_argument_group("Selection Options", description=_co_help)
76
+ sel_opt.add_argument("--selection", nargs="+", metavar=("A B", "A,B C"))
77
+
78
+
79
+ def main():
80
+ args = ap.parse_args()
81
+ log.setLevel(logging.ERROR if args.quiet else logging.INFO)
82
+
83
+ struct_path = Path(args.input_path)
84
+
85
+ input_list = []
86
+ if struct_path.is_file():
87
+ input_list.append(struct_path)
88
+
89
+ elif struct_path.is_dir():
90
+ for input_f in struct_path.glob("*"):
91
+ if Path(input_f).suffix in [".pdb", ".cif", ".ent"]:
92
+ input_list.append(input_f)
93
+
94
+ elif not struct_path.exists():
95
+ log.error(f"File {struct_path} does not exist")
96
+ sys.exit(1)
97
+
98
+ else:
99
+ log.error(f"Input path {struct_path} is neither a valid file nor a directory")
100
+ sys.exit(1)
101
+
102
+ for input_f in input_list:
103
+ structure, n_chains, n_res = parse_structure(str(input_f))
104
+
105
+ if len(input_list) > 1:
106
+ log.info("#" * 42)
107
+
108
+ log.info(
109
+ "[+] Parsed structure file {0} ({1} chains, {2} residues)".format(
110
+ structure.id, n_chains, n_res
111
+ )
112
+ )
113
+ prodigy = Prodigy(structure, args.selection, args.temperature)
114
+ prodigy.predict(
115
+ distance_cutoff=args.distance_cutoff, acc_threshold=args.acc_threshold
116
+ )
117
+ prodigy.print_prediction(quiet=args.quiet)
118
+
119
+ if args.contact_list:
120
+ prodigy.print_contacts(outfile=str(struct_path.with_suffix(".ic")))
121
+
122
+ if args.pymol_selection:
123
+ prodigy.print_pymol_script(outfile=str(struct_path.with_suffix(".pml")))
124
+
125
+
126
+ if __name__ == "__main__":
127
+ sys.exit(main())
@@ -0,0 +1,256 @@
1
+ # Contributed by João Rodrigues
2
+
3
+ name: NACCESS
4
+
5
+ types:
6
+ C_ALI 1.87 apolar
7
+ C_CAR 1.76 apolar
8
+ C_NUC 1.80 apolar
9
+ N_AMN 1.50 polar
10
+ N_AMD 1.65 polar
11
+ N_NUC 1.60 polar
12
+ O 1.40 polar
13
+ S 1.85 apolar
14
+ SE 1.80 apolar
15
+ P 1.90 apolar
16
+
17
+ atoms:
18
+ ANY C C_CAR
19
+ ANY O O
20
+ ANY CA C_ALI
21
+ ANY N N_AMD
22
+ ANY CB C_ALI
23
+ ANY OXT O
24
+ # nucleic acid
25
+ ANY P P
26
+ ANY OP1 O
27
+ ANY OP2 O
28
+ ANY OP3 O
29
+ ANY O5' O
30
+ ANY O4' O
31
+ ANY O3' O
32
+ ANY O2' O
33
+ ANY C5' C_NUC
34
+ ANY C4' C_NUC
35
+ ANY C3' C_NUC
36
+ ANY C2' C_NUC
37
+ ANY C1' C_NUC
38
+
39
+ ALA CB C_ALI # included so that RSA values will be generated
40
+
41
+ ARG CG C_ALI
42
+ ARG CD C_ALI
43
+ ARG NE N_AMD
44
+ ARG CZ C_CAR
45
+ ARG NH1 N_AMD
46
+ ARG NH2 N_AMD
47
+
48
+ ASN CG C_CAR
49
+ ASN OD1 O
50
+ ASN ND2 N_AMD
51
+
52
+ ASP CG C_CAR
53
+ ASP OD1 O
54
+ ASP OD2 O
55
+
56
+ CYS SG S
57
+
58
+ GLN CG C_ALI
59
+ GLN CD C_CAR
60
+ GLN OE1 O
61
+ GLN NE2 N_AMD
62
+
63
+ GLU CG C_ALI
64
+ GLU CD C_CAR
65
+ GLU OE1 O
66
+ GLU OE2 O
67
+
68
+ GLY CA C_ALI # included so that RSA values will be generated
69
+
70
+ HIS CG C_CAR
71
+ HIS ND1 N_AMD
72
+ HIS CD2 C_CAR
73
+ HIS NE2 N_AMD
74
+ HIS CE1 C_CAR
75
+
76
+ ILE CG1 C_ALI
77
+ ILE CG2 C_ALI
78
+ ILE CD1 C_ALI
79
+
80
+ LEU CG C_ALI
81
+ LEU CD1 C_ALI
82
+ LEU CD2 C_ALI
83
+
84
+ LYS CG C_ALI
85
+ LYS CD C_ALI
86
+ LYS CE C_ALI
87
+ LYS NZ N_AMN
88
+
89
+ MET CG C_ALI
90
+ MET SD S
91
+ MET CE C_ALI
92
+
93
+ PHE CG C_CAR
94
+ PHE CD1 C_CAR
95
+ PHE CD2 C_CAR
96
+ PHE CE1 C_CAR
97
+ PHE CE2 C_CAR
98
+ PHE CZ C_CAR
99
+
100
+ PRO CG C_ALI
101
+ PRO CD C_ALI
102
+
103
+ SEC SE SE
104
+
105
+ SER OG O
106
+
107
+ THR OG1 O
108
+ THR CG2 C_ALI
109
+
110
+ TRP CG C_CAR
111
+ TRP CD1 C_CAR
112
+ TRP CD2 C_CAR
113
+ TRP NE1 N_AMD
114
+ TRP CE2 C_CAR
115
+ TRP CE3 C_CAR
116
+ TRP CZ2 C_CAR
117
+ TRP CZ3 C_CAR
118
+ TRP CH2 C_CAR
119
+
120
+ TYR CG C_CAR
121
+ TYR CD1 C_CAR
122
+ TYR CD2 C_CAR
123
+ TYR CE1 C_CAR
124
+ TYR CE2 C_CAR
125
+ TYR CZ C_CAR
126
+ TYR OH O
127
+
128
+ VAL CG1 C_ALI
129
+ VAL CG2 C_ALI
130
+
131
+ A N9 N_NUC
132
+ A C8 C_NUC
133
+ A N7 N_NUC
134
+ A C5 C_NUC
135
+ A C6 C_NUC
136
+ A N6 N_NUC
137
+ A N1 N_NUC
138
+ A C2 C_NUC
139
+ A N3 N_NUC
140
+ A C4 C_NUC
141
+
142
+ C N1 N_NUC
143
+ C C2 C_NUC
144
+ C O2 O
145
+ C N3 N_NUC
146
+ C C4 C_NUC
147
+ C N4 N_NUC
148
+ C C5 C_NUC
149
+ C C6 C_NUC
150
+
151
+ G N9 N_NUC
152
+ G C8 C_NUC
153
+ G N7 N_NUC
154
+ G C5 C_NUC
155
+ G C6 C_NUC
156
+ G O6 O
157
+ G N1 N_NUC
158
+ G C2 C_NUC
159
+ G N2 N_NUC
160
+ G N3 N_NUC
161
+ G C4 C_NUC
162
+
163
+ I N9 N_NUC
164
+ I C8 C_NUC
165
+ I N7 N_NUC
166
+ I C5 C_NUC
167
+ I C6 C_NUC
168
+ I O6 O
169
+ I N1 N_NUC
170
+ I C2 C_NUC
171
+ I N3 N_NUC
172
+ I C4 C_NUC
173
+
174
+ T N1 N_NUC
175
+ T C2 C_NUC
176
+ T O2 O
177
+ T N3 N_NUC
178
+ T C4 C_NUC
179
+ T O4 O
180
+ T C5 C_NUC
181
+ T C7 C_NUC
182
+ T C6 C_NUC
183
+
184
+ U N1 N_NUC
185
+ U C2 C_NUC
186
+ U O2 O
187
+ U N3 N_NUC
188
+ U C4 C_NUC
189
+ U O4 O
190
+ U C5 C_NUC
191
+ U C6 C_NUC
192
+
193
+ DA N9 N_NUC
194
+ DA C8 C_NUC
195
+ DA N7 N_NUC
196
+ DA C5 C_NUC
197
+ DA C6 C_NUC
198
+ DA N6 N_NUC
199
+ DA N1 N_NUC
200
+ DA C2 C_NUC
201
+ DA N3 N_NUC
202
+ DA C4 C_NUC
203
+
204
+ DC N1 N_NUC
205
+ DC C2 C_NUC
206
+ DC O2 O
207
+ DC N3 N_NUC
208
+ DC C4 C_NUC
209
+ DC N4 N_NUC
210
+ DC C5 C_NUC
211
+ DC C6 C_NUC
212
+
213
+ DG N9 N_NUC
214
+ DG C8 C_NUC
215
+ DG N7 N_NUC
216
+ DG C5 C_NUC
217
+ DG C6 C_NUC
218
+ DG O6 O
219
+ DG N1 N_NUC
220
+ DG C2 C_NUC
221
+ DG N2 N_NUC
222
+ DG N3 N_NUC
223
+ DG C4 C_NUC
224
+
225
+ DI N9 N_NUC
226
+ DI C8 C_NUC
227
+ DI N7 N_NUC
228
+ DI C5 C_NUC
229
+ DI C6 C_NUC
230
+ DI O6 O
231
+ DI N1 N_NUC
232
+ DI C2 C_NUC
233
+ DI N3 N_NUC
234
+ DI C4 C_NUC
235
+
236
+ DT N1 N_NUC
237
+ DT C2 C_NUC
238
+ DT O2 O
239
+ DT N3 N_NUC
240
+ DT C4 C_NUC
241
+ DT O4 O
242
+ DT C5 C_NUC
243
+ DT C7 C_NUC
244
+ DT C6 C_NUC
245
+
246
+ DU N1 N_NUC
247
+ DU C2 C_NUC
248
+ DU O2 O
249
+ DU N3 N_NUC
250
+ DU C4 C_NUC
251
+ DU O4 O
252
+ DU C5 C_NUC
253
+ DU C6 C_NUC
254
+
255
+
256
+
File without changes
@@ -0,0 +1,122 @@
1
+ """
2
+ Generic properties of amino acids required for the binding affinity
3
+ prediction methods.
4
+ """
5
+
6
+ aa_character_ic: dict[str, str] = {
7
+ "ALA": "A",
8
+ "CYS": "A", # ?
9
+ "GLU": "C",
10
+ "ASP": "C",
11
+ "GLY": "A",
12
+ "PHE": "A",
13
+ "ILE": "A",
14
+ "HIS": "C",
15
+ "LYS": "C",
16
+ "MET": "A",
17
+ "LEU": "A",
18
+ "ASN": "P",
19
+ "GLN": "P",
20
+ "PRO": "A",
21
+ "SER": "P",
22
+ "ARG": "C",
23
+ "THR": "P",
24
+ "TRP": "A",
25
+ "VAL": "A",
26
+ "TYR": "A",
27
+ }
28
+
29
+ aa_character_protorp: dict[str, str] = {
30
+ "ALA": "A",
31
+ "CYS": "P",
32
+ "GLU": "C",
33
+ "ASP": "C",
34
+ "GLY": "A",
35
+ "PHE": "A",
36
+ "ILE": "A",
37
+ "HIS": "P",
38
+ "LYS": "C",
39
+ "MET": "A",
40
+ "LEU": "A",
41
+ "ASN": "P",
42
+ "GLN": "P",
43
+ "PRO": "A",
44
+ "SER": "P",
45
+ "ARG": "C",
46
+ "THR": "P",
47
+ "TRP": "P",
48
+ "VAL": "A",
49
+ "TYR": "P",
50
+ }
51
+
52
+ # Scaling factors for relative ASA
53
+ # Calculated using extended ALA-X-ALA peptides
54
+ # Taken from NACCESS
55
+ rel_asa: dict[str, dict[str, float]] = {
56
+ "total": {
57
+ "ALA": 107.95,
58
+ "CYS": 134.28,
59
+ "ASP": 140.39,
60
+ "GLU": 172.25,
61
+ "PHE": 199.48,
62
+ "GLY": 80.10,
63
+ "HIS": 182.88,
64
+ "ILE": 175.12,
65
+ "LYS": 200.81,
66
+ "LEU": 178.63,
67
+ "MET": 194.15,
68
+ "ASN": 143.94,
69
+ "PRO": 136.13,
70
+ "GLN": 178.50,
71
+ "ARG": 238.76,
72
+ "SER": 116.50,
73
+ "THR": 139.27,
74
+ "VAL": 151.44,
75
+ "TRP": 249.36,
76
+ "TYR": 212.76,
77
+ },
78
+ "bb": {
79
+ "ALA": 38.54,
80
+ "CYS": 37.53,
81
+ "ASP": 37.70,
82
+ "GLU": 37.51,
83
+ "PHE": 35.37,
84
+ "GLY": 47.77,
85
+ "HIS": 35.80,
86
+ "ILE": 37.16,
87
+ "LYS": 37.51,
88
+ "LEU": 37.51,
89
+ "MET": 37.51,
90
+ "ASN": 37.70,
91
+ "PRO": 16.23,
92
+ "GLN": 37.51,
93
+ "ARG": 37.51,
94
+ "SER": 38.40,
95
+ "THR": 37.57,
96
+ "VAL": 37.16,
97
+ "TRP": 38.10,
98
+ "TYR": 35.38,
99
+ },
100
+ "sc": {
101
+ "ALA": 69.41,
102
+ "CYS": 96.75,
103
+ "ASP": 102.69,
104
+ "GLU": 134.74,
105
+ "PHE": 164.11,
106
+ "GLY": 32.33,
107
+ "HIS": 147.08,
108
+ "ILE": 137.96,
109
+ "LYS": 163.30,
110
+ "LEU": 141.12,
111
+ "MET": 156.64,
112
+ "ASN": 106.24,
113
+ "PRO": 119.90,
114
+ "GLN": 140.99,
115
+ "ARG": 201.25,
116
+ "SER": 78.11,
117
+ "THR": 101.70,
118
+ "VAL": 114.28,
119
+ "TRP": 211.26,
120
+ "TYR": 177.38,
121
+ },
122
+ }
@@ -0,0 +1,65 @@
1
+ """
2
+ Functions to execute freesasa and parse its output.
3
+ """
4
+
5
+ import os
6
+
7
+ import freesasa
8
+ from Bio.PDB.Structure import Structure
9
+ from freesasa import Classifier, calc, structureFromBioPDB
10
+
11
+ from prodigy_prot import NACCESS_CONFIG
12
+ from prodigy_prot.modules.aa_properties import rel_asa
13
+
14
+ freesasa.setVerbosity(freesasa.nowarnings)
15
+
16
+
17
+ def execute_freesasa_api(structure: Structure) -> tuple[dict, dict]:
18
+ """
19
+ Calls freesasa using its Python API and returns
20
+ per-residue accessibilities.
21
+ """
22
+
23
+ asa_data = {}
24
+ rsa_data: dict[tuple[str, int, str], float] = {}
25
+ _rsa: dict = rel_asa["total"]
26
+
27
+ classifier = Classifier(str(NACCESS_CONFIG))
28
+
29
+ try:
30
+ struct = structureFromBioPDB(
31
+ structure,
32
+ classifier,
33
+ )
34
+ result = calc(struct)
35
+ except AssertionError as e:
36
+ error_message = "" + os.linesep
37
+ error_message += "[!] Error when running freesasa:" + os.linesep
38
+ error_message += f"[!] {e}" + os.linesep
39
+ error_message += (
40
+ "[!] Make sure the atom names in your PDB file match"
41
+ " the canonical naming and belong "
42
+ "to default residues" + os.linesep
43
+ )
44
+ print(error_message)
45
+ raise Exception(error_message)
46
+
47
+ # iterate over all atoms to get SASA and residue name
48
+ for idx in range(struct.nAtoms()):
49
+ atname = struct.atomName(idx)
50
+ resname = struct.residueName(idx)
51
+ resid = struct.residueNumber(idx)
52
+ chain = struct.chainLabel(idx)
53
+ at_uid = (chain, resname, resid, atname)
54
+ res_uid = (chain, resname, resid)
55
+
56
+ asa = result.atomArea(idx)
57
+ asa_data[at_uid] = asa
58
+ # add asa to residue
59
+ rsa_data[res_uid] = rsa_data.get(res_uid, 0) + asa
60
+
61
+ # convert total asa ro relative asa
62
+ rsa_data.update(
63
+ (res_uid, asa / _rsa[res_uid[1]]) for res_uid, asa in rsa_data.items()
64
+ )
65
+ return asa_data, rsa_data
@@ -0,0 +1,41 @@
1
+ """
2
+ Models to predict binding affinity based on molecular properties.
3
+ """
4
+
5
+
6
+ def IC_NIS(
7
+ ic_cc: float,
8
+ ic_ca: float,
9
+ ic_pp: float,
10
+ ic_pa: float,
11
+ p_nis_a: float,
12
+ p_nis_c: float,
13
+ ) -> float:
14
+ """
15
+ Calculates the predicted binding affinity value
16
+ based on the IC-NIS model.
17
+ """
18
+
19
+ return (
20
+ -0.09459 * ic_cc
21
+ + -0.10007 * ic_ca
22
+ + 0.19577 * ic_pp
23
+ + -0.22671 * ic_pa
24
+ + 0.18681 * p_nis_a
25
+ + 0.13810 * p_nis_c
26
+ + -15.9433
27
+ )
28
+
29
+
30
+ def NIS(p_nis_c: float, p_nis_p: float, n_int_atoms: float) -> float:
31
+ """
32
+ Calculates the predicted binding affinity value
33
+ based on the NIS model.
34
+ """
35
+
36
+ return (
37
+ 0.0856851248873 * p_nis_p
38
+ + -0.0685254498746 * p_nis_c
39
+ + 0.0261591389985 * n_int_atoms
40
+ + 3.0124939659498
41
+ )