fetkutils 3.6.7__tar.gz → 3.7.1__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 (25) hide show
  1. fetkutils-3.7.1/CMakeLists.txt +67 -0
  2. {fetkutils-3.6.7 → fetkutils-3.7.1}/PKG-INFO +6 -7
  3. {fetkutils-3.6.7 → fetkutils-3.7.1}/pyproject.toml +15 -8
  4. fetkutils-3.7.1/src/python/CMakeLists.txt +8 -0
  5. fetkutils-3.7.1/src/python/bin/fetkutils-amberti2img.py +339 -0
  6. fetkutils-3.7.1/src/python/bin/fetkutils-ipi-setupfromamber.py +877 -0
  7. fetkutils-3.7.1/src/python/bin/fetkutils-ipi-tdfepkie.py +771 -0
  8. fetkutils-3.7.1/src/python/bin/fetkutils-ipi-xcrd2dumpave.py +178 -0
  9. fetkutils-3.7.1/src/python/bin/fetkutils-nma-MergeHessianNetCDFs.py +347 -0
  10. fetkutils-3.7.1/src/python/bin/fetkutils-nma-approxfreqratio.py +204 -0
  11. fetkutils-3.7.1/src/python/bin/fetkutils-nma-kie.py +379 -0
  12. fetkutils-3.7.1/src/python/bin/fetkutils-nma-thermochem.py +137 -0
  13. fetkutils-3.7.1/src/python/bin/fetkutils-tischedule.py +407 -0
  14. {fetkutils-3.6.7 → fetkutils-3.7.1}/src/python/lib/fetkutils/tischedule.py +2 -2
  15. fetkutils-3.7.1/src/python/scripts.py +46 -0
  16. fetkutils-3.7.1/src/python/setup.py +39 -0
  17. fetkutils-3.6.7/setup.cfg +0 -4
  18. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/PKG-INFO +0 -20
  19. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/SOURCES.txt +0 -10
  20. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/dependency_links.txt +0 -1
  21. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/entry_points.txt +0 -10
  22. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/requires.txt +0 -8
  23. fetkutils-3.6.7/src/python/lib/fetkutils.egg-info/top_level.txt +0 -1
  24. {fetkutils-3.6.7 → fetkutils-3.7.1}/README.md +0 -0
  25. {fetkutils-3.6.7 → fetkutils-3.7.1}/src/python/lib/fetkutils/__init__.py +0 -0
