phbuilder 1.2.4__tar.gz → 1.2.5__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 (44) hide show
  1. {phbuilder-1.2.4 → phbuilder-1.2.5}/PKG-INFO +11 -16
  2. {phbuilder-1.2.4 → phbuilder-1.2.5}/README.md +8 -15
  3. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/lambdagrouptypes.dat +1 -1
  4. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/parsecmdline.py +9 -2
  5. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/phbuilder.py +51 -13
  6. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/sanitize.py +45 -8
  7. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/PKG-INFO +11 -16
  8. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/requires.txt +2 -0
  9. {phbuilder-1.2.4 → phbuilder-1.2.5}/pyproject.toml +2 -1
  10. {phbuilder-1.2.4 → phbuilder-1.2.5}/setup.cfg +3 -1
  11. {phbuilder-1.2.4 → phbuilder-1.2.5}/LICENSE +0 -0
  12. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/__init__.py +0 -0
  13. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/README.md +0 -0
  14. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/atomtypes.atp +0 -0
  15. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/cmap.itp +0 -0
  16. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/ffbonded.itp +0 -0
  17. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/ffnonbonded.itp +0 -0
  18. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/forcefield.doc +0 -0
  19. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/forcefield.itp +0 -0
  20. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/gb.itp +0 -0
  21. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/ions.itp +0 -0
  22. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.arn +0 -0
  23. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.c.tdb +0 -0
  24. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.hdb +0 -0
  25. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.n.tdb +0 -0
  26. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.r2b +0 -0
  27. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.rtp +0 -0
  28. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/merged.vsd +0 -0
  29. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/nbfix.itp +0 -0
  30. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/old_c36_cmap.itp +0 -0
  31. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/popc.itp +0 -0
  32. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/spc.itp +0 -0
  33. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/spce.itp +0 -0
  34. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/tip3p.itp +0 -0
  35. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/tip4p.itp +0 -0
  36. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/charmm36-mar2019-cphmd.ff/watermodels.dat +0 -0
  37. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/ffield/residuetypes.dat +0 -0
  38. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/mdp.py +0 -0
  39. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/structure.py +0 -0
  40. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder/user.py +0 -0
  41. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/SOURCES.txt +0 -0
  42. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/dependency_links.txt +0 -0
  43. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/entry_points.txt +0 -0
  44. {phbuilder-1.2.4 → phbuilder-1.2.5}/phbuilder.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phbuilder
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: System builder for constant-pH simulations in GROMACS.
5
5
  Home-page: https://gitlab.com/gromacs-constantph/phbuilder
6
6
  Author: Anton Jansen
@@ -18,6 +18,8 @@ Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: argcomplete>=3.1.1
20
20
  Requires-Dist: configparser>=6.0.0
21
+ Requires-Dist: sympy>=1.12
22
+ Requires-Dist: numpy
21
23
 
22
24
  <div style="width: 830px">
23
25
 
@@ -239,7 +241,7 @@ gmx cphmd -s MD.tpr -e MD.edr -numplot 1
239
241
 
240
242
  # Performing titrations
241
243
 
242
- Performing a computational titration is helpful for determining the microscopic pKas of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
244
+ Performing a computational titration is helpful for determining the pKa shifts of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
243
245
 
244
246
  ```
245
247
  create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -nr 2
@@ -247,21 +249,13 @@ create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -n
247
249
 
248
250
  creates directories corresponding to pH 1 to 9, with each subdirectory containing two replicates (each containing the appropriate input files for `gmx mdrun`).
249
251
 
250
- **NOTE** `create_titration.py` currently requires small modifications of `MD.mdp` file. In case of multisite groups (e.g. histidine), one of the $\lambda$-coordinates (usually the first coordinate associated with the multisite group) should have pH value equal to $\text{p}K_\text{a}$ (check [manual](https://gitlab.com/gromacs-constantph/constantph/-/blob/main/manual/constantph_usage.md)). To achieve this, `create_titration.py` searches through the **.mdp** file, and if it sees pH and $\text{p}K_\text{a}$ in one line, it replaces pH with actual numeric value. This will ensure the correct set up at all pH values. To give an example:
251
- ```
252
- lambda-dynamics-group-type3-state-1-reference-pka = pH
253
- ```
254
- this line will be sequentially changed to
252
+ The minor change is at step 7. When parameters are generated, `phbuilder genparams` needs to be called with the `-titr` option:
253
+
255
254
  ```
