HTPolyNet 2.2.0__py3-none-any.whl → 2.3.1__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.
- htpolynet/analysis/analyze.py +1 -1
- htpolynet/analysis/postsim.py +1 -1
- htpolynet/cli.py +2 -2
- htpolynet/core/molecule.py +7 -0
- htpolynet/core/paramcache.py +132 -0
- htpolynet/core/projectfilesystem.py +26 -2
- htpolynet/core/runtime.py +118 -7
- htpolynet/external/ambertools.py +23 -4
- htpolynet/external/software.py +18 -2
- {htpolynet-2.2.0.dist-info → htpolynet-2.3.1.dist-info}/METADATA +2 -1
- {htpolynet-2.2.0.dist-info → htpolynet-2.3.1.dist-info}/RECORD +14 -13
- {htpolynet-2.2.0.dist-info → htpolynet-2.3.1.dist-info}/WHEEL +0 -0
- {htpolynet-2.2.0.dist-info → htpolynet-2.3.1.dist-info}/entry_points.txt +0 -0
- {htpolynet-2.2.0.dist-info → htpolynet-2.3.1.dist-info}/licenses/LICENSE +0 -0
htpolynet/analysis/analyze.py
CHANGED
|
@@ -248,7 +248,7 @@ def analyze(args):
|
|
|
248
248
|
software.sw_setup()
|
|
249
249
|
logger.debug(f'ogromacs {ogromacs}')
|
|
250
250
|
for d in args.proj:
|
|
251
|
-
pfs.pfs_setup(root=os.getcwd(),topdirs=pfs.Dirs.analyze_topdirs,verbose=True,projdir=d,reProject=False,userlibrary=args.lib)
|
|
251
|
+
pfs.pfs_setup(root=os.getcwd(),topdirs=pfs.Dirs.analyze_topdirs,verbose=True,projdir=d,reProject=False,userlibrary=pfs.resolve_user_library(args.lib))
|
|
252
252
|
pfs.go_to(pfs.Dirs.analyze)
|
|
253
253
|
for stage in cfg.stagelist:
|
|
254
254
|
stage.do(**ogromacs)
|
htpolynet/analysis/postsim.py
CHANGED
|
@@ -436,7 +436,7 @@ def postsim(args):
|
|
|
436
436
|
software.sw_setup()
|
|
437
437
|
logger.debug(f'ogromacs {ogromacs}')
|
|
438
438
|
for d in args.proj:
|
|
439
|
-
pfs.pfs_setup(root=os.getcwd(),topdirs=pfs.Dirs.postsim_topdirs,verbose=True,projdir=d,reProject=False,userlibrary=args.lib)
|
|
439
|
+
pfs.pfs_setup(root=os.getcwd(),topdirs=pfs.Dirs.postsim_topdirs,verbose=True,projdir=d,reProject=False,userlibrary=pfs.resolve_user_library(args.lib))
|
|
440
440
|
pfs.go_to(pfs.Dirs.postsim)
|
|
441
441
|
for stage in cfg.stagelist:
|
|
442
442
|
stage.do(mdp_pfx='local',**ogromacs)
|
htpolynet/cli.py
CHANGED
|
@@ -127,7 +127,7 @@ def _add_run_options(p, loglevel='debug'):
|
|
|
127
127
|
p.add_argument('-restart',default=False,action='store_true',help='restart in latest proj dir (EXPERIMENTAL: broken at the cure stage; see usage docs)')
|
|
128
128
|
p.add_argument('--no-banner',default=False,action='store_true',help='suppress the startup banner')
|
|
129
129
|
p.add_argument('--force-parameterization',default=False,action='store_true',help='force GAFF parameterization of any input mol2 structures')
|
|
130
|
-
p.add_argument('--force-checkin',default=False,action='store_true',help='
|
|
130
|
+
p.add_argument('--force-checkin',default=False,action='store_true',help='overwrite entries already in the user library (~/.htpolynet, or $HTPOLYNET_CACHE) with newly generated parameter files; a name the library does not yet hold is checked in either way')
|
|
131
131
|
p.add_argument('--param-only',default=False,action='store_true',help='stop after parameterizing molecules without building the full system')
|
|
132
132
|
p.add_argument('--loglevel',type=str,default=loglevel,help='log level for the diagnostic file (debug|info)')
|
|
133
133
|
|
|
@@ -235,7 +235,7 @@ def _add_gen_slurm_args(p):
|
|
|
235
235
|
def _add_analysis_args(p):
|
|
236
236
|
"""Adds the common arguments shared by the postsim and analyze subcommands."""
|
|
237
237
|
p.add_argument('-proj',type=str,default='',nargs='+',help='name of project directory')
|
|
238
|
-
p.add_argument('-lib',type=str,default=
|
|
238
|
+
p.add_argument('-lib',type=str,default=None,help='local user library of molecular structures and parameterizations (default: ./lib if it exists, otherwise none)')
|
|
239
239
|
p.add_argument('-ocfg',type=str,default='',help='original htpolynet config file used to generate project(s)')
|
|
240
240
|
p.add_argument('-cfg',type=str,default='',help='config file specifying the operations to perform')
|
|
241
241
|
p.add_argument('--no-banner',default=False,action='store_true',help='suppress the startup banner')
|
htpolynet/core/molecule.py
CHANGED
|
@@ -12,6 +12,7 @@ from itertools import product
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
|
|
15
|
+
from ..core import paramcache
|
|
15
16
|
from ..core import projectfilesystem as pfs
|
|
16
17
|
from ..core.bondtemplate import BondTemplate, BondTemplateList, ReactionBond, ReactionBondList
|
|
17
18
|
from ..core.topocoord import TopoCoord
|
|
@@ -424,6 +425,12 @@ class Molecule:
|
|
|
424
425
|
shutil.copy(f'{self.parentname}.top', f'{self.name}.top')
|
|
425
426
|
shutil.copy(f'{self.parentname}.grx', f'{self.name}.grx')
|
|
426
427
|
shutil.copy(f'{self.parentname}.tpx', f'{self.name}.tpx')
|
|
428
|
+
# The isomer carries the parent's parameters, so it carries the
|
|
429
|
+
# parent's provenance too; without this it would look like a
|
|
430
|
+
# library entry of unknown origin on every subsequent run.
|
|
431
|
+
parent_key = paramcache.key_filename(self.parentname)
|
|
432
|
+
if os.path.exists(parent_key):
|
|
433
|
+
shutil.copy(parent_key, paramcache.key_filename(self.name))
|
|
427
434
|
|
|
428
435
|
if do_minimization:
|
|
429
436
|
self.minimize(outname)
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Provenance records for cached GAFF parameterizations.
|
|
2
|
+
|
|
3
|
+
A parameterization checked into the user library is identified by molecule
|
|
4
|
+
name alone, but the numbers it contains depend on more than the name: the
|
|
5
|
+
antechamber charge method, the net charge passed as ``-nc``, and the atom-type
|
|
6
|
+
set. Without a record of those, a configuration asking for
|
|
7
|
+
``charge_method: bcc`` silently reuses a ``gas`` parameterization checked in
|
|
8
|
+
months earlier under the same residue name, and the only trace is a log line
|
|
9
|
+
saying the cache was used. The resulting system carries one charge method on
|
|
10
|
+
some residues and another on the rest, and nothing in the output says so.
|
|
11
|
+
|
|
12
|
+
This module writes a small JSON sidecar next to a parameterization recording
|
|
13
|
+
what produced it, and compares that record against what the current run asks
|
|
14
|
+
for. A mismatch is a cache miss. An *absent* record -- any library built
|
|
15
|
+
before sidecars existed -- is a cache hit with a warning, so that existing
|
|
16
|
+
libraries keep working rather than silently re-parameterizing wholesale.
|
|
17
|
+
|
|
18
|
+
Author: Cameron F. Abrams <cfa22@drexel.edu>
|
|
19
|
+
"""
|
|
20
|
+
import json
|
|
21
|
+
import logging
|
|
22
|
+
import os
|
|
23
|
+
|
|
24
|
+
logger = logging.getLogger(__name__)
|
|
25
|
+
|
|
26
|
+
CACHE_KEY_EXT = 'parm'
|
|
27
|
+
"""Filename extension of the sidecar record, alongside gro/top/itp/tpx/grx."""
|
|
28
|
+
|
|
29
|
+
_KEY_FIELDS = (
|
|
30
|
+
('charge_method', 'charge method'),
|
|
31
|
+
('net_charge', 'net charge'),
|
|
32
|
+
('atom_type', 'atom-type set'),
|
|
33
|
+
)
|
|
34
|
+
"""Fields that determine the parameters, with human-readable labels."""
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def build_key(ambertools=None):
|
|
38
|
+
"""Returns the provenance record describing a parameterization run under
|
|
39
|
+
the given AmberTools directives.
|
|
40
|
+
|
|
41
|
+
Defaults come from :data:`htpolynet.external.ambertools.AMBERTOOLS_DEFAULTS`
|
|
42
|
+
so that the record cannot drift from what GAFFParameterize actually does.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
ambertools (dict, optional): ambertools configuration directives
|
|
46
|
+
|
|
47
|
+
Returns:
|
|
48
|
+
dict: provenance record
|
|
49
|
+
"""
|
|
50
|
+
from ..external.ambertools import AMBERTOOLS_DEFAULTS
|
|
51
|
+
ambertools = ambertools or {}
|
|
52
|
+
return {field: ambertools.get(field, AMBERTOOLS_DEFAULTS[field])
|
|
53
|
+
for field, _ in _KEY_FIELDS}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def key_filename(prefix):
|
|
57
|
+
"""Returns the sidecar filename for the given file basename.
|
|
58
|
+
|
|
59
|
+
Args:
|
|
60
|
+
prefix (str): file basename
|
|
61
|
+
|
|
62
|
+
Returns:
|
|
63
|
+
str: sidecar filename
|
|
64
|
+
"""
|
|
65
|
+
return f'{prefix}.{CACHE_KEY_EXT}'
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def write_key(prefix, key):
|
|
69
|
+
"""Writes a provenance record beside the parameterization it describes.
|
|
70
|
+
|
|
71
|
+
Args:
|
|
72
|
+
prefix (str): file basename
|
|
73
|
+
key (dict): provenance record
|
|
74
|
+
"""
|
|
75
|
+
with open(key_filename(prefix), 'w') as f:
|
|
76
|
+
json.dump(key, f, indent=2, sort_keys=True)
|
|
77
|
+
f.write('\n')
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def read_key(prefix):
|
|
81
|
+
"""Reads the provenance record for the given file basename.
|
|
82
|
+
|
|
83
|
+
A record that is missing, unreadable, or malformed is reported as absent
|
|
84
|
+
rather than raising, since an unusable record must not be able to abort a
|
|
85
|
+
build that would otherwise have proceeded.
|
|
86
|
+
|
|
87
|
+
Args:
|
|
88
|
+
prefix (str): file basename
|
|
89
|
+
|
|
90
|
+
Returns:
|
|
91
|
+
dict or None: provenance record, or None if absent or unusable
|
|
92
|
+
"""
|
|
93
|
+
fn = key_filename(prefix)
|
|
94
|
+
if not os.path.exists(fn):
|
|
95
|
+
return None
|
|
96
|
+
try:
|
|
97
|
+
with open(fn) as f:
|
|
98
|
+
key = json.load(f)
|
|
99
|
+
except (OSError, ValueError) as m:
|
|
100
|
+
logger.warning(f'Could not read parameterization record {fn} ({m}); treating it as absent')
|
|
101
|
+
return None
|
|
102
|
+
if not isinstance(key, dict):
|
|
103
|
+
logger.warning(f'Parameterization record {fn} is not a JSON object; treating it as absent')
|
|
104
|
+
return None
|
|
105
|
+
return key
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def describe_mismatch(stored, requested):
|
|
109
|
+
"""Returns human-readable descriptions of every field on which a stored
|
|
110
|
+
record disagrees with what the current run requests.
|
|
111
|
+
|
|
112
|
+
A field absent from the stored record is skipped rather than counted as a
|
|
113
|
+
mismatch, so that adding a field here does not invalidate every record
|
|
114
|
+
written by an earlier version.
|
|
115
|
+
|
|
116
|
+
Args:
|
|
117
|
+
stored (dict or None): record read from the cache
|
|
118
|
+
requested (dict): record describing what this run asks for
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
list: descriptions of the differing fields; empty if the record agrees
|
|
122
|
+
or is absent
|
|
123
|
+
"""
|
|
124
|
+
if not stored:
|
|
125
|
+
return []
|
|
126
|
+
diffs = []
|
|
127
|
+
for field, label in _KEY_FIELDS:
|
|
128
|
+
if field not in stored:
|
|
129
|
+
continue
|
|
130
|
+
if stored[field] != requested.get(field):
|
|
131
|
+
diffs.append(f'{label} {stored[field]!r} cached, {requested.get(field)!r} requested')
|
|
132
|
+
return diffs
|
|
@@ -208,7 +208,9 @@ class UserLibrary:
|
|
|
208
208
|
pathname (str): path to the user library directory, defaults to '.'
|
|
209
209
|
"""
|
|
210
210
|
self.root = Path(os.path.abspath(pathname))
|
|
211
|
-
assert self.root.exists() and self.root.is_dir(),
|
|
211
|
+
assert self.root.exists() and self.root.is_dir(), (
|
|
212
|
+
f'user library {pathname!r} (resolved to {self.root}) is not a directory; '
|
|
213
|
+
f'pass -lib <path> to point at an existing library, or create it')
|
|
212
214
|
|
|
213
215
|
def exists(self, filename):
|
|
214
216
|
"""Checks if filename exists in the user library.
|
|
@@ -448,6 +450,28 @@ def pfs_setup(root='.', topdirs=['molecules', 'systems', 'plots'], projdir='next
|
|
|
448
450
|
userlibrary=userlibrary, mock=mock)
|
|
449
451
|
|
|
450
452
|
|
|
453
|
+
def resolve_user_library(pathname, default='lib'):
|
|
454
|
+
"""Returns the user-library path a subcommand should use, or None for none.
|
|
455
|
+
|
|
456
|
+
An explicitly supplied path is returned unchanged, so that a typo fails
|
|
457
|
+
loudly in UserLibrary rather than silently degrading to no library. When
|
|
458
|
+
nothing was supplied, the conventional ``lib/`` is used only if it is
|
|
459
|
+
actually there: a subcommand that merely reads finished results has no
|
|
460
|
+
reason to require a molecule library, and demanding one turns the default
|
|
461
|
+
value of a flag the user never typed into a hard error.
|
|
462
|
+
|
|
463
|
+
Args:
|
|
464
|
+
pathname (str or None): the value of the ``-lib`` flag, or None if unset
|
|
465
|
+
default (str): the conventional library directory, defaults to 'lib'
|
|
466
|
+
|
|
467
|
+
Returns:
|
|
468
|
+
str or None: path to use as the user library, or None for no user library
|
|
469
|
+
"""
|
|
470
|
+
if pathname is not None:
|
|
471
|
+
return pathname
|
|
472
|
+
return default if os.path.isdir(default) else None
|
|
473
|
+
|
|
474
|
+
|
|
451
475
|
def checkout(filename, altpath=[]):
|
|
452
476
|
"""Copies a file to cwd; searches user library, then user cache, then system library.
|
|
453
477
|
|
|
@@ -487,7 +511,7 @@ def fetch_molecule_files(mname):
|
|
|
487
511
|
"""
|
|
488
512
|
ret_exts = []
|
|
489
513
|
dirname = 'molecules/parameterized'
|
|
490
|
-
for e in ['mol2', 'pdb', 'gro', 'top', 'tpx', 'itp', 'grx']:
|
|
514
|
+
for e in ['mol2', 'pdb', 'gro', 'top', 'tpx', 'itp', 'grx', 'parm']:
|
|
491
515
|
prob_filename = os.path.join(dirname, f'{mname}.{e}')
|
|
492
516
|
if exists(prob_filename):
|
|
493
517
|
ret_exts.append(e)
|
htpolynet/core/runtime.py
CHANGED
|
@@ -13,6 +13,7 @@ from copy import deepcopy
|
|
|
13
13
|
import numpy as np
|
|
14
14
|
|
|
15
15
|
from ..analysis.plot import trace
|
|
16
|
+
from ..core import paramcache
|
|
16
17
|
from ..core import projectfilesystem as pfs
|
|
17
18
|
from ..core.configuration import Configuration
|
|
18
19
|
from ..core.molecule import Molecule, MoleculeDict
|
|
@@ -148,6 +149,9 @@ class Runtime:
|
|
|
148
149
|
if restart:
|
|
149
150
|
logger.info(f'Restarting in {pfs.proj()}')
|
|
150
151
|
self.molecules:MoleculeDict={}
|
|
152
|
+
# molecules reused from a library entry that carries no provenance
|
|
153
|
+
# record, collected for a stage-end summary; see generate_molecules
|
|
154
|
+
self.unverified_parameterizations=[]
|
|
151
155
|
self.reactions:ReactionList=[]
|
|
152
156
|
self.molecule_report={}
|
|
153
157
|
self.maxconv=0.0
|
|
@@ -279,6 +283,7 @@ class Runtime:
|
|
|
279
283
|
"""
|
|
280
284
|
for mname,M in self.molecules.items():
|
|
281
285
|
M.origin='unparameterized'
|
|
286
|
+
self.unverified_parameterizations=[]
|
|
282
287
|
pfs.go_to(pfs.Dirs.molecules_parameterized)
|
|
283
288
|
my_logger(f'Templates in {pfs.cwd()}',logger.info)
|
|
284
289
|
ess='' if len(self.molecules)==1 else 's'
|
|
@@ -322,6 +327,8 @@ class Runtime:
|
|
|
322
327
|
logger.info(f'Resolving type discrepancies for directive {resolve_directive}')
|
|
323
328
|
self._type_consistency_check(typename=resolve_directive['typename'],funcidx=resolve_directive.get('funcidx',4),selection_rule=resolve_directive['rule'])
|
|
324
329
|
|
|
330
|
+
self._report_unverified_parameterizations()
|
|
331
|
+
|
|
325
332
|
ess='' if len(self.molecules)==1 else 's'
|
|
326
333
|
logger.info(f'Generated {len(self.molecules)} molecule template{ess}')
|
|
327
334
|
if self.cfg.initial_composition:
|
|
@@ -601,6 +608,107 @@ class Runtime:
|
|
|
601
608
|
except Exception as e:
|
|
602
609
|
logger.warning(f'Could not write profile.json: {e}')
|
|
603
610
|
|
|
611
|
+
def _report_unverified_parameterizations(self):
|
|
612
|
+
"""Summarizes, at the end of the parameterization stage, every molecule
|
|
613
|
+
reused from a library entry whose provenance could not be checked.
|
|
614
|
+
|
|
615
|
+
The per-molecule warning is right for grepping but wrong as the only
|
|
616
|
+
surface: it sits in a log that runs to thousands of lines, alongside
|
|
617
|
+
the ordinary "Using cached parameterization" line that this whole
|
|
618
|
+
mechanism exists because people read straight past. A block at the end
|
|
619
|
+
of the stage is what someone scanning the tail of a log actually hits,
|
|
620
|
+
and it arrives while the expensive part of the build is still ahead of
|
|
621
|
+
them rather than behind.
|
|
622
|
+
|
|
623
|
+
Both messages have to say that the cached parameters are being *used*,
|
|
624
|
+
not merely that they could not be checked. A reader who upgrades with
|
|
625
|
+
an existing library, asks for one charge method, and gets another one's
|
|
626
|
+
numbers will otherwise conclude the cache guard does not work -- the
|
|
627
|
+
correct behavior here is indistinguishable from the bug it replaced
|
|
628
|
+
unless the message says which is happening.
|
|
629
|
+
"""
|
|
630
|
+
if not self.unverified_parameterizations:
|
|
631
|
+
return
|
|
632
|
+
names = sorted(set(self.unverified_parameterizations))
|
|
633
|
+
ess = '' if len(names) == 1 else 's'
|
|
634
|
+
requested = paramcache.build_key(self.cfg.ambertools)
|
|
635
|
+
my_logger(f'{len(names)} parameterization{ess} reused without provenance', logger.warning)
|
|
636
|
+
logger.warning('These were taken from the library, which records nothing about how they were')
|
|
637
|
+
logger.warning('built. This build therefore carries whatever charges those entries hold, and')
|
|
638
|
+
logger.warning(f'they may not be {requested["charge_method"]!r}:')
|
|
639
|
+
my_logger(names, logger.warning)
|
|
640
|
+
logger.warning('This is expected for entries written before htpolynet 2.3, and is not a')
|
|
641
|
+
logger.warning('failure. Rebuild them with --force-parameterization if this build\'s charges')
|
|
642
|
+
logger.warning('need to be certain.')
|
|
643
|
+
|
|
644
|
+
@staticmethod
|
|
645
|
+
def _checkin_parameterization(mname, overwrite):
|
|
646
|
+
"""Checks a molecule's parameterization files into the user library.
|
|
647
|
+
|
|
648
|
+
The provenance record is checked in only when the data files beside it
|
|
649
|
+
are. pfs.checkin() will not replace a file that already exists unless
|
|
650
|
+
told to, and a library entry can be partially populated, so a record
|
|
651
|
+
checked in unconditionally could attach itself to files it does not
|
|
652
|
+
describe -- leaving the library asserting that a gas parameterization
|
|
653
|
+
was built with bcc, which is worse than the missing record it replaced.
|
|
654
|
+
|
|
655
|
+
Args:
|
|
656
|
+
mname (str): molecule name
|
|
657
|
+
overwrite (bool): replace files already in the library
|
|
658
|
+
"""
|
|
659
|
+
entry = f'{pfs.Dirs.molecules_parameterized}/{mname}'
|
|
660
|
+
wrote_data = overwrite or not pfs.exists(f'{entry}.gro')
|
|
661
|
+
for ex in ['mol2', 'top', 'tpx', 'itp', 'gro', 'grx']:
|
|
662
|
+
pfs.checkin(f'{entry}.{ex}', overwrite=overwrite)
|
|
663
|
+
if wrote_data:
|
|
664
|
+
pfs.checkin(f'{entry}.{paramcache.CACHE_KEY_EXT}', overwrite=True)
|
|
665
|
+
|
|
666
|
+
def _cached_parameterization_mismatch(self, M):
|
|
667
|
+
"""Returns descriptions of every way a cached parameterization of M
|
|
668
|
+
disagrees with what this run asks AmberTools for.
|
|
669
|
+
|
|
670
|
+
The cache is keyed on molecule name alone, so without this check a
|
|
671
|
+
configuration requesting one charge method silently reuses a
|
|
672
|
+
parameterization built with another, producing a system with mixed
|
|
673
|
+
charge methods and no indication of it anywhere in the output.
|
|
674
|
+
|
|
675
|
+
A library entry written before provenance records existed carries no
|
|
676
|
+
record to check. That is reported and treated as a match, so that an
|
|
677
|
+
existing library keeps working; --force-parameterization remains the
|
|
678
|
+
way to be certain of what a build used.
|
|
679
|
+
|
|
680
|
+
Args:
|
|
681
|
+
M (Molecule): the molecule whose cached parameterization is in question
|
|
682
|
+
|
|
683
|
+
Returns:
|
|
684
|
+
list: descriptions of the differing directives; empty if the cached
|
|
685
|
+
parameterization agrees with this run or carries no record
|
|
686
|
+
"""
|
|
687
|
+
requested = paramcache.build_key(self.cfg.ambertools)
|
|
688
|
+
# Discard any record left in the project directory by an earlier run so
|
|
689
|
+
# that what we check is the record belonging to the library entry that
|
|
690
|
+
# previously_parameterized() just found.
|
|
691
|
+
local = paramcache.key_filename(M.name)
|
|
692
|
+
if os.path.exists(local):
|
|
693
|
+
os.remove(local)
|
|
694
|
+
keyfile = os.path.join(pfs.Dirs.molecules_parameterized, local)
|
|
695
|
+
if pfs.exists(keyfile):
|
|
696
|
+
pfs.checkout(keyfile)
|
|
697
|
+
stored = paramcache.read_key(M.name)
|
|
698
|
+
if stored is None:
|
|
699
|
+
logger.warning(f'Reusing cached parameterization for {M.name}, which carries no record of '
|
|
700
|
+
f'how it was built: this build takes whatever charges that entry holds, and '
|
|
701
|
+
f'they may not be {requested["charge_method"]!r}. Expected for an entry '
|
|
702
|
+
f'written before htpolynet 2.3; rebuild it with --force-parameterization '
|
|
703
|
+
f'if this build\'s charges need to be certain.')
|
|
704
|
+
self.unverified_parameterizations.append(M.name)
|
|
705
|
+
return []
|
|
706
|
+
diffs = paramcache.describe_mismatch(stored, requested)
|
|
707
|
+
if diffs:
|
|
708
|
+
logger.info(f'Cached parameterization for {M.name} was built differently than this run requests '
|
|
709
|
+
f'({"; ".join(diffs)}); re-parameterizing')
|
|
710
|
+
return diffs
|
|
711
|
+
|
|
604
712
|
def _generate_molecule(self,M:Molecule,**kwargs):
|
|
605
713
|
"""Generates and parameterizes a single molecule based on the partially complete instance in parameter M.
|
|
606
714
|
|
|
@@ -609,18 +717,23 @@ class Runtime:
|
|
|
609
717
|
"""
|
|
610
718
|
if M.origin!='unparameterized' and M.origin!='symmetry_product': return
|
|
611
719
|
mname=M.name
|
|
612
|
-
checkin=pfs.checkin
|
|
613
720
|
force_parameterization=kwargs.get('force_parameterization',False)
|
|
614
721
|
force_checkin=kwargs.get('force_checkin',False)
|
|
722
|
+
# A cached parameterization is keyed on molecule name, which says nothing
|
|
723
|
+
# about the charge method, net charge or atom types that produced its
|
|
724
|
+
# numbers. Reject one that answers a different question than this run is
|
|
725
|
+
# asking; see _cached_parameterization_mismatch.
|
|
726
|
+
use_cache = (not force_parameterization) and M.previously_parameterized()
|
|
727
|
+
if use_cache and self._cached_parameterization_mismatch(M):
|
|
728
|
+
use_cache = False
|
|
615
729
|
# Either perform a fresh parameterization or fetch parameterization files
|
|
616
|
-
if
|
|
730
|
+
if not use_cache:
|
|
617
731
|
logger.debug(f'Parameterization of {mname} requested -- can we generate {mname}?')
|
|
618
732
|
generatable=(not M.generator) or (all([m in self.molecules for m in M.generator.reactants.values()]))
|
|
619
733
|
if generatable:
|
|
620
734
|
logger.debug(f'Generating {mname}')
|
|
621
735
|
M.generate(available_molecules=self.molecules,gaff=self.cfg.gaff,ambertools=self.cfg.ambertools)
|
|
622
|
-
|
|
623
|
-
checkin(f'{pfs.Dirs.molecules_parameterized}/{mname}.{ex}',overwrite=force_checkin)
|
|
736
|
+
self._checkin_parameterization(mname, force_checkin)
|
|
624
737
|
M.origin='newly parameterized'
|
|
625
738
|
else:
|
|
626
739
|
logger.debug(f'Error: could not generate {mname}')
|
|
@@ -690,9 +803,7 @@ class Runtime:
|
|
|
690
803
|
M.set_sequence_from_moldict(self.molecules)
|
|
691
804
|
M.generate(available_molecules=self.molecules,
|
|
692
805
|
gaff=self.cfg.gaff, ambertools=self.cfg.ambertools)
|
|
693
|
-
|
|
694
|
-
checkin(f'{pfs.Dirs.molecules_parameterized}/{mname}.{ex}',
|
|
695
|
-
overwrite=True)
|
|
806
|
+
self._checkin_parameterization(mname, True)
|
|
696
807
|
M.origin='newly parameterized (stale cache refreshed)'
|
|
697
808
|
else:
|
|
698
809
|
M.origin='previously parameterized'
|
htpolynet/external/ambertools.py
CHANGED
|
@@ -9,11 +9,24 @@ import shutil
|
|
|
9
9
|
|
|
10
10
|
import parmed
|
|
11
11
|
|
|
12
|
+
from ..core import paramcache
|
|
12
13
|
from ..core.coordinates import Coordinates
|
|
13
14
|
from ..external.command import run
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
16
17
|
|
|
18
|
+
AMBERTOOLS_DEFAULTS = {
|
|
19
|
+
'charge_method': 'bcc',
|
|
20
|
+
'net_charge': 0,
|
|
21
|
+
'atom_type': 'gaff',
|
|
22
|
+
}
|
|
23
|
+
"""Directives that determine the parameters GAFFParameterize produces.
|
|
24
|
+
|
|
25
|
+
These are the single source of truth for both the antechamber/parmchk2/tleap
|
|
26
|
+
invocations below and the provenance record written beside their output; see
|
|
27
|
+
:mod:`htpolynet.core.paramcache`.
|
|
28
|
+
"""
|
|
29
|
+
|
|
17
30
|
|
|
18
31
|
def GAFFParameterize(inputPrefix, outputPrefix, input_structure_format='mol2', ambertools=None):
|
|
19
32
|
"""Manages execution of antechamber, parmchk2, and tleap to generate GAFF parameters,
|
|
@@ -29,7 +42,9 @@ def GAFFParameterize(inputPrefix, outputPrefix, input_structure_format='mol2', a
|
|
|
29
42
|
parmed.exceptions.GromacsError: if parmed fails to convert tleap output
|
|
30
43
|
"""
|
|
31
44
|
ambertools = ambertools or {}
|
|
32
|
-
chargemethod = ambertools.get('charge_method', '
|
|
45
|
+
chargemethod = ambertools.get('charge_method', AMBERTOOLS_DEFAULTS['charge_method'])
|
|
46
|
+
netcharge = ambertools.get('net_charge', AMBERTOOLS_DEFAULTS['net_charge'])
|
|
47
|
+
atomtype = ambertools.get('atom_type', AMBERTOOLS_DEFAULTS['atom_type'])
|
|
33
48
|
logger.info(f'AmberTools> generating GAFF parameters from {inputPrefix}.{input_structure_format}')
|
|
34
49
|
|
|
35
50
|
structin = f'{inputPrefix}.{input_structure_format}'
|
|
@@ -47,9 +62,9 @@ def GAFFParameterize(inputPrefix, outputPrefix, input_structure_format='mol2', a
|
|
|
47
62
|
shutil.copy(structin, new_structin)
|
|
48
63
|
|
|
49
64
|
run(f'antechamber -j 4 -fi {input_structure_format} -fo mol2 -c {chargemethod}'
|
|
50
|
-
f' -at
|
|
65
|
+
f' -at {atomtype} -i {new_structin} -o {mol2out} -pf Y -nc {netcharge} -eq 1 -pl 10', quiet=False)
|
|
51
66
|
logger.debug(f'AmberTools> Antechamber generated {mol2out}')
|
|
52
|
-
run(f'parmchk2 -i {mol2out} -o {frcmodout} -f mol2 -s
|
|
67
|
+
run(f'parmchk2 -i {mol2out} -o {frcmodout} -f mol2 -s {atomtype}', quiet=False)
|
|
53
68
|
|
|
54
69
|
# Antechamber ignores SUBSTRUCTURE records, so patch the antechamber output
|
|
55
70
|
# mol2 with the original resName/resNum before passing it to tleap.
|
|
@@ -70,7 +85,7 @@ def GAFFParameterize(inputPrefix, outputPrefix, input_structure_format='mol2', a
|
|
|
70
85
|
|
|
71
86
|
with open(f'{inputPrefix}-tleap.in', 'w') as f:
|
|
72
87
|
f.write('\n'.join([
|
|
73
|
-
'source leaprc.
|
|
88
|
+
f'source leaprc.{atomtype}',
|
|
74
89
|
# Load parmchk2's patches BEFORE checking the molecule, otherwise
|
|
75
90
|
# `check` reports any GAFF-coverage gaps (e.g. h5-ce-n2 on cyanate-
|
|
76
91
|
# ester dimers) as `Error!`, the run-wrapper's override needle
|
|
@@ -100,3 +115,7 @@ def GAFFParameterize(inputPrefix, outputPrefix, input_structure_format='mol2', a
|
|
|
100
115
|
logger.error('Unspecified parmed error')
|
|
101
116
|
raise parmed.exceptions.GromacsError(m) from m
|
|
102
117
|
|
|
118
|
+
# Record what produced these parameters, so that a later run reusing them
|
|
119
|
+
# from the library can tell whether they answer the question it is asking.
|
|
120
|
+
paramcache.write_key(outputPrefix, paramcache.build_key(ambertools))
|
|
121
|
+
|
htpolynet/external/software.py
CHANGED
|
@@ -90,8 +90,15 @@ def _mdrun_cmd(base):
|
|
|
90
90
|
|
|
91
91
|
def _get_git_commit():
|
|
92
92
|
"""Records the short git commit hash of the htpolynet source tree and
|
|
93
|
-
whether there are uncommitted changes.
|
|
94
|
-
|
|
93
|
+
whether there are uncommitted changes.
|
|
94
|
+
|
|
95
|
+
An installed copy -- pip, conda, or the published container -- has no
|
|
96
|
+
``.git`` beside it, so the git lookup fails and there is nothing to
|
|
97
|
+
report. Reporting 'unknown' there leaves a build with no way to answer
|
|
98
|
+
"what code produced this" from inside itself, which is exactly the
|
|
99
|
+
question the parameterization records exist to answer for molecules.
|
|
100
|
+
Fall back to the installed distribution version, which for a released
|
|
101
|
+
install maps to a tag and is the honest answer.
|
|
95
102
|
"""
|
|
96
103
|
global git_commit
|
|
97
104
|
src = os.path.dirname(__file__)
|
|
@@ -108,6 +115,15 @@ def _get_git_commit():
|
|
|
108
115
|
)
|
|
109
116
|
if dirty.returncode == 0 and dirty.stdout.strip():
|
|
110
117
|
git_commit += ' (uncommitted changes present)'
|
|
118
|
+
return
|
|
119
|
+
except Exception:
|
|
120
|
+
pass
|
|
121
|
+
try:
|
|
122
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
123
|
+
try:
|
|
124
|
+
git_commit = f'not a git checkout (installed version {version("htpolynet")})'
|
|
125
|
+
except PackageNotFoundError:
|
|
126
|
+
pass
|
|
111
127
|
except Exception:
|
|
112
128
|
pass
|
|
113
129
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: htpolynet
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
4
4
|
Summary: Automated MD System Builder for Amorphous Network Polymers
|
|
5
5
|
Project-URL: Source, https://github.com/cameronabrams/htpolynet
|
|
6
6
|
Project-URL: Documentation, https://htpolynet.readthedocs.io/
|
|
@@ -42,6 +42,7 @@ Description-Content-Type: text/markdown
|
|
|
42
42
|
[](https://github.com/cameronabrams/htpolynet/blob/main/LICENSE)
|
|
43
43
|
[](https://htpolynet.readthedocs.io/en/latest/)
|
|
44
44
|
[](https://pepy.tech/projects/htpolynet)
|
|
45
|
+
[](https://doi.org/10.5281/zenodo.22070252)
|
|
45
46
|
|
|
46
47
|
htpolynet is a Python utility for generating atomistic models of cross-linked polymer networks together with appropriate topology and parameter files required for molecular dynamics simulations using Gromacs. It is intended as a fully automated system builder requiring as inputs only the molecular structures of any monomer species, a description of the polymerization chemistry, and a handful of options describing desired system size and composition. htpolynet uses the Generalized Amber Force Field for atom-typing and parameter generation.
|
|
47
48
|
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
htpolynet/__init__.py,sha256=_ApfhZLLP4Hd3b5ZCHAw6FHEj2VpQhu3RrZrZPiTef4,80
|
|
2
|
-
htpolynet/cli.py,sha256=
|
|
2
|
+
htpolynet/cli.py,sha256=4QjaltjS1LLBciGc5uiENFbKC4_ReIHVHMq6PVe-7ZQ,15186
|
|
3
3
|
htpolynet/analysis/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
htpolynet/analysis/analyze.py,sha256=
|
|
4
|
+
htpolynet/analysis/analyze.py,sha256=vM-FpM7rC6hiXw7VjrKFmpTjrfRzSbWHG9McsaZrhMs,9132
|
|
5
5
|
htpolynet/analysis/plot.py,sha256=ncLduM4cK7ncQjksE2qL0Z086gqQOCpMs66rlI7AbOk,33020
|
|
6
|
-
htpolynet/analysis/postsim.py,sha256=
|
|
6
|
+
htpolynet/analysis/postsim.py,sha256=7HvW6yPHfSddl63QUp8PbyzToMSm13Pw16cqCY8OnWw,16873
|
|
7
7
|
htpolynet/analysis/utils.py,sha256=jmQMfw8EDzRSEvqBHUQV2g15-MmZbreJYiJ7gan_z-c,17246
|
|
8
8
|
htpolynet/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
9
|
htpolynet/core/bondtemplate.py,sha256=Sz_K7ZhyHzj_dCBjDASlhzm3cXgIwAvHIgIanvuld5s,8512
|
|
10
10
|
htpolynet/core/configuration.py,sha256=CsfCE6_SwwFgN6BdY-4cWrQKAIcVNE1mxp2_qyQaJ9Y,3052
|
|
11
11
|
htpolynet/core/coordinates.py,sha256=CGTHkdfw2ikc2ANacA5akRhZ9tOyM2IbELwQ2FVcKRw,23878
|
|
12
|
-
htpolynet/core/molecule.py,sha256=
|
|
13
|
-
htpolynet/core/
|
|
14
|
-
htpolynet/core/
|
|
12
|
+
htpolynet/core/molecule.py,sha256=xUA52zkRMyAFCE8LbXvXghweDCPkrgD4rx1mcimddn0,52751
|
|
13
|
+
htpolynet/core/paramcache.py,sha256=3MTG96F4vtT5w-pn1RWNmXic0QKB7WVcwCrD-BSY3B0,4508
|
|
14
|
+
htpolynet/core/projectfilesystem.py,sha256=2U_EToZxN7yUGWu9BIRABVsYdp1AKkOuManwuFBz89k,20983
|
|
15
|
+
htpolynet/core/runtime.py,sha256=BmWDttIKtRJnqYiYgrv7bJcivLaBtsgXK8q1jdYVKGw,53299
|
|
15
16
|
htpolynet/core/topocoord.py,sha256=jtQcwzvzPVNjU9VxBF9iXw8g3KiY55_jGDlwAZDOSjs,101564
|
|
16
17
|
htpolynet/core/topology.py,sha256=XcFL96x2E4MsMrUr9upjE211-VcPVwLVoPL9vrV4DOw,56954
|
|
17
18
|
htpolynet/cure/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -20,12 +21,12 @@ htpolynet/cure/curecontroller.py,sha256=a97x1GaJ7Q2ayDEN48K4QHS9EOCPEljraUN_joR9
|
|
|
20
21
|
htpolynet/cure/expandreactions.py,sha256=_NNsAuOCdgHMBLyEwl6S7VAZyDT5ei-m4OBBXjDE3YQ,13774
|
|
21
22
|
htpolynet/cure/reaction.py,sha256=S-w60HocYknKnGbq1_uwLpKTL5Fte_o7zxwk3FbyQ1I,10557
|
|
22
23
|
htpolynet/external/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
|
-
htpolynet/external/ambertools.py,sha256=
|
|
24
|
+
htpolynet/external/ambertools.py,sha256=W3Ut9z7XovJcrxfgkL8eyP-Q0tKmyK1awfAcEafNxB0,5307
|
|
24
25
|
htpolynet/external/command.py,sha256=KYmWV8P4nuw_ciE16WazviorxjGj5un_z7dL62n0TG0,2480
|
|
25
26
|
htpolynet/external/gromacs.py,sha256=KEtHA4TuHaSA_nFXoz2NyrX3JUr9a733-KkOv5BE4Lc,12848
|
|
26
27
|
htpolynet/external/slurm.py,sha256=FvnKyNqFXgDe5bdTDB4Kcn9KU4mxq9Gcw675SzU-4w0,4082
|
|
27
28
|
htpolynet/external/smiles_input.py,sha256=vt-CdEHSqpJ5EA57NqQSCywjpHnTE5wCk2im2oxhM3U,9830
|
|
28
|
-
htpolynet/external/software.py,sha256=
|
|
29
|
+
htpolynet/external/software.py,sha256=vVgm7hvF9PyjWZ8-gUTDMl4XdnC3IIK7QEWQGr0-B7g,9569
|
|
29
30
|
htpolynet/geometry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
30
31
|
htpolynet/geometry/bondlist.py,sha256=ps6AreIHLz-55zZieJiBg9rbd9zZctw8gPrmQYK0MbI,6144
|
|
31
32
|
htpolynet/geometry/lattice.py,sha256=YgrX52xHjiK9DP-T_xFiqiCYLHukU5tKCxutl-rC5c0,896
|
|
@@ -94,8 +95,8 @@ htpolynet/utils/logsetup.py,sha256=o0mlVXNzqcfua2SAlJPkGSh4lM_bmI10gWwpb9gqYu8,1
|
|
|
94
95
|
htpolynet/utils/profiling.py,sha256=su7qpGEz6FXVU4KT2HQDWG82bc1sgsfpDQBbAfPpsHc,7331
|
|
95
96
|
htpolynet/utils/stringthings.py,sha256=Mr6o55EM8o4YAaVYpjIJj2IxDToNdbPzb-lpQ3w3jFk,1176
|
|
96
97
|
htpolynet/utils/vmd_viz.py,sha256=Crk3Ln88PKiJ9X7DMMkFEVh2Ru6a1y0RUgj3w6EIgFc,10867
|
|
97
|
-
htpolynet-2.
|
|
98
|
-
htpolynet-2.
|
|
99
|
-
htpolynet-2.
|
|
100
|
-
htpolynet-2.
|
|
101
|
-
htpolynet-2.
|
|
98
|
+
htpolynet-2.3.1.dist-info/METADATA,sha256=tXtk99WECunWtlinNhiRCqy6z8XiB6bzZMcDrEdB1Ms,6036
|
|
99
|
+
htpolynet-2.3.1.dist-info/WHEEL,sha256=zOwg4jB6zX2kU910N-cMawjivD6tO8NEWvE12je1bVk,87
|
|
100
|
+
htpolynet-2.3.1.dist-info/entry_points.txt,sha256=G5tx55llJf-IV9dIe7J8myGdyrhCVggCAhKrVNGP_s0,48
|
|
101
|
+
htpolynet-2.3.1.dist-info/licenses/LICENSE,sha256=piPSGqJdmTGyzF9HOnjlO2KvgOKT8NHwhCuGYM778tY,1071
|
|
102
|
+
htpolynet-2.3.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|