packmol-memgen-minimal 1.1.16__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.
Files changed (71) hide show
  1. packmol_memgen/__init__.py +2 -0
  2. packmol_memgen/__version__.py +34 -0
  3. packmol_memgen/data/LICENSE.Apache-2.0 +201 -0
  4. packmol_memgen/data/extra_solvents.lib +789 -0
  5. packmol_memgen/data/frcmod.lipid_ext +97 -0
  6. packmol_memgen/data/frcmod.solvents +129 -0
  7. packmol_memgen/data/insane_lipids.txt +138 -0
  8. packmol_memgen/data/insane_solvents.txt +45 -0
  9. packmol_memgen/data/leaprc.extra_solvents +42 -0
  10. packmol_memgen/data/leaprc.lipid_ext +48 -0
  11. packmol_memgen/data/lipid_ext.lib +12312 -0
  12. packmol_memgen/data/martini_v3.0.0.itp +356605 -0
  13. packmol_memgen/data/memgen.parm +4082 -0
  14. packmol_memgen/data/pdbs.tar.gz +0 -0
  15. packmol_memgen/data/solvent.parm +14 -0
  16. packmol_memgen/example/example.sh +31 -0
  17. packmol_memgen/lib/__init__.py +0 -0
  18. packmol_memgen/lib/amber.py +77 -0
  19. packmol_memgen/lib/charmmlipid2amber/__init__.py +0 -0
  20. packmol_memgen/lib/charmmlipid2amber/charmmlipid2amber.csv +7164 -0
  21. packmol_memgen/lib/charmmlipid2amber/charmmlipid2amber.py +225 -0
  22. packmol_memgen/lib/pdbremix/LICENSE +21 -0
  23. packmol_memgen/lib/pdbremix/__init__.py +0 -0
  24. packmol_memgen/lib/pdbremix/_version.py +1 -0
  25. packmol_memgen/lib/pdbremix/amber.py +1103 -0
  26. packmol_memgen/lib/pdbremix/asa.py +227 -0
  27. packmol_memgen/lib/pdbremix/data/aminoacid.pdb +334 -0
  28. packmol_memgen/lib/pdbremix/data/binaries.json +26 -0
  29. packmol_memgen/lib/pdbremix/data/charmm22.parameter +2250 -0
  30. packmol_memgen/lib/pdbremix/data/charmm22.topology +1635 -0
  31. packmol_memgen/lib/pdbremix/data/color_b.py +682 -0
  32. packmol_memgen/lib/pdbremix/data/hin.lib +130 -0
  33. packmol_memgen/lib/pdbremix/data/hydroxide.lib +88 -0
  34. packmol_memgen/lib/pdbremix/data/make_chi.py +92 -0
  35. packmol_memgen/lib/pdbremix/data/opls.parameter +1108 -0
  36. packmol_memgen/lib/pdbremix/data/opls.topology +1869 -0
  37. packmol_memgen/lib/pdbremix/data/phd.frcmod +82 -0
  38. packmol_memgen/lib/pdbremix/data/phd.leaprc +4 -0
  39. packmol_memgen/lib/pdbremix/data/phd.prepin +35 -0
  40. packmol_memgen/lib/pdbremix/data/template.pdb +334 -0
  41. packmol_memgen/lib/pdbremix/data/znb.frcmod +24 -0
  42. packmol_memgen/lib/pdbremix/data/znb.leaprc +7 -0
  43. packmol_memgen/lib/pdbremix/data/znb.lib +69 -0
  44. packmol_memgen/lib/pdbremix/data.py +264 -0
  45. packmol_memgen/lib/pdbremix/fetch.py +102 -0
  46. packmol_memgen/lib/pdbremix/force.py +627 -0
  47. packmol_memgen/lib/pdbremix/gromacs.py +978 -0
  48. packmol_memgen/lib/pdbremix/lib/__init__.py +0 -0
  49. packmol_memgen/lib/pdbremix/lib/docopt.py +579 -0
  50. packmol_memgen/lib/pdbremix/lib/pyqcprot.py +305 -0
  51. packmol_memgen/lib/pdbremix/namd.py +1078 -0
  52. packmol_memgen/lib/pdbremix/pdbatoms.py +543 -0
  53. packmol_memgen/lib/pdbremix/pdbtext.py +120 -0
  54. packmol_memgen/lib/pdbremix/protein.py +311 -0
  55. packmol_memgen/lib/pdbremix/pymol.py +480 -0
  56. packmol_memgen/lib/pdbremix/rmsd.py +203 -0
  57. packmol_memgen/lib/pdbremix/simulate.py +420 -0
  58. packmol_memgen/lib/pdbremix/spacehash.py +73 -0
  59. packmol_memgen/lib/pdbremix/trajectory.py +286 -0
  60. packmol_memgen/lib/pdbremix/util.py +273 -0
  61. packmol_memgen/lib/pdbremix/v3.py +16 -0
  62. packmol_memgen/lib/pdbremix/v3array.py +482 -0
  63. packmol_memgen/lib/pdbremix/v3numpy.py +350 -0
  64. packmol_memgen/lib/pdbremix/volume.py +155 -0
  65. packmol_memgen/lib/utils.py +1017 -0
  66. packmol_memgen/main.py +2827 -0
  67. packmol_memgen_minimal-1.1.16.dist-info/METADATA +664 -0
  68. packmol_memgen_minimal-1.1.16.dist-info/RECORD +71 -0
  69. packmol_memgen_minimal-1.1.16.dist-info/WHEEL +4 -0
  70. packmol_memgen_minimal-1.1.16.dist-info/entry_points.txt +2 -0
  71. packmol_memgen_minimal-1.1.16.dist-info/licenses/LICENSE +338 -0
