Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: initial setup of packmol.ini file #38

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
=======
History
=======
2024.7.25 -- Bugfix: initial setup of packmol.ini file
* The initial setup of the packmol.ini file did not add the information for
Conda. This release fixes that problem.

2024.6.29 -- Bugfix: bonding incorrect in some cases.
* The use of PDB with Packmol could in some cases lead to multiple bonds in the
wrong place. This release fixes that problem.
Expand Down
37 changes: 19 additions & 18 deletions packmol_step/packmol.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import importlib
import logging
import math
import os
from pathlib import Path
import pprint
import shutil
Expand All @@ -16,7 +17,7 @@
from molsystem import SystemDB
import seamm
import seamm_util
from seamm_util import ureg, Q_, units_class # noqa: F401
from seamm_util import Configuration, ureg, Q_, units_class # noqa: F401
import seamm_util.printing as printing
from seamm_util.printing import FormattedText as __
import packmol_step
Expand Down Expand Up @@ -220,14 +221,19 @@ def run(self):
ini_dir = Path(seamm_options["root"]).expanduser()
path = ini_dir / "packmol.ini"

if path.exists():
full_config.read(ini_dir / "packmol.ini")

# If the section we need doesn't exists, get the default
if not path.exists() or executor_type not in full_config:
# If the config file doesn't exists, get the default
if not path.exists():
resources = importlib.resources.files("packmol_step") / "data"
ini_text = (resources / "packmol.ini").read_text()
full_config.read_string(ini_text)
txt_config = Configuration(path)
txt_config.from_string(ini_text)

# Work out the conda info needed
txt_config.set_value("local", "conda", os.environ["CONDA_EXE"])
txt_config.set_value("local", "conda-environment", "seamm-packmol")
txt_config.save()

full_config.read(ini_dir / "packmol.ini")

# Getting desperate! Look for an executable in the path
if executor_type not in full_config:
Expand All @@ -239,17 +245,12 @@ def run(self):
"in the path!"
)
else:
full_config[executor_type] = {
"installation": "local",
"code": str(path),
}

# If the ini file does not exist, write it out!
if not path.exists():
with path.open("w") as fd:
full_config.write(fd)
printer.normal(f"Wrote the Packmol configuration file to {path}")
printer.normal("")
txt_config = Configuration(path)
txt_config.add_section(executor_type)
txt_config.add_value(executor_type, "installation", "local")
txt_config.add_value(executor_type, "code", str(path))
txt_config.save()
full_config.read(ini_dir / "packmol.ini")

config = dict(full_config.items(executor_type))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside sphere 0.0 0.0 0.0 10.0000
center
fixed -0.0189 -0.1051 -0.0281 0.0 0.0 0.0
fixed -0.0309 -0.0697 -0.0322 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ output packmol.pdb
filetype pdb
connect yes
structure input_1.pdb
inside sphere 0.0 0.0 0.0 14.5778
inside sphere 0.0 0.0 0.0 14.5687
center
fixed -0.0043 -0.0362 -0.0348 0.0 0.0 0.0
fixed 0.0302 -0.1685 0.0129 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
inside sphere 0.0 0.0 0.0 14.5778
number 425
inside sphere 0.0 0.0 0.0 14.5687
number 424
end structure
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
the molecule. The number of molecules of the fluid will be obtained by
using the density 1.0 g/ml.

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

+-------------+------------------+---------------+----------+------------+
| Component | Structure | Requested % | Number | Actual % |
|-------------+------------------+---------------+----------+------------|
| solute | c1ccccc1c2ccccc2 | | 1 | |
| fluid | O | 100.000 | 425 | 100.000 |
| fluid | O | 100.000 | 424 | 100.000 |
+-------------+------------------+---------------+----------+------------+

There are a total of 1297 atoms in the cell giving a density of 0.99949 g/ml.
There are a total of 1294 atoms in the cell giving a density of 0.99906 g/ml.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ output packmol.pdb
filetype pdb
connect yes
structure input_1.pdb
inside cube 0.0 0.0 0.0 29.2609
inside cube 0.0 0.0 0.0 29.1850
center
fixed 14.6244 14.6137 14.6231 0.0 0.0 0.0
fixed 14.6157 14.5994 14.5991 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
inside cube 0.0 0.0 0.0 29.2609
number 829
inside cube 0.0 0.0 0.0 29.1850
number 822
end structure
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
the molecule. The number of molecules of the fluid will be obtained by
using the density 1.0 g/ml.

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

