Skip to content

Commit 074d9a7

Browse files
authored
Merge pull request #38 from molssi-seamm/dev
Bugfix: initial setup of packmol.ini file
2 parents 2d9235d + 28e3801 commit 074d9a7

17 files changed

+58
-53
lines changed

HISTORY.rst

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
=======
22
History
33
=======
4+
2024.7.25 -- Bugfix: initial setup of packmol.ini file
5+
* The initial setup of the packmol.ini file did not add the information for
6+
Conda. This release fixes that problem.
7+
48
2024.6.29 -- Bugfix: bonding incorrect in some cases.
59
* The use of PDB with Packmol could in some cases lead to multiple bonds in the
610
wrong place. This release fixes that problem.

packmol_step/packmol.py

+19-18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import importlib
77
import logging
88
import math
9+
import os
910
from pathlib import Path
1011
import pprint
1112
import shutil
@@ -16,7 +17,7 @@
1617
from molsystem import SystemDB
1718
import seamm
1819
import seamm_util
19-
from seamm_util import ureg, Q_, units_class # noqa: F401
20+
from seamm_util import Configuration, ureg, Q_, units_class # noqa: F401
2021
import seamm_util.printing as printing
2122
from seamm_util.printing import FormattedText as __
2223
import packmol_step
@@ -220,14 +221,19 @@ def run(self):
220221
ini_dir = Path(seamm_options["root"]).expanduser()
221222
path = ini_dir / "packmol.ini"
222223

223-
if path.exists():
224-
full_config.read(ini_dir / "packmol.ini")
225-
226-
# If the section we need doesn't exists, get the default
227-
if not path.exists() or executor_type not in full_config:
224+
# If the config file doesn't exists, get the default
225+
if not path.exists():
228226
resources = importlib.resources.files("packmol_step") / "data"
229227
ini_text = (resources / "packmol.ini").read_text()
230-
full_config.read_string(ini_text)
228+
txt_config = Configuration(path)
229+
txt_config.from_string(ini_text)
230+
231+
# Work out the conda info needed
232+
txt_config.set_value("local", "conda", os.environ["CONDA_EXE"])
233+
txt_config.set_value("local", "conda-environment", "seamm-packmol")
234+
txt_config.save()
235+
236+
full_config.read(ini_dir / "packmol.ini")
231237

232238
# Getting desperate! Look for an executable in the path
233239
if executor_type not in full_config:
@@ -239,17 +245,12 @@ def run(self):
239245
"in the path!"
240246
)
241247
else:
242-
full_config[executor_type] = {
243-
"installation": "local",
244-
"code": str(path),
245-
}
246-
247-
# If the ini file does not exist, write it out!
248-
if not path.exists():
249-
with path.open("w") as fd:
250-
full_config.write(fd)
251-
printer.normal(f"Wrote the Packmol configuration file to {path}")
252-
printer.normal("")
248+
txt_config = Configuration(path)
249+
txt_config.add_section(executor_type)
250+
txt_config.add_value(executor_type, "installation", "local")
251+
txt_config.add_value(executor_type, "code", str(path))
252+
txt_config.save()
253+
full_config.read(ini_dir / "packmol.ini")
253254

254255
config = dict(full_config.items(executor_type))
255256

tests/outputs/test_10_20_Å_spherical_region_with_solvent_around_solute.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside sphere 0.0 0.0 0.0 10.0000
77
center
8-
fixed -0.0189 -0.1051 -0.0281 0.0 0.0 0.0
8+
fixed -0.0309 -0.0697 -0.0322 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_11_spherical_region_with_solvent_thickness_around_solute.inp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ output packmol.pdb
33
filetype pdb
44
connect yes
55
structure input_1.pdb
6-
inside sphere 0.0 0.0 0.0 14.5778
6+
inside sphere 0.0 0.0 0.0 14.5687
77
center
8-
fixed -0.0043 -0.0362 -0.0348 0.0 0.0 0.0
8+
fixed 0.0302 -0.1685 0.0129 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb
12-
inside sphere 0.0 0.0 0.0 14.5778
13-
number 425
12+
inside sphere 0.0 0.0 0.0 14.5687
13+
number 424
1414
end structure

