Skip to content

Commit

Permalink
Merge pull request #167 from hjkgrp/issue134
Browse files Browse the repository at this point in the history
Issue134
  • Loading branch information
ralf-meyer committed Aug 25, 2023
2 parents 1a25e5c + e078904 commit b9f8f23
Show file tree
Hide file tree
Showing 18 changed files with 216 additions and 218 deletions.
8 changes: 4 additions & 4 deletions molSimplify/Classes/mol3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ def getBondedAtomsBOMatrixAug(self, idx):
nats.append(i)
return nats

def getBondCutoff(self, atom, ratom):
def getBondCutoff(self, atom: atom3D, ratom: atom3D) -> float:
"""
Get cutoff based on two atoms.
Expand All @@ -1632,15 +1632,15 @@ def getBondCutoff(self, atom, ratom):
distance_max = min(2.75, distance_max) # 2.75 by 07/22/2021
if ratom.symbol() == "C" and not atom.symbol() == "H":
distance_max = min(2.75, distance_max) # 2.75 by 07/22/2021
if ratom.symbol() == "H" and atom.ismetal:
if ratom.symbol() == "H" and atom.ismetal():
# tight cutoff for metal-H bonds
distance_max = 1.1 * (atom.rad + ratom.rad)
if atom.symbol() == "H" and ratom.ismetal:
if atom.symbol() == "H" and ratom.ismetal():
# tight cutoff for metal-H bonds
distance_max = 1.1 * (atom.rad + ratom.rad)
return distance_max

def getBondedAtoms(self, idx):
def getBondedAtoms(self, idx: int) -> List[int]:
"""
Gets atoms bonded to a specific atom. This is determined based on
element-specific distance cutoffs, rather than predefined valences.
Expand Down
35 changes: 19 additions & 16 deletions tests/helperFuncs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import random
import shutil
import numpy as np
from typing import List
from molSimplify.Scripts.geometry import kabsch, distance
from molSimplify.Scripts.generator import startgen
from molSimplify.Classes.globalvars import (dict_oneempty_check_st,
Expand All @@ -14,7 +15,7 @@
from pathlib import Path


def is_number(s):
def is_number(s: str) -> bool:
"""check whether the string is a integral/float/scientific"""
try:
float(s)
Expand All @@ -33,11 +34,11 @@ def working_directory(path: Path):
os.chdir(prev_cwd)


def fuzzy_equal(x1, x2, thresh):
def fuzzy_equal(x1, x2, thresh: float) -> bool:
return np.fabs(float(x1) - float(x2)) < thresh


def fuzzy_compare_xyz(xyz1, xyz2, thresh):
def fuzzy_compare_xyz(xyz1, xyz2, thresh: float) -> bool:
fuzzyEqual = False
mol1 = mol3D()
mol1.readfromxyz(xyz1)
Expand Down Expand Up @@ -86,9 +87,7 @@ def getAllLigands(xyz):
return ligands


def getMetalLigBondLength(mymol3d):
# findMetal only returns 1 metal atom?
# TG: fixed findmetal to return a list
def getMetalLigBondLength(mymol3d: mol3D) -> List[float]:
mm = mymol3d.findMetal()[0]
bonded = mymol3d.getBondedAtoms(mm)
blength = []
Expand All @@ -98,39 +97,43 @@ def getMetalLigBondLength(mymol3d):
return blength


def compareNumAtoms(xyz1, xyz2):
def compareNumAtoms(xyz1, xyz2) -> bool:
"""Compare number of atoms"""
print("Checking total number of atoms")
mol1 = mol3D()
mol1.readfromxyz(xyz1)
mol2 = mol3D()
mol2.readfromxyz(xyz1)
mol2.readfromxyz(xyz2)
# Compare number of atoms
passNumAtoms = (mol1.natoms == mol2.natoms)
print("Pass total number of atoms check: ", passNumAtoms)
return passNumAtoms


def compareMLBL(xyz1, xyz2, thresh):
def compareMLBL(xyz1, xyz2, thresh: float) -> bool:
"""Compare Metal Ligand Bond Length"""
print("Checking metal-ligand bond length")
mol1 = mol3D()
mol1.readfromxyz(xyz1)
mol2 = mol3D()
mol2.readfromxyz(xyz1)
mol2.readfromxyz(xyz2)
bl1 = getMetalLigBondLength(mol1)
bl2 = getMetalLigBondLength(mol2)
passMLBL = True
for i in range(0, len(bl1)):
if not fuzzy_equal(bl1[i], bl2[i], thresh):
print("Error! Metal-Ligand bondlength mismatch for bond # ", i)
passMLBL = False
if len(bl1) != len(bl2):
print("Error! Number of metal-ligand bonds is different")
passMLBL = False
else:
for i in range(0, len(bl1)):
if not fuzzy_equal(bl1[i], bl2[i], thresh):
print("Error! Metal-Ligand bondlength mismatch for bond # ", i)
passMLBL = False
print("Pass metal-ligand bond length check: ", passMLBL)
print("Threshold for bondlength difference: ", thresh)
return passMLBL


def compareLG(xyz1, xyz2, thresh):
def compareLG(xyz1, xyz2, thresh: float) -> bool:
"""Compare Ligand Geometry"""
print("Checking the Ligand Geometries")
passLG = True
Expand All @@ -152,7 +155,7 @@ def compareLG(xyz1, xyz2, thresh):
return passLG


def compareOG(xyz1, xyz2, thresh):
def compareOG(xyz1, xyz2, thresh: float) -> bool:
print("Checking the overall geometry")
passOG = fuzzy_compare_xyz(xyz1, xyz2, thresh)
print("Pass overall geometry check: ", passOG)
Expand Down
2 changes: 1 addition & 1 deletion tests/inputs/molcas_caspt2.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-oxstate II
-lig water
-smicat 0
-ff mmff94
-ff uff
-keepHs True
-qccode MOLCAS
-method CASPT2
Expand Down
2 changes: 1 addition & 1 deletion tests/inputs/molcas_casscf.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
-oxstate II
-lig water
-smicat 0
-ff mmff94
-ff uff
-keepHs True
-qccode MOLCAS
-method CASSCF
Expand Down
4 changes: 2 additions & 2 deletions tests/inputs/orca_ccsdt.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
-oxstate II
-lig N1C=CC=C1
-runtyp Opt
-smicat 0
-smicat 1
-qccode orca
-ff mmff94
-ffoption ba
-keepHs True
-keepHs False
-qoption REL DKH2
4 changes: 2 additions & 2 deletions tests/inputs/orca_dft.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
-oxstate II
-lig N1C=CC=C1
-runtyp Opt
-smicat 0
-smicat 1
-qccode orca
-ff mmff94
-keepHs True
-keepHs False
-qoption REL DKH2
-qoption HFX 0.2
1 change: 1 addition & 0 deletions tests/inputs/tutorial_09_part_one.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
-oxstate II
-spin 1
-geometry tbp
-ffoption L
1 change: 1 addition & 0 deletions tests/inputs/tutorial_09_part_two.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
-replig true
-oxstate II
-spin 1
-ffoption BA
1 change: 1 addition & 0 deletions tests/inputs/tutorial_10_part_one.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
-ligocc 3
-smicat 3,4
-skipANN true
-ffoption L
1 change: 1 addition & 0 deletions tests/inputs/tutorial_10_part_two.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
-ligocc 1 1 1
-smicat 3,4
-skipANN true
-ffoption L
26 changes: 13 additions & 13 deletions tests/refs/orca_ccsdt.report
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ Bad structure?, False
Min_dist (A), 1000
Was ANN used?, True
geo_label, 1
geo_prob, 0.9946129322052002
geo_LSE, 0.6930601425111972
geo_prob, 0.9413718581199646
geo_LSE, 0.6739948349985794
geo_label_trust, very low
sc_label, 1
sc_prob, 0.8634330630302429
sc_LSE, 0.6931470250647405
sc_prob, 0.6407925486564636
sc_LSE, 0.5110593378625077
sc_label_trust, very low
split, 47.12842958921388
split_dist, 18.91462055450386
split, -13.827394459438906
split_dist, 8.552455363508885
This spin, 5
ANN_ground_state, 1
homo, -15.494993125140807
gap, 3.746240116650166
homo_dist, 0.68992805
gap_dist, 0.26609284
ANN_bondl, [2.0098842331388456, 2.0098842331388456, 2.0098842331388456, 2.0098842331388456, 1.9381185776891228, 2.0859009557197328]
ANN_ground_state, 5
homo, -13.793439866573024
gap, 3.4514513871141346
homo_dist, 0.44729072
gap_dist, 0.18568888
ANN_bondl, [2.3605745803152858, 2.3605745803152858, 2.3605745803152858, 2.3605745803152858, 2.2763077827004237, 2.2302417433371216]
homo_trust, high
gap_trust, high
split_trust, very low
Was Catalytic ANN used?, False
Catalytic ANN reason, False
ML-bl (database, A), 1.62
ML-bl (database, A), 2.1
116 changes: 55 additions & 61 deletions tests/refs/orca_ccsdt.xyz
Original file line number Diff line number Diff line change
@@ -1,63 +1,57 @@
61
55
02/06/2019 11:09, XYZ structure generated by mol3D Class, molSimplify
Fe 0.000000 0.000000 0.000000
N -0.710450 0.905404 -0.942135
C -2.086092 0.653124 -1.098946
C -2.802413 1.781697 -0.781450
C -1.872837 2.737795 -0.435990
C -0.622386 2.158343 -0.552520
H -0.116353 0.625454 -1.734749
H -2.507151 -0.290452 -1.420309
H -3.878665 1.886215 -0.806866
H -2.070885 3.756987 -0.132677
H 0.309869 2.668255 -0.351586
N 3.091620 -2.646483 0.044745
C 2.320645 -3.526091 0.708713
C 2.134527 -3.096748 2.006446
C 2.824190 -1.908414 2.130531
C 3.402500 -1.658630 0.903315
H 3.392803 -2.717926 -0.952191
H 1.913992 -4.429877 0.274465
H 1.560655 -3.594725 2.776285
H 2.897089 -1.293143 3.017041
H 4.015705 -0.803045 0.652473
N -1.887583 -1.859670 1.175941
C -3.119868 -2.362594 1.369665
C -3.288409 -3.493150 0.597455
C -2.107525 -3.678967 -0.091830
C -1.265694 -2.654278 0.286712
H -1.487948 -1.009458 1.629729
H -3.856858 -1.932885 2.034989
H -4.173470 -4.112736 0.542749
H -1.885590 -4.472543 -0.792575
H -0.256645 -2.498096 -0.068930
N -3.181000 2.600173 2.667607
C -2.324879 2.849241 3.674525
C -2.028750 1.675379 4.335321
C -2.734109 0.675756 3.698238
C -3.434012 1.279099 2.674121
H -3.576004 3.302370 2.003991
H -1.937618 3.829895 3.917384
H -1.372462 1.560786 5.186893
H -2.737465 -0.375453 3.952795
H -4.091380 0.780875 1.973868
N 1.622876 1.431753 3.894954
C 2.862443 1.953048 3.865710
C 3.281754 2.085788 2.558545
C 2.251046 1.625257 1.766302
C 1.242300 1.230238 2.620626
H 1.062017 1.222117 4.749491
H 3.431885 2.221798 4.745590
H 4.232929 2.474260 2.220314
H 2.240260 1.582105 0.686917
H 0.286199 0.817350 2.328196
N 2.863843 -0.907697 -4.361222
C 4.008098 -0.259645 -4.077501
C 3.948790 0.253401 -2.798174
C 2.716289 -0.100128 -2.289852
C 2.072198 -0.815629 -3.277572
H 2.633034 -1.392491 -5.256495
H 4.840804 -0.164529 -4.761934
H 4.717754 0.821569 -2.292262
H 2.330956 0.135947 -1.308416
H 1.081149 -1.244338 -3.207618
N 0.000000 2.360575 0.000000
C -1.035788 3.192277 0.085736
C -0.643421 4.510582 0.038070
C 0.743144 4.470086 -0.077885
C 1.079671 3.131116 -0.093238
H -2.053859 2.834210 0.195040
H -1.272514 5.379877 0.082074
H 1.415864 5.310455 -0.139639
H 2.076832 2.719004 -0.181012
N 2.360575 0.000000 0.000000
C 3.127732 -0.143112 -1.087315
C 4.468459 -0.063830 -0.781307
C 4.531334 0.033282 0.594336
C 3.225998 0.103080 1.017031
H 2.712594 -0.281119 -2.073654
H 5.296854 -0.103185 -1.473983
H 5.415281 0.067060 1.215491
H 2.913250 0.226033 2.043499
N 0.000000 -2.360575 0.000000
C 0.192850 -3.127647 -1.079157
C 0.083736 -4.468103 -0.780911
C -0.100858 -4.531712 0.585622
C -0.188203 -3.226274 1.003762
H 0.393839 -2.711751 -2.054473
H 0.157469 -5.295719 -1.471497
H -0.182679 -5.415980 1.201590
H -0.374463 -2.911942 2.020304
N -2.360575 0.000000 0.000000
C -3.146744 0.610592 -0.887598
C -4.475194 0.403300 -0.591083
C -4.488687 -0.444346 0.507268
C -3.168394 -0.698140 0.798476
H -2.731623 1.201389 -1.695534
H -5.327958 0.808217 -1.116916
H -5.352374 -0.842062 1.021054
H -2.782647 -1.346045 1.574617
N 0.000000 0.000000 2.276308
C -0.796690 0.836404 2.986431
C -0.516315 0.556546 4.312459
C 0.470965 -0.484681 4.342641
C 0.774482 -0.815638 3.033991
H -1.455299 1.528309 2.488289
H -0.963294 1.046319 5.168393
H 0.910129 -0.931297 5.226080
H 1.450709 -1.522446 2.580292
N 0.000000 0.000000 -2.230242
C -0.817279 -0.692005 -3.028553
C -0.529141 -0.458721 -4.354299
C 0.428078 0.543987 -4.356027
C 0.639646 0.854835 -3.031705
H -1.555827 -1.372443 -2.622531
H -0.976958 -0.942071 -5.210385
H 0.892624 1.009475 -5.213171
H 1.283841 1.626647 -2.632723
26 changes: 13 additions & 13 deletions tests/refs/orca_dft.report
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ Bad structure?, False
Min_dist (A), 1000
Was ANN used?, True
geo_label, 1
geo_prob, 0.9946129322052002
geo_LSE, 0.6930601425111972
geo_prob, 0.9413718581199646
geo_LSE, 0.6739948349985794
geo_label_trust, very low
sc_label, 1
sc_prob, 0.8634330630302429
sc_LSE, 0.6931470250647405
sc_prob, 0.6407925486564636
sc_LSE, 0.5110593378625077
sc_label_trust, very low
split, 47.12842958921388
split_dist, 18.91462055450386
split, -13.827394459438906
split_dist, 8.552455363508885
This spin, 5
ANN_ground_state, 1
homo, -15.494993125140807
gap, 3.746240116650166
homo_dist, 0.68992805
gap_dist, 0.26609284
ANN_bondl, [2.0098842331388456, 2.0098842331388456, 2.0098842331388456, 2.0098842331388456, 1.9381185776891228, 2.0859009557197328]
ANN_ground_state, 5
homo, -13.793439866573024
gap, 3.4514513871141346
homo_dist, 0.44729072
gap_dist, 0.18568888
ANN_bondl, [2.3605745803152858, 2.3605745803152858, 2.3605745803152858, 2.3605745803152858, 2.2763077827004237, 2.2302417433371216]
homo_trust, high
gap_trust, high
split_trust, very low
Was Catalytic ANN used?, False
Catalytic ANN reason, False
ML-bl (database, A), 1.62
ML-bl (database, A), 2.1
Loading

0 comments on commit b9f8f23

Please sign in to comment.