Skip to content
Open
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: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ Now, create the anaconda environment for AutoTST

Modify environment variables. Add AutoTST to the `PYTHONPATH` to ensure that you can access modules from any folder. Modify your ~/.bashrc file by adding the following line:

- `export AUTOTST="your_folder/AutoTST`

- `export PYTHONPATH=$AUTOTST:$PYTHONPATH`
- `export PYTHONPATH=/path/to/AutoTST:$PYTHONPATH`

To be able to run AutoTST in any conda environment, you can set your path to the following by modifing your ~/.bashrc:

Expand Down
12 changes: 6 additions & 6 deletions autotst/calculator/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def get_rotor_calc(self,
addsec=[addsec[:-1]])

ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)
return ase_gaussian

def get_conformer_calc(self):
Expand Down Expand Up @@ -232,7 +232,7 @@ def get_conformer_calc(self):
extra=f"opt=(calcfc,maxcycles=900,{self.convergence}) freq IOP(7/33=1,2/16=3) scf=(maxcycle=900)",
multiplicity=self.conformer.rmg_molecule.multiplicity)
ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)
return ase_gaussian

def get_shell_calc(self):
Expand Down Expand Up @@ -293,7 +293,7 @@ def get_shell_calc(self):
addsec=[combos]
)
ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)

return ase_gaussian

Expand Down Expand Up @@ -353,7 +353,7 @@ def get_center_calc(self):
addsec=[addsec[:-1]]
)
ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)

return ase_gaussian

Expand Down Expand Up @@ -399,7 +399,7 @@ def get_overall_calc(self):
extra="opt=(ts,calcfc,noeigentest,maxcycles=900) freq scf=(maxcycle=900) IOP(7/33=1,2/16=3)",
multiplicity=self.conformer.rmg_molecule.multiplicity)
ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)

return ase_gaussian

Expand Down Expand Up @@ -444,7 +444,7 @@ def get_irc_calc(self):
multiplicity=self.conformer.rmg_molecule.multiplicity
)
ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
ase_gaussian.parameters.pop("force", None)

return ase_gaussian

Expand Down
15 changes: 9 additions & 6 deletions autotst/calculator/gaussian_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ..species import Species, Conformer
from ..geometry import Torsion
from .gaussian import Gaussian
from ..utils.paths import project_root, test_bin_dir

import ase
import ase.calculators.gaussian
Expand All @@ -48,7 +49,7 @@

class TestGaussian(unittest.TestCase):
def setUp(self):
os.environ["PATH"] = os.path.expandvars("$AUTOTST/test/bin:") + os.environ["PATH"]
os.environ["PATH"] = f"{test_bin_dir()}:{os.environ['PATH']}"
rxn = Reaction(label='C+[O]O_[CH3]+OO')
ts = rxn.ts["forward"][0]
ts.get_molecules()
Expand Down Expand Up @@ -105,12 +106,14 @@ def test_irc_calc(self):
self.assertIsInstance(calc_dict,dict)

def tearDown(self):
if os.path.exists(os.path.expandvars("$AUTOTST/autotst/calculator/ts")):
shutil.rmtree(os.path.expandvars("$AUTOTST/autotst/calculator/ts"))
if os.path.exists(os.path.expandvars("$AUTOTST/autotst/calculator/species")):
shutil.rmtree(os.path.expandvars("$AUTOTST/autotst/calculator/species"))
ts_dir = project_root() / "autotst" / "calculator" / "ts"
species_dir = project_root() / "autotst" / "calculator" / "species"
if os.path.exists(ts_dir):
shutil.rmtree(ts_dir)
if os.path.exists(species_dir):
shutil.rmtree(species_dir)

if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))



23 changes: 12 additions & 11 deletions autotst/calculator/orca_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@

from .orca import Orca
from ..species import Conformer
from ..utils.paths import project_root, test_data_dir

class TestOrca(unittest.TestCase):

def setUp(self):
conf = Conformer(smiles='C')
self.orca = Orca(conformer=conf, directory=os.path.expandvars(
"$AUTOTST/autotst/calculator/fod"))
self.orca = Orca(
conformer=conf,
directory=str(project_root() / "autotst" / "calculator" / "fod")
)

def test_load_conformer_attributes(self):
charge = 0
Expand All @@ -59,21 +62,19 @@ def test_write_fod_input(self):
self.assertTrue(os.path.exists(os.path.join(self.orca.directory,'C_fod.inp')))

def test_check_normal_termination(self):
path = os.path.expandvars(
"$AUTOTST/test/bin/log-files/C_fod.log")
self.assertTrue(self.orca.check_normal_termination(path))
path = test_data_dir() / "C_fod.log"
self.assertTrue(self.orca.check_normal_termination(str(path)))