@@ -0,0 +1,67 @@
1
+ # check if we are building as part of AmberTools
2
+ # PROJECT_NAME will be overriden by `project` command,
3
+ # so we need to check it before calling `project`
4
+ if (NOT DEFINED IS_AMBERTOOLS)
5
+ if (PROJECT_NAME STREQUAL "Amber")
6
+ set(IS_AMBERTOOLS TRUE)
7
+ else()
8
+ set(IS_AMBERTOOLS FALSE)
9
+ endif()
10
+ endif()
11
+
12
+ #
13
+ # Let's use 3.10, if possible, because that's the highest
14
+ # requirement of any part of AmberTools
15
+ #
16
+ if (IS_AMBERTOOLS)
17
+ cmake_minimum_required(VERSION 3.10)
18
+ else()
19
+ cmake_minimum_required(VERSION 3.12)
20
+ endif()
21
+
22
+ #
23
+ # Fortran is needed so we get -lgfortran when linking to some
24
+ # blas/lapack implementations
25
+ #
26
+ if(NOT DEFINED FETOOLKITVERSION)
27
+ set(FETOOLKITVERSION 0.0)
28
+ endif()
29
+
30
+ project(fetkutils VERSION "${FETOOLKITVERSION}" LANGUAGES NONE)
31
+
32
+
33
+ if(NOT IS_AMBERTOOLS)
34
+
35
+ if (SKBUILD)
36
+
37
+ # Every script in src/python/bin: each one has an entry point in
38
+ # pyproject.toml ([project.scripts]), and a script missing here makes its
39
+ # command fail with FileNotFoundError (8 fetkutils scripts and
40
+ # edgembar-bookend2dats.py were missing before 3.7.1).
41
+ file(GLOB FETKUTILS_SCRIPTS CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/python/bin/*.py")
42
+ install(FILES ${FETKUTILS_SCRIPTS}
43
+ DESTINATION bin
44
+ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_EXECUTE WORLD_READ)
45
+ #
46
+ # We can't install scripts.py to the installation prefix
47
+ # That would be, like, installing to /usr/scripts.py
48
+ #
49
+ install(FILES src/python/scripts.py DESTINATION .)
50
+ endif()
51
+
52
+
53
+ if(BUILD_PYTHON)
54
+ add_subdirectory(src/python)
55
+ endif()
56
+
57
+ else()
58
+
59
+ if(NOT ${nlopt_DISABLED})
60
+
61
+ if(BUILD_PYTHON)
62
+ add_subdirectory(src/python)
63
+ endif()
64
+
65
+ endif()
66
+
67
+ endif()
@@ -1,20 +1,19 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: fetkutils
3
- Version: 3.6.7
3
+ Version: 3.7.1
4
4
  Summary: Utility library for the FE-ToolKit project
5
- Author-email: "Timothy J. Giese" <TimothyJGiese@gmail.com>
6
5
  Keywords: free energy
6
+ Author-Email: "Timothy J. Giese" <TimothyJGiese@gmail.com>
7
7
  Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Development Status :: 5 - Production/Stable
9
+ Classifier: Operating System :: OS Independent
9
10
  Requires-Python: >=3.7
10
- Description-Content-Type: text/markdown
11
11
  Requires-Dist: numpy
12
12
  Requires-Dist: scipy
13
13
  Requires-Dist: matplotlib
14
14
  Requires-Dist: netCDF4
15
15
  Requires-Dist: rdkit
16
- Requires-Dist: setuptools
17
- Requires-Dist: importlib
18
- Requires-Dist: importlib-metadata
16
+ Requires-Dist: parmed
17
+ Description-Content-Type: text/markdown
19
18
 
20
19
  # TODO
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools>=61"]
3
- build-backend = "setuptools.build_meta"
2
+ requires = ["scikit-build-core>=0.3.0"]
3
+ build-backend = "scikit_build_core.build"
4
4
 
5
5
  [project]
6
6
  name = "fetkutils"
7
- version = "3.6.7"
7
+ version = "3.7.1"
8
8
  description = "Utility library for the FE-ToolKit project"
9
9
  authors = [
10
10
  {name = "Timothy J. Giese", email = "TimothyJGiese@gmail.com"},
@@ -13,6 +13,7 @@ authors = [
13
13
  classifiers = [
14
14
  "Programming Language :: Python :: 3",
15
15
  "Development Status :: 5 - Production/Stable",
16
+ "Operating System :: OS Independent",
16
17
  ]
17
18
  dependencies = [
18
19
  'numpy',
@@ -20,9 +21,7 @@ dependencies = [
20
21
  'matplotlib',
21
22
  'netCDF4',
22
23
  'rdkit',
23
- 'setuptools',
24
- 'importlib',
25
- 'importlib-metadata'
24
+ 'parmed'
26
25
  ]
27
26
  requires-python = ">=3.7"
28
27
  readme = "README.md"
@@ -42,5 +41,13 @@ keywords = ["free energy"]
42
41
  "fetkutils-nma-approxfreqratio.py" = "fetkutils.scripts:fetkutils_nma_approxfreqratio"
43
42
  "fetkutils-amberti2img.py" = "fetkutils.scripts:fetkutils_amberti2img"
44
43
 
45
- [tool.setuptools]
46
- package-dir = {"" = "src/python/lib"}
44
+ [tool.scikit-build]
45
+ experimental = true
46
+ wheel.platlib = false
47
+
48
+
49
+ # Defines where the library code lives
50
+ wheel.packages = [
51
+ "src/python/lib/fetkutils",
52
+ ]
53
+ wheel.install-dir = "fetkutils"
@@ -0,0 +1,8 @@
1
+ project(fetkutils_python)
2
+
3
+ if (IS_AMBERTOOLS)
4
+ install_python_library()
5
+ else()
6
+ find_package(Python3 COMPONENTS Interpreter REQUIRED)
7
+ install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} -m pip install --prefix=${CMAKE_INSTALL_PREFIX} ${CMAKE_CURRENT_SOURCE_DIR})")
8
+ endif()
@@ -0,0 +1,339 @@
1
+ #!/usr/bin/env python3
2
+
3
+
4
+ def show_atom_number(mol, label, offset):
5
+ for atom in mol.GetAtoms():
6
+ atom.SetProp(label, str(atom.GetIdx()+1+offset))
7
+ return mol
8
+
9
+
10
+ def GetSelectedAtomIndices(param,maskstr):
11
+ import parmed
12
+ sele = []
13
+ if len(maskstr) > 0:
14
+ newmaskstr = maskstr.replace("@0","!@*")
15
+ sele = [ param.atoms[i].idx for i in parmed.amber.mask.AmberMask( param, newmaskstr ).Selected() ]
16
+ return sele
17
+
18
+
19
+ class Ligand(object):
20
+ def __init__(self, mdin, parmfile, rstfile, image_loc, edge_name, showidxs, size, absfe=False):
21
+ """ This is a class to generate an image of a ligand with softcore atoms highlighted
22
+
23
+ Parameters
24
+ ----------
25
+ mdin : str
26
+ Path to the mdin mdin file [mdin]
27
+ parmfile : str
28
+ Path to the parameter file [parm7]
29
+ rstfile : str
30
+ Path to the restart file [rst7]
31
+ image_loc : str
32
+ Path to the directory where the images will be saved
33
+ edge_name : str
34
+ Name of the edge (e.g. 0~1)
35
+ showidxs : bool
36
+ If True, show the atom indexes in the image
37
+ size : tuple of int
38
+ The image size in pixels.
39
+
40
+ Returns
41
+ -------
42
+ None
43
+
44
+ Raises
45
+ ------
46
+ FileNotFoundError
47
+ If the mdin, parmfile, or rstfile does not exist
48
+
49
+
50
+ """
51
+ from pathlib import Path
52
+
53
+ if absfe:
54
+ self.resstop=1
55
+ else:
56
+ self.resstop=2
57
+
58
+
59
+ self.mdin = Path(mdin)
60
+ self.parmfile = Path(parmfile)
61
+ self.rstfile = Path(rstfile)
62
+ self.softcore = []
63
+ self.timask = []
64
+ self.image_loc = Path(image_loc)
65
+ self.edge_name = edge_name
66
+ self.showidxs = showidxs
67
+ self.size = size
68
+ if not self.mdin.exists():
69
+ raise FileNotFoundError(f"{self.mdin} does not exist")
70
+ if not self.parmfile.exists():
71
+ raise FileNotFoundError(f"{self.parmfile} does not exist")
72
+ if not self.rstfile.exists():
73
+ raise FileNotFoundError(f"{self.rstfile} does not exist")
74
+ if "~" not in self.edge_name:
75
+ raise Exception(f"Edge name {self.edge_name} does not contain '~'")
76
+ else:
77
+ ligs = self.edge_name.split("~")
78
+ if len(ligs) != 2:
79
+ raise Exception(f"Could interpret edge name {self.edge_name} as 2 ligands: {ligs}")
80
+
81
+
82
+ def run(self):
83
+ """ This function runs the class and generates the images """
84
+ self.parm = self._read_parm()
85
+ self._find_softcore()
86
+ ti_only, sc_only, ti_all = [], [], []
87
+ for i in range(len(self.softcore)):
88
+ ti_only.append(self._find_difference(self.softcore[i], self.timask[i]))
89
+ sc_only.append(self._parse_range(self.softcore[i]))
90
+ ti_all.append(self._parse_range(self.timask[i]))
91
+
92
+ self.ti_only = ti_only
93
+ self.sc_only = sc_only
94
+ self.ti_all = ti_all
95
+ self._write_2d_structure()
96
+ return
97
+
98
+ def _read_parm(self):
99
+ """ This function reads the parameter and restart files and returns a parameter file object"""
100
+ import parmed
101
+ parm = None
102
+ try:
103
+ parm = parmed.load_file(str(self.parmfile))
104
+ parm.load_rst7(str(self.rstfile))
105
+ except Exception as e:
106
+ raise RuntimeError(f"Failed to read parameter or restart file: {e}")
107
+ return parm
108
+
109
+ def _write_2d_structure(self):
110
+ """ This function writes the 2D structure of the ligand with the softcore atoms highlighted
111
+
112
+ Parameters
113
+ ----------
114
+ parm : parmed.Structure
115
+ A parmed structure object
116
+
117
+ Returns
118
+ -------
119
+ None
120
+
121
+ TODO
122
+ ----
123
+ This function should be modified to check charges on the ligands.
124
+
125
+ """
126
+ import rdkit
127
+ from rdkit import Chem
128
+ from rdkit.Chem import Draw, rdDetermineBonds
129
+ from pathlib import Path
130
+
131
+ ligand_resnames = [res.name for res in self.parm.residues[0:self.resstop]]
132
+ fake_pdb = FakeFile()
133
+ self.parm.write_pdb(fake_pdb)
134
+ for i, mol in enumerate(ligand_resnames):
135
+ mol_content = fake_pdb.getvalue(mask=[mol])
136
+ rdmol = Chem.MolFromPDBBlock(mol_content, removeHs=False)
137
+
138
+ q1 = round(sum([atom.charge for atom in self.parm.residues[i].atoms]))
139
+
140
+ rdDetermineBonds.DetermineBonds(rdmol,charge=q1)
141
+
142
+ Chem.rdDepictor.SetPreferCoordGen(True)
143
+
144
+ Chem.rdDepictor.Compute2DCoords(rdmol)
145
+ sc = [idx - min(self.ti_all[i]) for idx in self.sc_only[i]]
146
+
147
+ img = Draw.rdMolDraw2D.MolDraw2DCairo(*self.size)
148
+ opts = img.drawOptions()
149
+ opts.baseFontSize = 0.46
150
+ opts.useMolBlockWedging = True
151
+ opts.singleColourWedgeBonds = True
152
+ opts.highlightBondWidthMultiplier = 12
153
+
154
+ img.DrawMolecule(rdmol,highlightAtoms=sc)
155
+ img.FinishDrawing()
156
+ node_names = self.edge_name.split('~')
157
+
158
+ Path(self.image_loc).mkdir(parents=True, exist_ok=True)
159
+
160
+ with open(f"{self.image_loc}/{self.edge_name}_{node_names[i]}.png",'wb') as f:
161
+ f.write(img.GetDrawingText())
162
+
163
+
164
+ if self.showidxs:
165
+
166
+
167
+ offset = self.parm.residues[i].atoms[0].idx
168
+ #show_atom_number(rdmol,'molAtomMapNumber')
169
+ show_atom_number(rdmol,'atomLabel',offset)
170
+ img = Draw.rdMolDraw2D.MolDraw2DCairo(*self.size)
171
+ opts = img.drawOptions()
172
+ opts.baseFontSize = 0.42
173
+ opts.useMolBlockWedging = True
174
+ opts.singleColourWedgeBonds = True
175
+ opts.highlightBondWidthMultiplier = 12
176
+
177
+ img.DrawMolecule(rdmol,highlightAtoms=sc)
178
+ img.FinishDrawing()
179
+ node_names = self.edge_name.split('~')
180
+ with open(f"{self.image_loc}/{self.edge_name}_{node_names[i]}_idxs.png",'wb') as f:
181
+ f.write(img.GetDrawingText())
182
+
183
+ return
184
+
185
+ def _find_softcore(self):
186
+ """ This function finds the softcore atoms from the mdin file """
187
+ with self.mdin.open() as f:
188
+ for line in f:
189
+ if "scmask" in line:
190
+ line = line.split('!')[0].strip()
191
+ key,value = line.split('=')
192
+ value=value.strip()
193
+ self.softcore.append(value)
194
+ if "timask" in line:
195
+ line = line.split('!')[0].strip()
196
+ key,value = line.split('=')
197
+ value=value.strip()
198
+ self.timask.append(value)
199
+
200
+ def _parse_range(self, mask):
201
+ value=mask.strip()
202
+ if value[0] == "\"" and value[1] == "\"":
203
+ value = value[1:-1]
204
+ if value[0] == "'":
205
+ value = value[1:]
206
+ if value[-1] == "'":
207
+ value = value[:-1]
208
+ atomids = [idx+1 for idx in GetSelectedAtomIndices(self.parm,value)]
209
+ return atomids
210
+
211
+
212
+ def _find_difference(self, list1, list2):
213
+ """ This function finds the difference between two sets """
214
+ set1 = set()
215
+ set2 = set()
216
+ set1.update(self._parse_range(list1))
217
+ set2.update(self._parse_range(list2))
218
+ return sorted(set2-set1)
219
+
220
+ class FakeFile(object):
221
+ def __init__(self):
222
+ """ This is a fake file class to capture the output of parmed.write_pdb """
223
+ self.content = ""
224
+
225
+ def write(self, text):
226
+ """ This function writes the text to the content
227
+
228
+ Parameters
229
+ ----------
230
+ text : str
231
+ The text to write to the content
232
+
233
+ """
234
+ self.content += text
235
+
236
+ def getvalue(self, mask=None):
237
+ """ This function returns the content of the file
238
+
239
+ Parameters
240
+ ----------
241
+ mask : list
242
+ A list of strings to filter the content
243
+
244
+ Returns
245
+ -------
246
+ str
247
+ The content of the file
248
+
249
+ """
250
+ content = []
251
+ if mask == None:
252
+ return self.content
253
+ for line in self.content.split('\n'):
254
+ for elem in mask:
255
+ if elem in line:
256
+ content.append(line)
257
+ content = '\n'.join(content)
258
+ return content
259
+
260
+
261
+ if __name__ == "__main__":
262
+
263
+ import argparse
264
+
265
+ parser = argparse.ArgumentParser(
266
+ formatter_class=argparse.RawDescriptionHelpFormatter,
267
+ description="""Reads a pmemd mdin file, rst7 coordinate file, amber parameter (parm7) file, and writes chemical structures of the first 2 residues. The atoms within the softcore regions are highlighted.
268
+ """)
269
+
270
+ parser.add_argument \
271
+ ("-i","--mdin",
272
+ type=str,
273
+ required=True,
274
+ help="A pmemd mdin file containing scmask and timask setting within the cntrl namelist")
275
+
276
+ parser.add_argument \
277
+ ("-p","--parm",
278
+ type=str,
279
+ required=True,
280
+ help="An Amber parameter (parm7) file")
281
+
282
+ parser.add_argument \
283
+ ("-c","--crd",
284
+ type=str,
285
+ required=True,
286
+ help="A formatted Amber restart coordinate (rst7) file")
287
+
288
+ parser.add_argument \
289
+ ("-e","--edge",
290
+ type=str,
291
+ required=True,
292
+ help="Name of the edge. It should be formatted like 'lig1~lig2'")
293
+
294
+ parser.add_argument \
295
+ ("--imgdir",
296
+ type=str,
297
+ default=".",
298
+ help="The directory where the image is written to. Default: .")
299
+
300
+ parser.add_argument \
301
+ ("--showidxs",
302
+ action='store_true',
303
+ help="If present, write a second image showing the atom indexes rather than element symbols")
304
+
305
+ parser.add_argument \
306
+ ("--width",
307
+ type=int,
308
+ default=400,
309
+ help="Width of the image in pixels. Default: 400")
310
+
311
+ parser.add_argument \
312
+ ("--height",
313
+ type=int,
314
+ default=-1,
315
+ help="Height of the image in pixels. Default: -1, which assumes the same value as --width")
316
+
317
+ parser.add_argument \
318
+ ("--absfe",
319
+ action='store_true',
320
+ help="If true, then only read the first ligand")
321
+
322
+
323
+
324
+ args = parser.parse_args()
325
+
326
+ size = (args.width,args.height)
327
+
328
+ ligand = Ligand(args.mdin,
329
+ args.parm,
330
+ args.crd,
331
+ args.imgdir,
332
+ args.edge,
333
+ args.showidxs,
334
+ size,
335
+ absfe=args.absfe)
336
+
337
+ ligand.run()
338
+
339
+