tests/outputs/test_11_spherical_region_with_solvent_thickness_around_solute.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
the molecule. The number of molecules of the fluid will be obtained by
1414
using the density 1.0 g/ml.
1515

16-
Created a spherical region with a diameter of 29.16 Å with the solute and 425.0 solvent molecules
16+
Created a spherical region with a diameter of 29.14 Å with the solute and 424.0 solvent molecules
1717

1818
+-------------+------------------+---------------+----------+------------+
1919
| Component | Structure | Requested % | Number | Actual % |
2020
|-------------+------------------+---------------+----------+------------|
2121
| solute | c1ccccc1c2ccccc2 | | 1 | |
22-
| fluid | O | 100.000 | 425 | 100.000 |
22+
| fluid | O | 100.000 | 424 | 100.000 |
2323
+-------------+------------------+---------------+----------+------------+
2424

25-
There are a total of 1297 atoms in the cell giving a density of 0.99949 g/ml.
25+
There are a total of 1294 atoms in the cell giving a density of 0.99906 g/ml.

tests/outputs/test_12_cubic_region_with_solvent_thickness_around_solute.inp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ output packmol.pdb
33
filetype pdb
44
connect yes
55
structure input_1.pdb
6-
inside cube 0.0 0.0 0.0 29.2609
6+
inside cube 0.0 0.0 0.0 29.1850
77
center
8-
fixed 14.6244 14.6137 14.6231 0.0 0.0 0.0
8+
fixed 14.6157 14.5994 14.5991 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb
12-
inside cube 0.0 0.0 0.0 29.2609
13-
number 829
12+
inside cube 0.0 0.0 0.0 29.1850
13+
number 822
1414
end structure

tests/outputs/test_12_cubic_region_with_solvent_thickness_around_solute.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
the molecule. The number of molecules of the fluid will be obtained by
1414
using the density 1.0 g/ml.
1515

16-
Created a cubic region 29.26 Å on a side with the solute and 829.0 solvent molecules
16+
Created a cubic region 29.18 Å on a side with the solute and 822.0 solvent molecules
1717

1818
+-------------+------------------+---------------+----------+------------+
1919
| Component | Structure | Requested % | Number | Actual % |
2020
|-------------+------------------+---------------+----------+------------|
2121
| solute | c1ccccc1c2ccccc2 | | 1 | |
22-
| fluid | O | 100.000 | 829 | 100.000 |
22+
| fluid | O | 100.000 | 822 | 100.000 |
2323
+-------------+------------------+---------------+----------+------------+
2424

25-
There are a total of 2509 atoms in the cell giving a density of 1.0001 g/ml.
25+
There are a total of 2488 atoms in the cell giving a density of 0.99951 g/ml.

tests/outputs/test_13_cubic_cell_with_solvent_thickness_around_solute.inp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ output packmol.pdb
33
filetype pdb
44
connect yes
55
structure input_1.pdb
6-
inside cube 1.0000 1.0000 1.0000 17.2164
6+
inside cube 1.0000 1.0000 1.0000 17.0750
77
center
8-
fixed 8.6069 8.5960 8.6042 0.0 0.0 0.0
8+
fixed 8.5324 8.5449 8.5430 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb
12-
inside cube 1.0000 1.0000 1.0000 17.2164
13-
number 229
12+
inside cube 1.0000 1.0000 1.0000 17.0750
13+
number 223
1414
end structure

tests/outputs/test_13_cubic_cell_with_solvent_thickness_around_solute.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
the molecule. The number of molecules of the fluid will be obtained by
1414
using the density 1.0 g/ml.
1515

16-
Created a periodic cubic cell 19.22 Å on a side with the solute and 229.0 solvent molecules
16+
Created a periodic cubic cell 19.08 Å on a side with the solute and 223.0 solvent molecules
1717