def test_read_fod_log(self):
path = os.path.expandvars(
"$AUTOTST/test/bin/log-files/C_fod.log")
fod = self.orca.read_fod_log(path)
path = test_data_dir() / "C_fod.log"
fod = self.orca.read_fod_log(str(path))
self.assertEquals(float(0.000025),fod)

def tearDown(self):

if os.path.exists(os.path.expandvars("$AUTOTST/autotst/calculator/fod")):
shutil.rmtree(os.path.expandvars(
"$AUTOTST/autotst/calculator/fod"))
fod_dir = project_root() / "autotst" / "calculator" / "fod"
if os.path.exists(fod_dir):
shutil.rmtree(fod_dir)

if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
15 changes: 8 additions & 7 deletions autotst/calculator/statmech_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import unittest, os, sys, shutil
from ..reaction import Reaction
from .statmech import StatMech
from ..utils.paths import project_root, test_data_dir, test_dir
import rmgpy.reaction
import rmgpy.kinetics

Expand All @@ -40,12 +41,12 @@ def setUp(self):
self.reaction.get_labeled_reaction()
self.reaction.generate_reactants_and_products()

directory = os.path.expandvars("$AUTOTST/test")
directory = test_dir()
if not os.path.exists(os.path.join(directory, "ts", self.reaction.label)):
os.makedirs(os.path.join(directory, "ts", self.reaction.label))
if not os.path.exists(os.path.join(directory, "ts", self.reaction.label, self.reaction.label + ".log")):
shutil.copy(
os.path.join(directory, "bin", "log-files", self.reaction.label + "_forward_0.log"),
test_data_dir() / f"{self.reaction.label}_forward_0.log",
os.path.join(directory, "ts", self.reaction.label, self.reaction.label + ".log")
)

Expand All @@ -55,24 +56,24 @@ def setUp(self):
os.makedirs(os.path.join(directory, "species", smiles))
if not os.path.exists(os.path.join(directory, "species", smiles, smiles+".log")):
shutil.copy(
os.path.join(directory, "bin", "log-files", smiles + "_0.log"),
test_data_dir() / f"{smiles}_0.log",
os.path.join(directory, "species", smiles, smiles+".log")
)

self.statmech = StatMech(
reaction = self.reaction,
directory = directory
directory = str(directory)
)

def tearDown(self):
try:
directory = os.path.expandvars("$AUTOTST/test")
directory = test_dir()
if os.path.exists(os.path.join(directory, "ts")):
shutil.rmtree(os.path.join(directory, "ts"))
if os.path.exists(os.path.join(directory, "species")):
shutil.rmtree(os.path.join(directory, "species"))

for head, _, files in os.walk(os.path.expandvars("$AUTOTST")):
for head, _, files in os.walk(project_root()):
for fi in files:
if fi.endswith(".symm"):
os.remove(os.path.join(head, fi))
Expand Down Expand Up @@ -176,4 +177,4 @@ def test_set_results(self):
if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))



19 changes: 9 additions & 10 deletions autotst/calculator/vibrational_analysis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
from ..reaction import Reaction, TS
from ..species import Species, Conformer
from .vibrational_analysis import percent_change, VibrationalAnalysis
from ..utils.paths import project_root, test_data_dir, test_dir

class VibrationalAnalysisTest(unittest.TestCase):

Expand All @@ -48,29 +49,28 @@ def setUp(self):
self.ts = self.reaction.ts["forward"][0]
self.ts.get_molecules()

directory = os.path.expandvars("$AUTOTST/test")
directory = test_dir()
if not os.path.exists(os.path.join(directory, "ts", self.reaction.label, "conformers")):
os.makedirs(os.path.join(directory, "ts", self.reaction.label, "conformers"))
if not os.path.exists(os.path.join(directory, "ts", self.reaction.label, self.reaction.label + ".log")):
shutil.copy(
os.path.join(directory, "bin", "log-files", self.reaction.label + "_forward_0.log"),
test_data_dir() / f"{self.reaction.label}_forward_0.log",
os.path.join(directory, "ts", self.reaction.label, "conformers", self.reaction.label + "_forward_0.log")
)

self.directory = directory
self.vibrational_analysis = VibrationalAnalysis(
transitionstate = self.ts,
directory = self.directory
directory = str(self.directory)
)

self.reaction2 = Reaction("[CH3]+CC(F)(F)F_C+[CH2]C(F)(F)F")
self.reaction2.get_labeled_reaction()
self.ts2 = self.reaction2.ts["forward"][0]
log_file = os.path.join(
directory, "bin", "log-files", "[CH3]+CC(F)(F)F_C+[CH2]C(F)(F)F.log")
log_file = test_data_dir() / "[CH3]+CC(F)(F)F_C+[CH2]C(F)(F)F.log"
self.vibrational_analysis2 = VibrationalAnalysis(
transitionstate = self.ts2,
log_file = log_file
log_file = str(log_file)
)

