Skip to content

Commit

Permalink
less intervention when combining charmm parameters to avoid issues wi…
Browse files Browse the repository at this point in the history
…th weird atom types
  • Loading branch information
stefdoerr committed Nov 6, 2023
1 parent 9e2502e commit f0bba2c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 112 deletions.
104 changes: 5 additions & 99 deletions htmd/builder/charmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def combine(prmlist, outfile):
# Process parameter files
prm_list = [
"!COMMENTS\n",
"!ATOMS\n",
"ATOMS\n",
"BONDS\n",
"ANGLES\n",
"DIHEDRALS\n",
Expand Down Expand Up @@ -810,110 +810,16 @@ def combine(prmlist, outfile):
prm_list[context] += _sec_name(fn)
else:
if context == 0: # COMMENTS
if re.search(r"^\s*\!+", line, re.I) or re.search(
r"^\s*\*+", line, re.I
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 1: # ATOMS
if re.search(r"^\s*\!+", line, re.I):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 2: # BONDS
if (
re.search(r"^\s*\!+", line)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[0-9\.\-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 3: # ANGLES
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[0-9\.\-]+\s+",
line,
)
or re.search(r"^\s*\*+", line, re.I)
or len(line.strip()) == 0
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 4: # DIHEDRALS
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[0-9\.\-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 5: # IMPROPER
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[0-9\.\-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 6: # CMAP
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+",
line,
)
or re.search(
r"^\s*[0-9\.-]+\s+[0-9\.-]+\s+[0-9\.-]+\s+[0-9\.-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 7: # NONBONDED
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[_A-Z0-9a-z\.]+\s+[0-9\.\-]+\s+[0-9\.\-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 8: # NBFIX
if (
re.search(r"^\s*\!+", line, re.I)
or re.search(r"^\s*$", line)
or re.search(
r"^\s*[A-Z0-9a-z_]+\s+[A-Z0-9a-z_]+\s+[0-9\.\-]+\s+",
line,
)
):
prm_list[context] += line
else:
prm_list[context] += "!" + line
elif context == 9: # HBOND
if not re.search(r"^END", line, re.I):
prm_list[context] += line
else:
continue
elif not line.lower().startswith("end"):
prm_list[context] += line

prm = "".join(map(str, prm_list)) + "END"
prmfh = open(outfile, "w")
Expand Down
14 changes: 2 additions & 12 deletions htmd/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,19 +170,9 @@ def assertSameAsReferenceDir(compareDir, outdir="."):
outdir, compareDir, toCompare, shallow=False
)
if len(mismatch) != 0 or len(error) != 0 or len(match) != len(toCompare):
logger.error(
"Mismatch while checking directory {} versus reference {}".format(
outdir, compareDir
)
raise Exception(
f"Different results in files {mismatch}: Compare {outdir} and {compareDir}"
)
logger.error("Files being checked: {}".format(toCompare))
for f in mismatch:
logger.error(
" diff {} {}".format(
os.path.join(outdir, f), os.path.join(compareDir, f)
)
)
raise Exception("Mismatch in regression testing.")


def testDHFR():
Expand Down

0 comments on commit f0bba2c

Please sign in to comment.