256
- lambda-dynamics-group-type3-state-1-reference-pka = 1.0
257
- lambda-dynamics-group-type3-state-1-reference-pka = 2.0
258
- lambda-dynamics-group-type3-state-1-reference-pka = 3.0
259
- ...
255
+ phbuilder genparams -f phneutral.pdb -ph 4.0 -titr
260
256
  ```
261
- in the corresponding folders.
262
-
263
257
 
264
- **NOTE** This behaviour will change in the next release of the code.
258
+ This will set the pH value to the string "ph", as well as all pH-dependent terms for pKa values in multisite groups (e.g. $\lambda_1$ of histidine). Those pH-dependent strings will be read by `create_titration.py` and modified according to the pH value for a particular somulation. Note however that a pH value is still required to be passed as input to `phbuilder genparams`. Minimization and equilibration files will be generated for this provided pH.
265
259
 
266
260
  # Performing parameterizations
267
261
 
@@ -567,7 +561,7 @@ OPTIONS
567
561
  |--------------|----------------|
568
562
  | `-f` | [\<.pdb/.gro>] (required) <br /> Specify input structure file. |
569
563
  | `-o` | [\<.pdb/.gro>] (phprocessed.pdb) <br /> Specify output structure file. |
570
- | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the macroscopic pKas of the titratable sites to auto set the initial lambdas. |
564
+ | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the reference pKas of the titratable sites to auto set the initial lambdas. |
571
565
  | `-v` | (no) <br /> Be more verbose. |
572
566
 
573
567
  # Synopsis `phbuilder neutralize`
@@ -604,7 +598,7 @@ Adds the appropriate number of ions to ensure a net-neutral system at t=0, and a
604
598
  # Synopsis `phbuilder genparams`
605
599
 
606
600
  ```
607
- phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-cal] [-v]
601
+ phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-titr] [-cal] [-v]
608
602
  ```
609
603
 
610
604
  ### DESCRIPTION
@@ -622,6 +616,7 @@ Generates the CpHMD-specific `.mdp` and `.ndx` files. Will write generic EM.mdp
622
616
  | `-nstout` | [\<int>] (500) <br /> Specify lambda coordinate output frequency. 500 is large enough for subsequent frames to be uncoupled (with a $dt = 0.002$).
623
617
  | `-dwpE` | [\<float>] (7.5) <br /> Specify default height of bias potential barrier (kJ/mol).
624
618
  | `-inter` | (no) <br /> Interactively set the height of the bias potential barrier (kJ/mol) for every titratable site.
619
+ | `-titr` | (no) <br /> Prepare files for running titrations with CpHMD: forces pH to be set to "ph" and ph-dependent pKa values to be written to MD.mdp as string. The `create_titration.py` script will further modify those entries according to the currently set ph. |
625
620
  | `-cal` | (no) <br /> Run CpHMD simulation in calibration mode: forces on the lambda coordinates are computed, but their positions won't be updated. This is only used for parameterization purposes. |
626
621
  | `-v` | (no) <br /> Be more verbose. |
627
622
 
@@ -218,7 +218,7 @@ gmx cphmd -s MD.tpr -e MD.edr -numplot 1
218
218
 
219
219
  # Performing titrations
220
220
 
221
- Performing a computational titration is helpful for determining the microscopic pKas of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
221
+ Performing a computational titration is helpful for determining the pKa shifts of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
222
222
 
223
223
  ```
224
224
  create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -nr 2
@@ -226,21 +226,13 @@ create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -n
226
226
 
227
227
  creates directories corresponding to pH 1 to 9, with each subdirectory containing two replicates (each containing the appropriate input files for `gmx mdrun`).
228
228
 