@@ -0,0 +1,311 @@
1
+ # encoding: utf-8
2
+
3
+ __doc__ = """
4
+
5
+ Common protein manipulations.
6
+
7
+ This is a collection of some common PDB and Soup manipulations
8
+ of protein strucutres.
9
+ """
10
+
11
+
12
+ import string
13
+
14
+ from . import data
15
+ from . import pdbatoms
16
+ from . import util
17
+ from . import pdbtext
18
+ from . import v3
19
+ from . import spacehash
20
+
21
+
22
+ def strip_solvent_pdb(pdb):
23
+ new_pdb = util.fname_variant(pdb)
24
+ txt = pdbtext.strip_solvent(open(pdb).read())
25
+ open(new_pdb, 'w').write(txt)
26
+ return new_pdb
27
+
28
+
29
+ def find_ca_of_resname(atoms, resname):
30
+ for atom in atoms:
31
+ if pdbatoms.split_tag(resname) == \
32
+ (atom.chain_id, atom.res_num, atom.res_insert):
33
+ if "CA" == atom.type:
34
+ return atom
35
+ raise IndexError("Can't find atom %s" % resname)
36
+
37
+
38
+ def get_pdb_transform(pdb, center_res, top_res):
39
+ """
40
+ Returns a transformation matrix that centers pdb to
41
+ center_res on the z-axis and moves top_res above center_res
42
+ on the y-axis
43
+ """
44
+ soup = pdbatoms.Soup(pdb)
45
+ atoms = soup.atoms()
46
+ soup_center = pdbatoms.get_center(atoms)
47
+ translation = v3.translation(-soup_center)
48
+ soup.transform(translation)
49
+ result = translation
50
+
51
+ view = v3.vector(0, 0, 1)
52
+
53
+ if center_res is not None:
54
+ center_atom = find_ca_of_resname(soup.atoms(), center_res)
55
+ axis = v3.cross(view, center_atom.pos)
56
+ angle = v3.vec_dihedral(view, axis, center_atom.pos)
57
+ rotation1 = v3.rotation(axis, angle)
58
+ soup.transform(rotation1)
59
+ result = v3.combine(rotation1, result)
60
+
61
+ if top_res is not None:
62
+ top_atom = find_ca_of_resname(soup.atoms(), top_res)
63
+ top_dir = v3.vector(0, 1, 0)
64
+ axis = v3.vector(view)
65
+ angle = v3.vec_dihedral(top_dir, axis, top_atom.pos)
66
+ rotation2 = v3.rotation(axis, angle)
67
+ result = v3.combine(rotation2, result)
68
+
69
+ return result
70
+
71
+
72
+ def transform_pdbs_to_residues_of_first_pdb(pdbs, center_res, top_res):
73
+ transform = get_pdb_transform(pdbs[0], center_res, top_res)
74
+ new_pdbs = []
75
+ for pdb in pdbs:
76
+ new_pdb = util.fname_variant(pdb)
77
+ soup = pdbatoms.Soup(pdb)
78
+ soup.transform(transform)
79
+ soup.write_pdb(new_pdb)
80
+ new_pdbs.append(new_pdb)
81
+ return new_pdbs
82
+
83
+
84
+ def transformed_soup_from_pdb(
85
+ pdb, center_res=None, top_res=None,
86
+ width=None, height=None, frame_residues=None):
87
+ soup = pdbatoms.Soup(pdb)
88
+ if center_res and top_res:
89
+ transform = get_pdb_transform(pdb, center_res, top_res)
90
+ soup.transform(transform)
91
+ if frame_residues:
92
+ resnames = [pymol_id_from_res_tag(r) for r in frame_residues]
93
+ soup.frame_pymol_script = "zoom (%s)\n" % ' or '.join(resnames)
94
+ if width: soup.width = width
95
+ if height: soup.height = height
96
+ return soup
97
+
98
+
99
+ def is_peptide_connected(res1, res2):
100
+ if res1.has_atom('CA') and \
101
+ res1.has_atom('C') and \
102
+ res2.has_atom('N') and \
103
+ res2.has_atom('CA'):
104
+ d = v3.distance(res1.atom('C').pos, res2.atom('N').pos)
105
+ if d < 2.0:
106
+ return True
107
+ return False
108
+
109
+
110
+ def find_chains(soup):
111
+ residues = soup.residues()
112
+ n = len(residues)
113
+ if n == 0:
114
+ return
115
+ i_chain = 0
116
+ chain_id = string.ascii_uppercase[i_chain]
117
+ for i in range(0, n):
118
+ res = residues[i]
119
+ if i == 0:
120
+ is_connected_to_prev = False
121
+ else:
122
+ prev_res = residues[i-1]
123
+ is_connected_to_prev = is_peptide_connected(prev_res, res)
124
+ if i < n-1:
125
+ next_res = residues[i+1]
126
+ is_connected_to_next = is_peptide_connected(res, next_res)
127
+ else:
128
+ is_connected_to_next = False
129
+ if is_connected_to_prev or is_connected_to_next:
130
+ res.set_chain_id(chain_id)
131
+ if not is_connected_to_next:
132
+ i_chain += 1
133
+ chain_id = string.ascii_uppercase[i_chain]
134
+
135
+
136
+ def is_connected(i, j, soup, cutoff=3.5):
137
+ if i == j:
138
+ return False
139
+ min_dist = 1000.0
140
+ for atom_i in soup.residue(i).atoms():
141
+ for atom_j in soup.residue(j).atoms():
142
+ dist = v3.distance(atom_i.pos, atom_j.pos)
143
+ if dist < min_dist:
144
+ min_dist = dist
145
+ return min_dist < cutoff
146
+
147
+
148
+ backbone = ['CA', 'HA', 'N', 'H', 'O', 'C']
149
+ def is_sidechain_connected(i, j, soup, cutoff=3.5):
150
+ if abs(i-j) <= 2:
151
+ return False
152
+ min_dist = 1000.0
153
+ sidechain_atoms_i = [a for a in soup.residue(i).atoms()
154
+ if a.type not in backbone]
155
+ for atom_i in sidechain_atoms_i:
156
+ for atom_j in soup.residue(j).atoms():
157
+ dist = v3.distance(atom_i.pos, atom_j.pos)
158
+ if dist < min_dist:
159
+ min_dist = dist
160
+ return min_dist < cutoff
161
+
162
+
163
+ def find_bb_hbonds(residues):
164
+
165
+ cutoff_d_of_n_o = 3.5
166
+
167
+ vertices = []
168
+ atoms = []
169
+ for i_residue, residue in enumerate(residues):
170
+ residue.i = i_residue
171
+ for atom in residue.atoms():
172
+ atom.residue = residue
173
+ if residue.has_atom('O'):
174
+ atom = residue.atom('O')
175
+ atoms.append(atom)
176
+ vertices.append(atom.pos)
177
+ if residue.has_atom('N'):
178
+ atom = residue.atom('N')
179
+ atoms.append(atom)
180
+ vertices.append(atom.pos)
181
+
182
+ for i, j in spacehash.SpaceHash(vertices).close_pairs():
183
+ if abs(i - j) < 3:
184
+ continue
185
+
186
+ if atoms[i].element == 'O' and atoms[j].element == 'N':
187
+ o = atoms[i]
188
+ n = atoms[j]
189
+ elif atoms[i].element == 'N' and atoms[j].element == 'O':
190
+ n = atoms[i]
191
+ o = atoms[j]
192
+ else:
193
+ continue
194
+
195
+ if v3.distance(o.pos, n.pos) < cutoff_d_of_n_o:
196
+ o.residue.co_partners.append(n.residue.i)
197
+ n.residue.nh_partners.append(o.residue.i)
198
+
199
+
200
+ def unique_append(a_list, item):
201
+ if item not in a_list:
202
+ a_list.append(item)
203
+ a_list.sort()
204
+
205
+
206
+ def find_ss_by_bb_hbonds(soup):
207
+ """
208
+ Analyzes a protein soup and adds the fields to each residue
209
+ to indicate secondary-structure:
210
+
211
+ - res.co_partners = []
212
+ - res.nh_partners = []
213
+ - res.beta_contacts = []
214
+ - res.alpha_contacts = []
215
+ - res.ss = "C"
216
+ - res.ss_contacts = []
217
+
218
+ The key field is ss_contacts which lists the indices of the
219
+ residues that are naturally in contact due to secondary-structure
220
+ geometry.
221
+ """
222
+
223
+ residues = soup.residues()
224
+ n_res = len(residues)
225
+
226
+ for res in residues:
227
+ res.co_partners = []
228
+ res.nh_partners = []
229
+ res.beta_contacts = []
230
+ res.alpha_contacts = []
231
+ res.ss_contacts = []
232
+ res.ss = "C"
233
+
234
+ find_bb_hbonds(residues)
235
+
236
+ def is_conh(i_res, j_res):
237
+ if not (0 <= i_res < n_res):
238
+ return False
239
+ if not (0 <= j_res < n_res):
240
+ return False
241
+ return j_res in residues[i_res].co_partners
242
+
243
+ def make_alpha_contacts(i_res, j_res):
244
+ unique_append(residues[i_res].alpha_contacts, j_res)
245
+ unique_append(residues[j_res].alpha_contacts, i_res)
246
+
247
+ for i_res in range(n_res):
248
+ if is_conh(i_res - 1, i_res + 3) and is_conh(i_res, i_res + 4):
249
+ # alpha-helix
250
+ for j_res in range(i_res, i_res + 4):
251
+ residues[j_res].ss = 'H'
252
+ make_alpha_contacts(i_res + 3, i_res)
253
+ make_alpha_contacts(i_res + 4, i_res)
254
+
255
+ def make_beta_contact(i_res, j_res):
256
+ unique_append(residues[i_res].beta_contacts, j_res)
257
+ unique_append(residues[i_res].beta_contacts, j_res-1)
258
+ unique_append(residues[i_res].beta_contacts, j_res+1)
259
+
260
+ def make_beta_contacts(i_res, j_res):
261
+ make_beta_contact(i_res, j_res)
262
+ make_beta_contact(j_res, i_res)
263
+
264
+ for i_res in range(n_res):
265
+ for j_res in range(n_res):
266
+ is_beta = False
267
+ if abs(i_res - j_res) <= 2:
268
+ # can't have beta contacts 2 or less apart
269
+ is_beta = False
270
+ elif is_conh(i_res, j_res) and is_conh(j_res, i_res):
271
+ # anti-parallel beta-sheet h-bonded pair
272
+ is_beta = True
273
+ elif is_conh(i_res - 1, j_res + 1) and is_conh(i_res + 1, j_res - 1):
274
+ # anti-parallel beta-sheet non-h-bonded pair
275
+ is_beta = True
276
+ elif is_conh(i_res, j_res - 1) and is_conh(j_res - 1, i_res):
277
+ # parallel beta sheet pairs
278
+ is_beta = True
279
+ if is_beta:
280
+ make_beta_contacts(i_res, j_res)
281
+ residues[i_res].ss = "E"
282
+ residues[j_res].ss = "E"
283
+
284
+ def check_piece_is_e(i_res, j_res):
285
+ for k_res in range(i_res, j_res+1):
286
+ if k_res < 0 or k_res >= n_res:
287
+ return False
288
+ if residues[k_res].ss != "E":
289
+ return False
290
+ return True
291
+
292
+ # add cross-strand i->j-2 contacts as beta
293
+ # TODO: distinguish hb and non-hb pairs
294
+ for i_res in range(n_res):
295
+ if residues[i_res].ss == "E":
296
+ for j_res in residues[i_res].beta_contacts:
297
+ if check_piece_is_e(j_res - 2, j_res):
298
+ unique_append(residues[i_res].beta_contacts, j_res - 2)
299
+ unique_append(residues[j_res - 2].beta_contacts, i_res)
300
+ if check_piece_is_e(j_res, j_res + 2):
301
+ unique_append(residues[i_res].beta_contacts, j_res + 2)
302
+ unique_append(residues[j_res + 2].beta_contacts, i_res)
303
+
304
+ for i_res in range(n_res):
305
+ residue = residues[i_res]
306
+ residue.ss_contacts.extend(residue.alpha_contacts)
307
+ residue.ss_contacts.extend(residue.beta_contacts)
308
+
309
+
310
+
311
+