1818
+-------------+------------------+---------------+----------+------------+
1919
| Component | Structure | Requested % | Number | Actual % |
2020
|-------------+------------------+---------------+----------+------------|
2121
| solute | c1ccccc1c2ccccc2 | | 1 | |
22-
| fluid | O | 100.000 | 229 | 100.000 |
22+
| fluid | O | 100.000 | 223 | 100.000 |
2323
+-------------+------------------+---------------+----------+------------+
2424

25-
There are a total of 709 atoms in the cell giving a density of 1.0015 g/ml.
25+
There are a total of 691 atoms in the cell giving a density of 0.99807 g/ml.

tests/outputs/test_14_rectangular_cell_with_solvent_thickness_around_solute.inp

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ output packmol.pdb
33
filetype pdb
44
connect yes
55
structure input_1.pdb
6-
inside cube 1.0000 1.0000 1.0000 17.2792
6+
inside cube 1.0000 1.0000 1.0000 17.1247
77
center
8-
fixed 8.6363 8.6450 8.6389 0.0 0.0 0.0
8+
fixed 8.5765 8.5850 8.5614 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb
12-
inside cube 1.0000 1.0000 1.0000 17.2792
13-
number 231
12+
inside cube 1.0000 1.0000 1.0000 17.1247
13+
number 225
1414
end structure

tests/outputs/test_14_rectangular_cell_with_solvent_thickness_around_solute.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@
1313
the molecule. The number of molecules of the fluid will be obtained by
1414
using the density 1.0 g/ml.
1515

16-
Created a periodic cubic cell 19.28 Å on a side with the solute and 231.0 solvent molecules
16+
Created a periodic cubic cell 19.12 Å on a side with the solute and 225.0 solvent molecules
1717

1818
+-------------+------------------+---------------+----------+------------+
1919
| Component | Structure | Requested % | Number | Actual % |
2020
|-------------+------------------+---------------+----------+------------|
2121
| solute | c1ccccc1c2ccccc2 | | 1 | |
22-
| fluid | O | 100.000 | 231 | 100.000 |
22+
| fluid | O | 100.000 | 225 | 100.000 |
2323
+-------------+------------------+---------------+----------+------------+
2424

25-
There are a total of 715 atoms in the cell giving a density of 1.0001 g/ml.
25+
There are a total of 697 atoms in the cell giving a density of 0.99887 g/ml.

tests/outputs/test_15_rectangular_cell_with_Ideal_gas_around_solute.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside box 1.0000 1.0000 1.0000 25.3153 52.6305 79.9458
77
center
8-
fixed 13.6630 27.3240 40.9699 0.0 0.0 0.0
8+
fixed 13.6616 27.3213 40.9757 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_1_spherical_region.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside sphere 0.0 0.0 0.0 13.3688
77
center
8-
fixed -0.0074 0.0650 0.0012 0.0 0.0 0.0
8+
fixed 0.0269 0.1283 -0.0216 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_3_cubic_region.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside cube 0.0 0.0 0.0 21.5504
77
center
8-
fixed 10.7916 10.7737 10.7750 0.0 0.0 0.0
8+
fixed 10.7897 10.7676 10.7743 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_4_periodic_cubic_cell.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside cube 1.0000 1.0000 1.0000 19.5504
77
center
8-
fixed 10.7627 10.7772 10.7756 0.0 0.0 0.0
8+
fixed 10.7661 10.7778 10.7743 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_8_10x20x30_ang_region_1k_atoms_biphenyl_solute.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside box 0.0 0.0 0.0 10.0000 20.0000 30.0000
77
center
8-
fixed 4.9978 10.0181 14.9962 0.0 0.0 0.0
8+
fixed 4.9959 10.0322 14.9967 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

tests/outputs/test_9_10x20x30_ang_cell_1k_atoms_biphenyl_solute.inp

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ connect yes
55
structure input_1.pdb
66
inside box 1.0000 1.0000 1.0000 8.0000 18.0000 28.0000
77
center
8-
fixed 4.0105 9.0004 13.9970 0.0 0.0 0.0
8+
fixed 3.9805 8.9732 13.9961 0.0 0.0 0.0
99
number 1
1010
end structure
1111
structure input_2.pdb

0 commit comments

Comments
 (0)