229
- **NOTE** `create_titration.py` currently requires small modifications of `MD.mdp` file. In case of multisite groups (e.g. histidine), one of the $\lambda$-coordinates (usually the first coordinate associated with the multisite group) should have pH value equal to $\text{p}K_\text{a}$ (check [manual](https://gitlab.com/gromacs-constantph/constantph/-/blob/main/manual/constantph_usage.md)). To achieve this, `create_titration.py` searches through the **.mdp** file, and if it sees pH and $\text{p}K_\text{a}$ in one line, it replaces pH with actual numeric value. This will ensure the correct set up at all pH values. To give an example:
230
- ```
231
- lambda-dynamics-group-type3-state-1-reference-pka = pH
232
- ```
233
- this line will be sequentially changed to
229
+ The minor change is at step 7. When parameters are generated, `phbuilder genparams` needs to be called with the `-titr` option:
230
+
234
231
  ```
235
- lambda-dynamics-group-type3-state-1-reference-pka = 1.0
236
- lambda-dynamics-group-type3-state-1-reference-pka = 2.0
237
- lambda-dynamics-group-type3-state-1-reference-pka = 3.0
238
- ...
232
+ phbuilder genparams -f phneutral.pdb -ph 4.0 -titr
239
233
  ```
240
- in the corresponding folders.
241
-
242
234
 
243
- **NOTE** This behaviour will change in the next release of the code.
235
+ This will set the pH value to the string "ph", as well as all pH-dependent terms for pKa values in multisite groups (e.g. $\lambda_1$ of histidine). Those pH-dependent strings will be read by `create_titration.py` and modified according to the pH value for a particular somulation. Note however that a pH value is still required to be passed as input to `phbuilder genparams`. Minimization and equilibration files will be generated for this provided pH.
244
236
 
245
237
  # Performing parameterizations
246
238
 
@@ -546,7 +538,7 @@ OPTIONS
546
538
  |--------------|----------------|
547
539
  | `-f` | [\<.pdb/.gro>] (required) <br /> Specify input structure file. |
548
540
  | `-o` | [\<.pdb/.gro>] (phprocessed.pdb) <br /> Specify output structure file. |
549
- | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the macroscopic pKas of the titratable sites to auto set the initial lambdas. |
541
+ | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the reference pKas of the titratable sites to auto set the initial lambdas. |
550
542
  | `-v` | (no) <br /> Be more verbose. |
551
543
 
552
544
  # Synopsis `phbuilder neutralize`
@@ -583,7 +575,7 @@ Adds the appropriate number of ions to ensure a net-neutral system at t=0, and a
583
575
  # Synopsis `phbuilder genparams`
584
576
 
585
577
  ```
586
- phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-cal] [-v]
578
+ phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-titr] [-cal] [-v]
587
579
  ```
588
580
 
589
581
  ### DESCRIPTION
@@ -601,6 +593,7 @@ Generates the CpHMD-specific `.mdp` and `.ndx` files. Will write generic EM.mdp
601
593
  | `-nstout` | [\<int>] (500) <br /> Specify lambda coordinate output frequency. 500 is large enough for subsequent frames to be uncoupled (with a $dt = 0.002$).
602
594
  | `-dwpE` | [\<float>] (7.5) <br /> Specify default height of bias potential barrier (kJ/mol).
603
595
  | `-inter` | (no) <br /> Interactively set the height of the bias potential barrier (kJ/mol) for every titratable site.
596
+ | `-titr` | (no) <br /> Prepare files for running titrations with CpHMD: forces pH to be set to "ph" and ph-dependent pKa values to be written to MD.mdp as string. The `create_titration.py` script will further modify those entries according to the currently set ph. |
604
597
  | `-cal` | (no) <br /> Run CpHMD simulation in calibration mode: forces on the lambda coordinates are computed, but their positions won't be updated. This is only used for parameterization purposes. |
605
598
  | `-v` | (no) <br /> Be more verbose. |
606
599
 
@@ -22,7 +22,7 @@ dvdl_1 = 59.636 -429.770 514.370 -204.910 -558.210 27.157
22
22
  incl = HIS HIS1 HISA HISB HISH HISD HISE HISP HSD HSE HSP
23
23
  atoms = CB CD2 HD2 CG NE2 HE2 ND1 HD1 CE1 HE1
24
24
  qqA = 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
25
- pKa_1 = 0.0
25
+ pKa_1 = ph
26
26
  qqB_1 = -0.05 0.19 0.13 0.19 -0.51 0.44 -0.51 0.44 0.32 0.18
27
27
  dvdl_1 = -3015.4 -13444.1 -34779. -44335.5 -31383.1 -13684.4 -4905.57 106.148 -484.107 11865.5 48985.4 104163. 103612. 59628.7 25794.9 3490.9 2180.34 -18552.6 -70083.6 -117174. -91492.5 -47959.2 -12542.4 -3968.74 14751.8 49997.8 63417.3 42048.3 16441.1 3929.98 -6193.44 -18113.5 -17591.7 -9832.74 -2246.33 934.809 2225.21 1887.54 594.263 402.485 604.077 158.757 -463.471 -193.458 82.6296
28
28
  pKa_2 = 6.53
@@ -16,7 +16,7 @@ def parsecmdline():
16
16
  desc_1 = "System builder for constant-pH simulations in GROMACS. phbuilder consists of three tools: gentopol, neutralize, and genparams. Each tool performs a specific task for preparing a constant-pH simulation. Functionality for setting up titrations and parameterizations is provided with the help of stand-alone Python scripts, provided on the gitlab. Out of the box, phbuilder comes with the force field and CpHMD topology parameters required for setting up titratable Arg, Lys, Asp, Glu, and His residues in CHARMM36m."
17
17
 
18
18
  # Epilogue. Also used by subcommands.
19
- desc_2 = "phbuilder VERSION 1.2.4. For the user manual visit https://gitlab.com/gromacs-constantph/phbuilder."
19
+ desc_2 = "phbuilder VERSION 1.2.5. For the user manual visit https://gitlab.com/gromacs-constantph/phbuilder."
20
20
 
21
21
  # gentopol main description.
22
22
  desc_3 = "Allows you to select which residues to make titratable and which initial lambda (protonation) state they should have. Also (re)generates the system topology using the modified CHARMM36m force field. If you don't want to manually set initial lambda values, you can use the -ph flag to have gentopol automatically choose the appropriate initial lambda values, based on the criterion: pH > pKa means start deprotonated, else start protonated."
@@ -51,7 +51,7 @@ def parsecmdline():
51
51
  required=False,
52
52
  dest='ph',
53
53
  action='store',
54
- help='[<float>] Specify intended simulation pH. Will be used together with the macroscopic pKas of the titratable sites to auto set the initial lambdas.',
54
+ help='[<float>] Specify intended simulation pH. Will be used together with the reference pKas of the titratable sites to auto set the initial lambdas.',
55
55
  type=float)
56
56
 
57
57
  parser_1.add_argument('-v',
@@ -197,6 +197,13 @@ def parsecmdline():
197
197
  const=1,
198
198
  help='(no) Interactively set the height of the bias potential barrier (kJ/mol) for every titratable site.')
199
199
 
200
+ parser_3.add_argument('-titr',
201
+ required=False,
202
+ dest='titr',
203
+ action='store_const',
204
+ const=1,
205
+ help="(no) Prepare files for CpHMD titration. This will leave all pH-dependent pKa values as they are in lambdagrouptypes.dat. Those will be further modified by the create_titration.py script.")
206
+
200
207
  parser_3.add_argument('-cal',
201
208
  required=False,
202
209
  dest='cal',
@@ -2,6 +2,9 @@ import configparser
2
2
  import subprocess
3
3
  import os
4
4
 
5
+ from sympy.parsing.sympy_parser import parse_expr
6
+ from sympy import symbols
7
+
5
8
  from .user import User
6
9
  from .sanitize import Sanitize
7
10
  from .structure import Structure
@@ -106,6 +109,12 @@ class phbuilder(User):
106
109
  else:
107
110
  self.ph_inter = False
108
111
 
112
+ # Process whether the -titr flag was or wasn't set.
113
+ if CLI.titr is not None:
114
+ self.titr = True
115
+ else:
116
+ self.titr = False
117
+
109
118
  # Process whether the -cal flag was or wasn't set.
110
119
  if CLI.cal is not None:
111
120
  self.ph_cal = True
@@ -223,10 +232,13 @@ class phbuilder(User):
223
232
  pKa = []
224
233
  qqB = []
225
234
  dvdl = []
226
- for idx in range(1, 11): # Max 10 multisites
235
+ # We iterate over the residue description as we don't know how many states we have.
236
+ # for loop over max 100 multistates. Do not use while True to prevent potential infinite loop.
237
+ for idx in range(1, 101):
227
238
  try:
228
- # Parse pKa(s)
229
- pKa.append(float(parser.get(sect, 'pKA_{}'.format(idx))))
239
+ # Parse pKa(s). Note: we are not converting pKa values here
240
+ # as there might be a dependence on pH.
241
+ pKa.append(parser.get(sect, 'pKA_{}'.format(idx)).lower())
230
242
 
231
243
  # Parse qqB(s)
232
244
  qqB.append(str2floatList(parser.get(sect, 'qqB_{}'.format(idx))))
@@ -242,7 +254,7 @@ class phbuilder(User):
242
254
  incl = [Sanitize(val, f"incl for {groupname} in lambdagrouptypes.dat").string(Range=[2, 4], upper=True) for val in incl]
243
255
  atoms = [Sanitize(val, f"atoms for {groupname} in lambdagrouptypes.dat").string(Range=[1, 4], upper=True) for val in atoms]
244
256
  qqA = [Sanitize(val, f"qqA for {groupname} in lambdagrouptypes.dat").num() for val in qqA]
245
- pKa = [Sanitize(val, f"pKa for {groupname} in lambdagrouptypes.dat").num(Range=[0, 14]) for val in pKa]
257
+ pKa = [Sanitize(val, f"pKa for {groupname} in lambdagrouptypes.dat").pka_string(Range=[0, 14]) for val in pKa]
246
258
 
247
259
  for array in qqB:
248
260
  for val in array:
@@ -1055,7 +1067,10 @@ class phbuilder(User):
1055
1067
  file.write("\n; CONSTANT PH\n")
1056
1068
 
1057
1069
  addParam('lambda-dynamics', 'yes')
1058
- addParam('lambda-dynamics-simulation-ph', self.ph_ph)
1070
+ if Type == "MD" and self.titr:
1071
+ addParam('lambda-dynamics-simulation-ph', 'ph')
1072
+ else:
1073
+ addParam('lambda-dynamics-simulation-ph', self.ph_ph)
1059
1074
  addParam('lambda-dynamics-lambda-particle-mass', "{:.1f}".format(5.0)) # lmass is hardcoded to 5.0 (amu).
1060
1075
  addParam('lambda-dynamics-tau', "{:.1f}".format(2.0)) # ltau is hardcoded to 2.0 (ps).
1061
1076
  addParam('lambda-dynamics-update-nst', self.ph_nstout)
@@ -1123,10 +1138,14 @@ class phbuilder(User):
1123
1138
  for idx in range(1, multistates + 1):
1124
1139
  # When we have a multistate lambdagrouptype, one of the pKas should
1125
1140
  # be equal to the simulation-pH. This is done by setting this pKa
1126
- # to zero in the lambdagrouptypes.dat file.
1127
- pKaNew = pKa[idx - 1]
1128
- if multistates > 1 and float(pKaNew) == 0.0:
1129
- pKaNew = self.ph_ph
1141
+ # to ph in the lambdagrouptypes.dat file.
1142
+
1143
+ if Type == "MD" and self.titr:
1144
+ pKaNew = pKa[idx - 1]
1145
+ else:
1146
+ # Do some symbol maths
1147
+ ph = symbols("ph")
1148
+ pKaNew = float(parse_expr(pKa[idx - 1], evaluate=False).subs(ph, self.ph_ph))
1130
1149
 
1131
1150
  addParam('lambda-dynamics-group-type{}-state-{}-charges'.format(number, idx), to_string(qqB[idx - 1]))
1132
1151
  addParam('lambda-dynamics-group-type{}-state-{}-reference-pka'.format(number, idx), pKaNew)
@@ -1165,7 +1184,7 @@ class phbuilder(User):
1165
1184
  1,
1166
1185
  [qqA],
1167
1186
  [[qqB]],
1168
- [0],
1187
+ ['0'],
1169
1188
  [self.ph_BUF_dvdl]
1170
1189
  )
1171
1190
 
@@ -1259,9 +1278,19 @@ class phbuilder(User):
1259
1278
 
1260
1279
  def writeTheGroup(number, atomIndexList):
1261
1280
  """Formatting function for writing the index block."""
1281
+
1262
1282
  file.write('\n[ LAMBDA{} ]\n'.format(number))
1283
+
1284
+ idxPerLine = 0
1285
+
1263
1286
  for index in atomIndexList:
1264
1287
  file.write('{} '.format(index))
1288
+
1289
+ idxPerLine += 1
1290
+ if idxPerLine == 15:
1291
+ file.write('\n')
1292
+ idxPerLine = 0
1293
+
1265
1294
  file.write('\n')
1266
1295
 
1267
1296
  atomCount = 1
@@ -1395,16 +1424,25 @@ class phbuilder(User):
1395
1424
  # multistate case
1396
1425
  if len(pKaList) > 1:
1397
1426
 
1427
+ # Do some symbol maths
1428
+ ph = symbols("ph")
1429
+ pKa_vals = [
1430
+ float(
1431
+ parse_expr(x, evaluate=False).subs(ph, systempH)
1432
+ ) for x in pKaList
1433
+ ]
1434
+
1398
1435
  highest = 0
1399
- for pKa in pKaList:
1436
+ for pKa in pKa_vals:
1437
+
1400
1438
  if pKa <= systempH and pKa > highest:
1401
1439
  highest = pKa
1402
1440
 
1403
- return pKaList.index(highest) + 1
1441
+ return pKa_vals.index(highest) + 1
1404
1442
 
1405
1443
  #2state case
1406
1444
  else:
1407
- if systempH >= pKaList[0]:
1445
+ if systempH >= float(pKaList[0]):
1408
1446
  return 1 # if pH >= pKa, we are in deproto = 1 state.
1409
1447
 
1410
1448
  return 0 # if pH < pKa, we are in the proto = 0 state.
@@ -91,6 +91,40 @@ class Sanitize:
91
91
 
92
92
  return self.__endbehavior()
93
93
 
94
+ def pka_string(self, Range: list = []):
95
+ """Sanitize strings that describe pka values for lambda coordinate.
96
+ The rule is, if <ph> not in string, then we should be within range.
97
+
98
+ Args:
99
+ Type (Any, optional): (list of) acceptable type(s). Defaults to None.
100
+ Range (list, optional): acceptable interval. Defaults to [].
101
+ signed (bool, optional): Signed or unsigned. Defaults to False.
102
+
103
+ Returns:
104
+ int: exitcode.
105
+ """
106
+
107
+ # Confirm whether var is a string.
108
+ if not isinstance(self.var, str):
109
+ self.__error(f'should be of type {str}')
110
+
111
+ # Check if ph in var
112
+ if 'ph' in self.var:
113
+ # Do nothing
114
+ return self.__endbehavior()
115
+
116
+ # Try converting to string
117
+ try:
118
+ float(self.var)
119
+ except ValueError:
120
+ self.__error('should be convertible to float or have "ph"')
121
+
122
+ # Check range.
123
+ if Range and (float(self.var) < Range[0] or float(self.var) > Range[1]):
124
+ self.__error(f'outside of acceptable interval {Range}')
125
+
126
+ return self.__endbehavior()
127
+
94
128
  def string(self, Range: list = [], upper: bool = False, lower: bool = False, ws: bool = True):
95
129
  """sanitize strings (str).
96
130
 
@@ -161,17 +195,20 @@ class Sanitize:
161
195
  if type(ext) != list:
162
196
  ext = [ext]
163
197
 
164
- if tail.count(' ') != 0:
165
- self.__error('cannot contain whitespace')
198
+ # Add "." to extensions if not present.
199
+ for idx in range(len(ext)):
200
+ if ext[idx][0] != ".":
201
+ ext[idx] = "." + ext[idx]
166
202
 
167
- if (tail.count('.') == 0) or (tail.count('.') > 1) or (tail[-1] == '.'):
168
- self.__error(f'ambiguous extension (should be {ext})')
203
+ # Comment this because file names can contain whitespace in linux.
204
+ # if tail.count(" ") != 0:
205
+ # self.__error("cannot contain whitespace")
169
206
 
170
- elif tail.index('.') == 0:
171
- self.__error('cannot be just an extension')
207
+ if "." not in tail or (tail.index(".") == 0 and tail.count(".") == 1):
208
+ self.__error(f"does not have a file extension (should be {ext})")
172
209
 
173
- elif tail[tail.index('.'):] not in ext:
174
- self.__error(f'should have extension {ext}')
210
+ elif "." + tail.split(".")[-1] not in ext:
211
+ self.__error(f"should have extension {ext}")
175
212
 
176
213
  # Check absolute file path.
177
214
  if abs and not os.path.isabs(self.var):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: phbuilder
3
- Version: 1.2.4
3
+ Version: 1.2.5
4
4
  Summary: System builder for constant-pH simulations in GROMACS.
5
5
  Home-page: https://gitlab.com/gromacs-constantph/phbuilder
6
6
  Author: Anton Jansen
@@ -18,6 +18,8 @@ Description-Content-Type: text/markdown
18
18
  License-File: LICENSE
19
19
  Requires-Dist: argcomplete>=3.1.1
20
20
  Requires-Dist: configparser>=6.0.0
21
+ Requires-Dist: sympy>=1.12
22
+ Requires-Dist: numpy
21
23
 
22
24
  <div style="width: 830px">
23
25
 
@@ -239,7 +241,7 @@ gmx cphmd -s MD.tpr -e MD.edr -numplot 1
239
241
 
240
242
  # Performing titrations
241
243
 
242
- Performing a computational titration is helpful for determining the microscopic pKas of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
244
+ Performing a computational titration is helpful for determining the pKa shifts of titratable sites. After steps 1 to 9 of the basic workflow have been completed, one can use the included [create_titration.py](scripts/create_titration.py) to setup a titration. For example, the command:
243
245
 
244
246
  ```
245
247
  create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -nr 2
@@ -247,21 +249,13 @@ create_titration.py -f MD.mdp -c NPT.pdb -p topol.top -n index.ndx -pH 1:10:1 -n
247
249
 
248
250
  creates directories corresponding to pH 1 to 9, with each subdirectory containing two replicates (each containing the appropriate input files for `gmx mdrun`).
249
251
 
250
- **NOTE** `create_titration.py` currently requires small modifications of `MD.mdp` file. In case of multisite groups (e.g. histidine), one of the $\lambda$-coordinates (usually the first coordinate associated with the multisite group) should have pH value equal to $\text{p}K_\text{a}$ (check [manual](https://gitlab.com/gromacs-constantph/constantph/-/blob/main/manual/constantph_usage.md)). To achieve this, `create_titration.py` searches through the **.mdp** file, and if it sees pH and $\text{p}K_\text{a}$ in one line, it replaces pH with actual numeric value. This will ensure the correct set up at all pH values. To give an example:
251
- ```
252
- lambda-dynamics-group-type3-state-1-reference-pka = pH
253
- ```
254
- this line will be sequentially changed to
252
+ The minor change is at step 7. When parameters are generated, `phbuilder genparams` needs to be called with the `-titr` option:
253
+
255
254
  ```
256
- lambda-dynamics-group-type3-state-1-reference-pka = 1.0
257
- lambda-dynamics-group-type3-state-1-reference-pka = 2.0
258
- lambda-dynamics-group-type3-state-1-reference-pka = 3.0
259
- ...
255
+ phbuilder genparams -f phneutral.pdb -ph 4.0 -titr
260
256
  ```
261
- in the corresponding folders.
262
-
263
257
 
264
- **NOTE** This behaviour will change in the next release of the code.
258
+ This will set the pH value to the string "ph", as well as all pH-dependent terms for pKa values in multisite groups (e.g. $\lambda_1$ of histidine). Those pH-dependent strings will be read by `create_titration.py` and modified according to the pH value for a particular somulation. Note however that a pH value is still required to be passed as input to `phbuilder genparams`. Minimization and equilibration files will be generated for this provided pH.
265
259
 
266
260
  # Performing parameterizations
267
261
 
@@ -567,7 +561,7 @@ OPTIONS
567
561
  |--------------|----------------|
568
562
  | `-f` | [\<.pdb/.gro>] (required) <br /> Specify input structure file. |
569
563
  | `-o` | [\<.pdb/.gro>] (phprocessed.pdb) <br /> Specify output structure file. |
570
- | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the macroscopic pKas of the titratable sites to auto set the initial lambdas. |
564
+ | `-ph` | [\<float>] <br /> Specify intended simulation pH. Will be used together with the reference pKas of the titratable sites to auto set the initial lambdas. |
571
565
  | `-v` | (no) <br /> Be more verbose. |
572
566
 
573
567
  # Synopsis `phbuilder neutralize`
@@ -604,7 +598,7 @@ Adds the appropriate number of ions to ensure a net-neutral system at t=0, and a
604
598
  # Synopsis `phbuilder genparams`
605
599
 
606
600
  ```
607
- phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-cal] [-v]
601
+ phbuilder genparams [-h] -f FILE -ph PH [-mdp MDP] [-ndx NDX] [-nstout NSTOUT] [-dwpE DWPE] [-inter] [-titr] [-cal] [-v]
608
602
  ```
609
603
 
610
604
  ### DESCRIPTION
@@ -622,6 +616,7 @@ Generates the CpHMD-specific `.mdp` and `.ndx` files. Will write generic EM.mdp
622
616
  | `-nstout` | [\<int>] (500) <br /> Specify lambda coordinate output frequency. 500 is large enough for subsequent frames to be uncoupled (with a $dt = 0.002$).
623
617
  | `-dwpE` | [\<float>] (7.5) <br /> Specify default height of bias potential barrier (kJ/mol).
624
618
  | `-inter` | (no) <br /> Interactively set the height of the bias potential barrier (kJ/mol) for every titratable site.
619
+ | `-titr` | (no) <br /> Prepare files for running titrations with CpHMD: forces pH to be set to "ph" and ph-dependent pKa values to be written to MD.mdp as string. The `create_titration.py` script will further modify those entries according to the currently set ph. |
625
620
  | `-cal` | (no) <br /> Run CpHMD simulation in calibration mode: forces on the lambda coordinates are computed, but their positions won't be updated. This is only used for parameterization purposes. |
626
621
  | `-v` | (no) <br /> Be more verbose. |
627
622
 
@@ -1,2 +1,4 @@
1
1
  argcomplete>=3.1.1
2
2
  configparser>=6.0.0
3
+ sympy>=1.12
4
+ numpy
@@ -2,6 +2,7 @@
2
2
 
3
3
  requires = [
4
4
  "setuptools>=42",
5
- "wheel"
5
+ "wheel",
6
+ "numpy"
6
7
  ]
7
8
  build-backend = "setuptools.build_meta"
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = phbuilder
3
- version = 1.2.4
3
+ version = 1.2.5
4
4
  author = Anton Jansen
5
5
  author_email = anton.jansen@scilifelab.se
6
6
  description = System builder for constant-pH simulations in GROMACS.
@@ -27,6 +27,8 @@ python_requires = >=3.8
27
27
  install_requires =
28
28
  argcomplete>=3.1.1
29
29
  configparser>=6.0.0
30
+ sympy>=1.12
31
+ numpy
30
32
 
31
33
  [options.package_data]
32
34
  phbuilder = ffield/*, ffield/charmm36-mar2019-cphmd.ff/*
File without changes
File without changes
File without changes