+-------------+------------------+---------------+----------+------------+
| Component | Structure | Requested % | Number | Actual % |
|-------------+------------------+---------------+----------+------------|
| solute | c1ccccc1c2ccccc2 | | 1 | |
| fluid | O | 100.000 | 829 | 100.000 |
| fluid | O | 100.000 | 822 | 100.000 |
+-------------+------------------+---------------+----------+------------+

There are a total of 2509 atoms in the cell giving a density of 1.0001 g/ml.
There are a total of 2488 atoms in the cell giving a density of 0.99951 g/ml.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ output packmol.pdb
filetype pdb
connect yes
structure input_1.pdb
inside cube 1.0000 1.0000 1.0000 17.2164
inside cube 1.0000 1.0000 1.0000 17.0750
center
fixed 8.6069 8.5960 8.6042 0.0 0.0 0.0
fixed 8.5324 8.5449 8.5430 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
inside cube 1.0000 1.0000 1.0000 17.2164
number 229
inside cube 1.0000 1.0000 1.0000 17.0750
number 223
end structure
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
the molecule. The number of molecules of the fluid will be obtained by
using the density 1.0 g/ml.

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

+-------------+------------------+---------------+----------+------------+
| Component | Structure | Requested % | Number | Actual % |
|-------------+------------------+---------------+----------+------------|
| solute | c1ccccc1c2ccccc2 | | 1 | |
| fluid | O | 100.000 | 229 | 100.000 |
| fluid | O | 100.000 | 223 | 100.000 |
+-------------+------------------+---------------+----------+------------+

There are a total of 709 atoms in the cell giving a density of 1.0015 g/ml.
There are a total of 691 atoms in the cell giving a density of 0.99807 g/ml.
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ output packmol.pdb
filetype pdb
connect yes
structure input_1.pdb
inside cube 1.0000 1.0000 1.0000 17.2792
inside cube 1.0000 1.0000 1.0000 17.1247
center
fixed 8.6363 8.6450 8.6389 0.0 0.0 0.0
fixed 8.5765 8.5850 8.5614 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
inside cube 1.0000 1.0000 1.0000 17.2792
number 231
inside cube 1.0000 1.0000 1.0000 17.1247
number 225
end structure
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
the molecule. The number of molecules of the fluid will be obtained by
using the density 1.0 g/ml.

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

+-------------+------------------+---------------+----------+------------+
| Component | Structure | Requested % | Number | Actual % |
|-------------+------------------+---------------+----------+------------|
| solute | c1ccccc1c2ccccc2 | | 1 | |
| fluid | O | 100.000 | 231 | 100.000 |
| fluid | O | 100.000 | 225 | 100.000 |
+-------------+------------------+---------------+----------+------------+

There are a total of 715 atoms in the cell giving a density of 1.0001 g/ml.
There are a total of 697 atoms in the cell giving a density of 0.99887 g/ml.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside box 1.0000 1.0000 1.0000 25.3153 52.6305 79.9458
center
fixed 13.6630 27.3240 40.9699 0.0 0.0 0.0
fixed 13.6616 27.3213 40.9757 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/test_1_spherical_region.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside sphere 0.0 0.0 0.0 13.3688
center
fixed -0.0074 0.0650 0.0012 0.0 0.0 0.0
fixed 0.0269 0.1283 -0.0216 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/test_3_cubic_region.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside cube 0.0 0.0 0.0 21.5504
center
fixed 10.7916 10.7737 10.7750 0.0 0.0 0.0
fixed 10.7897 10.7676 10.7743 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
2 changes: 1 addition & 1 deletion tests/outputs/test_4_periodic_cubic_cell.inp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside cube 1.0000 1.0000 1.0000 19.5504
center
fixed 10.7627 10.7772 10.7756 0.0 0.0 0.0
fixed 10.7661 10.7778 10.7743 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside box 0.0 0.0 0.0 10.0000 20.0000 30.0000
center
fixed 4.9978 10.0181 14.9962 0.0 0.0 0.0
fixed 4.9959 10.0322 14.9967 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ connect yes
structure input_1.pdb
inside box 1.0000 1.0000 1.0000 8.0000 18.0000 28.0000
center
fixed 4.0105 9.0004 13.9970 0.0 0.0 0.0
fixed 3.9805 8.9732 13.9961 0.0 0.0 0.0
number 1
end structure
structure input_2.pdb
Expand Down
Loading