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,264 @@
1
+ # encoding: utf-8
2
+
3
+ __doc__ = """
4
+
5
+ Stores data for PDBREMIX.
6
+
7
+ - directory of explici data directory
8
+ - mappings of residue names to chars
9
+ - names and locations of binaries used
10
+ - backbone atom types
11
+ - solvent residue types
12
+ - element radii
13
+ - chi dihedral angle topologies
14
+ """
15
+
16
+
17
+ import os
18
+ from . import util
19
+
20
+
21
+ module_dir = os.path.dirname(__file__)
22
+ data_dir = os.path.join(module_dir, 'data')
23
+
24
+ binaries = {
25
+ "pymol": "",
26
+ "pymol_batch": "",
27
+ "chimera": "",
28
+
29
+ "theseus": "",
30
+ "mafft": "",
31
+
32
+ "sander": "",
33
+ "tleap": "",
34
+
35
+ "mdrun": "",
36
+ "pdb2gmx": "",
37
+ "trjconv": "",
38
+ "grompp": "",
39
+ "editconf": "",
40
+ "genion": "",
41
+ "genbox": "",
42
+
43
+ "vmd": "",
44
+ "psfgen": "",
45
+ "namd2": "",
46
+ "flipdcd": "",
47
+
48
+ "mod9v8": ""
49
+ }
50
+ home_dir = os.path.expanduser('~')
51
+ binaries_fname = os.path.join(home_dir, '.pdbremix.config')
52
+ backup_binaries_fname = os.path.join(os.environ['AMBERHOME'], 'dat') if 'AMBERHOME' in os.environ else None
53
+ if not os.path.isfile(binaries_fname):
54
+ try:
55
+ util.write_dict(binaries_fname, binaries)
56
+ except IOError:
57
+ # May not have permission here, especially in a docker container. If so,
58
+ # fall back on AMBERHOME
59
+ if backup_binaries_fname is None:
60
+ raise
61
+ binaries_fname = backup_binaries_fname
62
+ else:
63
+ binaries = util.read_dict(binaries_fname)
64
+
65
+
66
+ def binary(bin, arg_str='', out_name=None, in_fname=None):
67
+ """
68
+ Runs an external binary, handles arguments, writes out
69
+ equivalent .sh file, log file, and can pipe in in_fname.
70
+ """
71
+ if bin in binaries and binaries[bin]:
72
+ bin = binaries[bin]
73
+ else:
74
+ util.check_program(bin)
75
+ if arg_str:
76
+ util.run_with_output_file(
77
+ '%s %s' % (bin, arg_str), out_name, in_fname)
78
+ return '"%s"' % bin
79
+
80
+
81
+ def invert_dict(d):
82
+ """
83
+ Returns dictionaries with swapped key-values.
84
+ """
85
+ return dict((v, k) for k,v in list(d.items()))
86
+
87
+
88
+ res_name_to_char = {
89
+ "ALA":"A", "CYS":"C", "ASP":"D",
90
+ "GLU":"E", "PHE":"F", "GLY":"G",
91
+ "HIS":"H", "ILE":"I", "LYS":"K",
92
+ "LEU":"L", "MET":"M", "ASN":"N",
93
+ "PRO":"P", "GLN":"Q", "ARG":"R",
94
+ "SER":"S", "THR":"T", "VAL":"V",
95
+ "TRP":"W", "TYR":"Y", "ACE":">",
96
+ "NME":"<",
97
+ }
98
+
99
+ res_char_to_name = invert_dict(res_name_to_char)
100
+
101
+ res_name_to_char.update({"HID":"H", "HIE":"H", "HIP":"H", "HSE":"H", "LYP":"K", "CYM":"C", "CYX":"C", "CYN":"C"})
102
+
103
+ # recognized atom types for protein backbone
104
+ backbone_atoms = [
105
+ "OXT", # C-terminal carboxyl group
106
+ "H1", "H2", "H3", # N-terminal charged group
107
+ "C", "O", # peptide-bond carbonyl group
108
+ "H", "HN", "N", # peptide-bond amide group
109
+ "CA", "HA" # main-chain C-alpha and alkyl group
110
+ ]
111
+
112
+ solvent_res_types = [
113
+ 'HOH', 'WAT', 'TIP', 'SOL',
114
+ 'CLA', 'SOD', 'NA', 'CL',
115
+ 'NA+', 'CL-', 'Na', 'Cl',
116
+ 'Na+', 'Cl-']
117
+
118
+ radii = {
119
+ 'H': 1.20,
120
+ 'N': 1.55,
121
+ 'NA': 2.27,
122
+ 'CU': 1.40,
123
+ 'CL': 1.75,
124
+ 'C': 1.70,
125
+ 'O': 1.52,
126
+ 'I': 1.98,
127
+ 'P': 1.80,
128
+ 'B': 1.85,
129
+ 'BR': 1.85,
130
+ 'S': 1.80,
131
+ 'SE': 1.90,
132
+ 'F': 1.47,
133
+ 'FE': 1.80,
134
+ 'K': 2.75,
135
+ 'MN': 1.73,
136
+ 'MG': 1.73,
137
+ 'ZN': 1.39,
138
+ 'HG': 1.80,
139
+ 'XE': 1.80,
140
+ 'AU': 1.80,
141
+ 'LI': 1.80,
142
+ '.': 1.80
143
+ }
144
+
145
+ masses = {'H' : 1.008, 'HE' : 4.003, 'LI' : 6.941, 'BE' : 9.012,
146
+ 'B' : 10.811, 'C' : 12.011, 'N' : 14.007, 'O' : 15.999,
147
+ 'F' : 18.998, 'NE' : 20.180, 'NA' : 22.990, 'MG' : 24.305,
148
+ 'AL' : 26.982, 'SI' : 28.086, 'P' : 30.974, 'S' : 32.066,
149
+ 'CL' : 35.453, 'AR' : 39.948, 'K' : 39.098, 'CA' : 40.078,
150
+ 'SC' : 44.956, 'TI' : 47.867, 'V' : 50.942, 'CR' : 51.996,
151
+ 'MN' : 54.938, 'FE' : 55.845, 'CO' : 58.933, 'NI' : 58.693,
152
+ 'CU' : 63.546, 'ZN' : 65.38, 'GA' : 69.723, 'GE' : 72.631,
153
+ 'AS' : 74.922, 'SE' : 78.971, 'BR' : 79.904, 'KR' : 84.798,
154
+ 'RB' : 84.468, 'SR' : 87.62, 'Y' : 88.906, 'ZR' : 91.224,
155
+ 'NB' : 92.906, 'MO' : 95.95, 'TC' : 98.907, 'RU' : 101.07,
156
+ 'RH' : 102.906, 'PD' : 106.42, 'AG' : 107.868, 'CD' : 112.414,
157
+ 'IN' : 114.818, 'SN' : 118.711, 'SB' : 121.760, 'TE' : 126.7,
158
+ 'I' : 126.904, 'XE' : 131.294, 'CS' : 132.905, 'BA' : 137.328,
159
+ 'LA' : 138.905, 'CE' : 140.116, 'PR' : 140.908, 'ND' : 144.243,
160
+ 'PM' : 144.913, 'SM' : 150.36, 'EU' : 151.964, 'GD' : 157.25,
161
+ 'TB' : 158.925, 'DY' : 162.500, 'HO' : 164.930, 'ER' : 167.259,
162
+ 'TM' : 168.934, 'YB' : 173.055, 'LU' : 174.967, 'HF' : 178.49,
163
+ 'TA' : 180.948, 'W' : 183.84, 'RE' : 186.207, 'OS' : 190.23,
164
+ 'IR' : 192.217, 'PT' : 195.085, 'AU' : 196.967, 'HG' : 200.592,
165
+ 'TL' : 204.383, 'PB' : 207.2, 'BI' : 208.980, 'PO' : 208.982,
166
+ 'AT' : 209.987, 'RN' : 222.081, 'FR' : 223.020, 'RA' : 226.025,
167
+ 'AC' : 227.028, 'TH' : 232.038, 'PA' : 231.036, 'U' : 238.029,
168
+ 'NP' : 237, 'PU' : 244, 'AM' : 243, 'CM' : 247, 'BK' : 247,
169
+ 'CT' : 251, 'ES' : 252, 'FM' : 257, 'MD' : 258, 'NO' : 259,
170
+ 'LR' : 262, 'RF' : 261, 'DB' : 262, 'SG' : 266, 'BH' : 264,
171
+ 'HS' : 269, 'MT' : 268, 'DS' : 271, 'RG' : 272, 'CN' : 285,
172
+ 'NH' : 284, 'FL' : 289, 'MC' : 288, 'LV' : 292, 'TS' : 294,
173
+ 'OG' : 294}
174
+
175
+ two_char_elements = [e for e in list(radii.keys()) if len(e) == 2]
176
+
177
+
178
+ def strip_numbers(s):
179
+ result = ""
180
+ for c in s:
181
+ if not c.isdigit() and c != " ":
182
+ result += c
183
+ return result
184
+
185
+
186
+ def guess_element(res_type, atom_type):
187
+ """
188
+ Returns the element type using a dirty heuristic guess.
189
+ """
190
+ atom_type = strip_numbers(atom_type)
191
+ if len(atom_type) == 0:
192
+ raise Exception("PDB line with no atom name found")
193
+ if res_type in res_name_to_char:
194
+ return atom_type[0]
195
+ if len(atom_type) == 2 and atom_type in two_char_elements:
196
+ return atom_type
197
+ return atom_type[0]
198
+
199
+
200
+ chi_topology = {
201
+ 'ARG': [ ['N', 'CA', 'CB', 'CG'],
202
+ ['CA', 'CB', 'CG', 'CD'],
203
+ ['CB', 'CG', 'CD', 'NE'],
204
+ ['CG', 'CD', 'NE', 'CZ']],
205
+ 'ASN': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'OD1']],
206
+ 'ASP': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'OD1']],
207
+ 'CYS': [['N', 'CA', 'CB', 'SG']],
208
+ 'GLN': [ ['N', 'CA', 'CB', 'CG'],
209
+ ['CA', 'CB', 'CG', 'CD'],
210
+ ['CB', 'CG', 'CD', 'OE1']],
211
+ 'GLU': [ ['N', 'CA', 'CB', 'CG'],
212
+ ['CA', 'CB', 'CG', 'CD'],
213
+ ['CB', 'CG', 'CD', 'OE1']],
214
+ 'HIS': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'ND1']],
215
+ 'ILE': [['N', 'CA', 'CB', 'CG1'], ['CA', 'CB', 'CG1', 'CD1']],
216
+ 'LEU': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'CD1']],
217
+ 'LYN': [ ['N', 'CA', 'CB', 'CG'],
218
+ ['CA', 'CB', 'CG', 'CD'],
219
+ ['CB', 'CG', 'CD', 'CE'],
220
+ ['CG', 'CD', 'CE', 'NZ']],
221
+ 'LYP': [ ['N', 'CA', 'CB', 'CG'],
222
+ ['CA', 'CB', 'CG', 'CD'],
223
+ ['CB', 'CG', 'CD', 'CE'],
224
+ ['CG', 'CD', 'CE', 'NZ']],
225
+ 'LYS': [ ['N', 'CA', 'CB', 'CG'],
226
+ ['CA', 'CB', 'CG', 'CD'],
227
+ ['CB', 'CG', 'CD', 'CE'],
228
+ ['CG', 'CD', 'CE', 'NZ']],
229
+ 'MET': [ ['N', 'CA', 'CB', 'CG'],
230
+ ['CA', 'CB', 'CG', 'SD'],
231
+ ['CB', 'CG', 'SD', 'CE']],
232
+ 'PHD': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'OD1']],
233
+ 'PHE': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'CD1']],
234
+ 'PRO': [ ['N', 'CA', 'CB', 'CG'],
235
+ ['CA', 'CB', 'CG', 'CD'],
236
+ ['CB', 'CG', 'CD', 'N'],
237
+ ['CG', 'CD', 'N', 'CA']],
238
+ 'SER': [['N', 'CA', 'CB', 'OG']],
239
+ 'THR': [['N', 'CA', 'CB', 'OG1']],
240
+ 'TRP': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'CD1']],
241
+ 'TYR': [['N', 'CA', 'CB', 'CG'], ['CA', 'CB', 'CG', 'CD1']],
242
+ 'VAL': [['N', 'CA', 'CB', 'CG1']]}
243
+
244
+
245
+ def get_res_chi_topology(res_type):
246
+ """
247
+ Returns the chi topology for a given residue, which is a list of
248
+ atoms that are affected if one rotates the chi0, chi1...
249
+ dihedral angle.
250
+ """
251
+ # Some common residue renamings in AMBER and GROMACS
252
+ if res_type in ["HID", "HIE", "HIP", "HSE"] or "HIS" in res_type:
253
+ res_type = "HIS"
254
+ if res_type in ["LYP"]:
255
+ res_type = "LYS"
256
+ if res_type in ["CYM", "CYX", "CYN"]:
257
+ res_type = "CYS"
258
+ if res_type not in chi_topology:
259
+ return []
260
+ else:
261
+ return chi_topology[res_type]
262
+
263
+
264
+
@@ -0,0 +1,102 @@
1
+ # encoding: utf-8
2
+
3
+ __doc__ = """
4
+
5
+ Fetches PDB files from RCSB web sites.
6
+
7
+ Simple utility functions to fetch PDB files given a list
8
+ of PDB codes. Several options are available.
9
+ """
10
+
11
+ import os
12
+ import urllib.request, urllib.parse, urllib.error
13
+ import gzip
14
+
15
+ from . import util
16
+
17
+
18
+ def expand_pdbs(*pdbs):
19
+ """
20
+ Returns a cleaned-up list of PDB codes given a mixed list
21
+ of pdb codes, pdb filenames, and text files containing such.
22
+ """
23
+ results = []
24
+ for pdb in pdbs:
25
+ if os.path.isfile(pdb):
26
+ print("Reading PDB codes from", pdb)
27
+ new_pdbs = expand_pdbs(*util.words_in_file(pdb))
28
+ results.extend(new_pdbs)
29
+ else:
30
+ pdb = pdb.lower()
31
+ if pdb.endswith('.pdb'):
32
+ pdb = pdb[:-4]
33
+ if len(pdb) != 4:
34
+ raise Exception("PDB code is not 4 letters long")
35
+ results.append(pdb)
36
+ return results
37
+
38
+
39
+ def get_pdbs_with_http(*pdbs):
40
+ """
41
+ Fetches PDB files using HTTP from a list of pdb-codes/text-files.
42
+ """
43
+ for pdb in expand_pdbs(*pdbs):
44
+ fname = pdb if pdb.endswith('pdb') else '%s.pdb' % pdb
45
+ if os.path.isfile(fname):
46
+ print("Skip: %s exists" % fname)
47
+ else:
48
+ try:
49
+ site = 'http://www.rcsb.org/pdb/files'
50
+ url = '%s/%s' % (site, fname)
51
+ sock = urllib.request.urlopen(url)
52
+ text = sock.read()
53
+ sock.close()
54
+ if '<html>' in text:
55
+ raise Exception
56
+ open(fname, 'w').write(text)
57
+ print(fname)
58
+ except:
59
+ print("Failed: %s" % fname)
60
+
61
+
62
+ template = """#!/bin/bash
63
+ ftp -n %(host)s <<END_SCRIPT
64
+ quote user guest
65
+ quote
66
+ ls
67
+ cd pub/pdb/data/structures/all/pdb
68
+ binary
69
+ %(mget_str)s
70
+ quit
71
+ END_SCRIPT
72
+ exit 0
73
+ """
74
+
75
+
76
+ def get_pdbs_with_ftp(*pdbs):
77
+ """
78
+ Fetches PDB files using FTP from a list of pdb-codes/text-files.
79
+ """
80
+ pdbs = expand_pdbs(*pdbs)
81
+ entries = ['pdb%s.ent.gz' % pdb for pdb in pdbs]
82
+ mget_scripts = ["get %s" % entry for entry in entries]
83
+ substitutions = {
84
+ 'host': 'ftp.wwpdb.org',
85
+ 'mget_str': '\n'.join(mget_scripts),
86
+ }
87
+ ftp_script = template % substitutions
88
+ open('ftp.sh', 'w').write(ftp_script)
89
+ util.run_with_output('chmod +x ftp.sh')
90
+ util.run_with_output('./ftp.sh')
91
+ for pdb, entry in zip(pdbs, entries):
92
+ fname = pdb + '.pdb'
93
+ if os.path.isfile(entry):
94
+ out_f = open(fname, 'w')
95
+ for line in gzip.open(entry):
96
+ out_f.write(line)
97
+ util.clean_fname(entry)
98
+ print(fname)
99
+ else:
100
+ print("Failed: %s" % fname)
101
+ util.clean_fname('ftp.sh')
102
+