def test_get_log_file(self):
Expand Down Expand Up @@ -140,14 +140,13 @@ def test_validate(self):
if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
try:
directory = os.path.expandvars("$AUTOTST/test")
directory = test_dir()
if os.path.exists(os.path.join(directory, "ts")):
shutil.rmtree(os.path.join(directory, "ts"))

for head, _, files in os.walk(os.path.expandvars("$AUTOTST")):
for head, _, files in os.walk(project_root()):
for fi in files:
if fi.endswith(".symm"):
os.remove(os.path.join(head, fi))
except:
except Exception:
None

14 changes: 6 additions & 8 deletions autotst/data/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import autotst
from ..reaction import Reaction
from .base import QMData, DistanceData, TransitionStates, TransitionStateDepository, TSGroups
from ..utils.paths import database_dir, test_data_dir
import rmgpy
import rmgpy.data.rmg

Expand All @@ -61,7 +62,8 @@ def test_get_qmdata(self):
A method that is designed to obtain the QM data for a transitionstate or molecule
Returns a qmdata object
"""
self.qmdata.get_qmdata(os.path.expandvars("$AUTOTST/test/bin/log-files/CC+[O]O_[CH2]C+OO_forward_0.log"))
log_path = test_data_dir() / "CC+[O]O_[CH2]C+OO_forward_0.log"
self.qmdata.get_qmdata(str(log_path))

self.assertEqual(self.qmdata.ground_state_degeneracy, 2)
self.assertAlmostEqual(self.qmdata.molecular_mass[0], 126.1, places=1)
Expand Down Expand Up @@ -154,9 +156,7 @@ def setUp(self):
self.ts_depository = TransitionStateDepository(label="test")

self.settings = {
"file_path": os.path.join(
os.path.expandvars("$AUTOTST"), "database", "H_Abstraction", "TS_training", "reactions.py"
),
"file_path": str(database_dir() / "H_Abstraction" / "TS_training" / "reactions.py"),
"local_context": {"DistanceData":DistanceData},
"global_context": {'__builtins__': None}
}
Expand All @@ -176,9 +176,7 @@ def setUp(self):
self.ts_groups = TSGroups(label="test")

self.settings = {
"file_path": os.path.join(
os.path.expandvars("$AUTOTST"), "database", "H_Abstraction", "TS_groups.py"
),
"file_path": str(database_dir() / "H_Abstraction" / "TS_groups.py"),
"local_context": {"DistanceData":DistanceData},
"global_context": {'__builtins__': None}
}
Expand Down Expand Up @@ -211,4 +209,4 @@ def test_estimate_distances_using_group_additivity(self):
self.assertAlmostEquals(d23, distance_data.distances["d23"], places=1)

if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
39 changes: 9 additions & 30 deletions autotst/data/inputoutput_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
from ..reaction import Reaction
from .base import QMData, DistanceData
from .inputoutput import InputOutput
from ..utils.paths import test_data_dir, test_dir
import rmgpy.kinetics

class TestInputOutput(unittest.TestCase):
Expand All @@ -46,54 +47,32 @@ def setUp(self):
self.reaction = Reaction("CC+[O]O_[CH2]C+OO")
self.io = InputOutput(
reaction=self.reaction,
directory=os.path.expandvars("$AUTOTST/test/")
directory=str(test_dir())
)
try:
os.makedirs(os.path.join(
os.path.expandvars("$AUTOTST/test/"),
"ts",
self.reaction.label
))
os.makedirs(test_dir() / "ts" / self.reaction.label)
except OSError:
try:
shutil.copy(
os.path.join(
os.path.expandvars("$AUTOTST/test/bin/log-files"),
self.reaction.label + "_forward_0.log"
),
os.path.join(
os.path.expandvars("$AUTOTST/test/"),
"ts",
self.reaction.label,
self.reaction.label + ".log"
)
test_data_dir() / f"{self.reaction.label}_forward_0.log",
test_dir() / "ts" / self.reaction.label / f"{self.reaction.label}.log"
)
except:
except Exception:
pass


def test_ts_file_path(self):
path = self.io.get_ts_file_path()
self.assertEqual(
path,
os.path.join(
os.path.expandvars("$AUTOTST/test/"),
"ts",
self.reaction.label,
self.reaction.label + ".ts"
)
str(test_dir() / "ts" / self.reaction.label / f"{self.reaction.label}.ts")
)

def test_kinetics_file_path(self):
path = self.io.get_kinetics_file_path()
self.assertEqual(
path,
os.path.join(
os.path.expandvars("$AUTOTST/test/"),
"ts",
self.reaction.label,
self.reaction.label + ".kinetics"
)
str(test_dir() / "ts" / self.reaction.label / f"{self.reaction.label}.kinetics")
)

def test_get_qmdata(self):
Expand Down Expand Up @@ -123,4 +102,4 @@ def test_kinetics_io(self):


if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
Loading