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

AutoTST Updates #92

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
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
89 changes: 89 additions & 0 deletions .github/workflows/cont_int.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main
types: [opened, synchronize, reopened, ready_for_review]
schedule:
- cron: '0 0 * * *'


jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
shell: bash -el {0}

steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Checkout RMG-Py
uses: actions/checkout@v3
with:
repository: ReactionMechanismGenerator/RMG-Py
path: RMG-Py
ref: main
fetch-depth: 1

- name: Checkout RMG-database
uses: actions/checkout@v3
with:
repository: ReactionMechanismGenerator/RMG-database
path: RMG-database
ref: main
fetch-depth: 1

- name: Set up AutoTST
uses: conda-incubator/setup-miniconda@v2
with:
environment-file: environment.yml
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: tst_env
use-mamba: true

- name: Update Environment
run: |
mamba env update -f environment.yml

- name: Add AUTOTST to ENV
run: |
export AUTOTST=$(pwd)
export PYTHONPATH=$PYTHONPATH:$AUTOTST
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> $GITHUB_ENV
echo 'export PATH=$PATH:'"$(pwd)" >> $GITHUB_ENV
echo 'export PYTHONPATH=$PYTHONPATH:'"$(pwd)" >> ~/.bashrc
echo 'export PATH=$PATH:'"$(pwd)" >> ~/.bashrc

- name: Install RMG-Py
run: |
cd RMG-Py
mamba env create -f environment.yml
cd ..

- name: Cythonize RMG-Py
run: |
cd RMG-Py
conda activate rmg_env
make
echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> $GITHUB_ENV
echo "PATH=$(pwd):$PATH" >> $GITHUB_ENV
echo "export rmgpy_path=$(pwd)" >> $GITHUB_ENV
echo "PYTHONPATH=$(pwd):$PYTHONPATH" >> ~/.bashrc
echo "PATH=$(pwd):$PATH" >> ~/.bashrc
echo "export rmgpy_path=$(pwd)" >> ~/.bashrc

- name: Unittest
run: |
source ~/.bashrc
conda activate tst_env
make unittests

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
*.symm
*.ase
*.com
*.log

*.ts
*.kinetics
25 changes: 16 additions & 9 deletions autotst/calculator/gaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@
import cclib.io

import autotst
from ..reaction import Reaction, TS
from ..species import Species, Conformer
from ..geometry import Torsion
from autotst.reaction import Reaction, TS
from autotst.species import Species, Conformer
from autotst.geometry import Torsion

import ase
import ase.calculators.gaussian
Expand Down Expand Up @@ -179,7 +179,8 @@ def get_rotor_calc(self,
addsec=[addsec[:-1]])

ase_gaussian.atoms = self.conformer.ase_molecule
del ase_gaussian.parameters['force']
if 'force' in ase_gaussian.parameters:
del ase_gaussian.parameters['force']
return ase_gaussian

def get_conformer_calc(self):
Expand Down Expand Up @@ -232,7 +233,8 @@ 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']
if 'force' in ase_gaussian.parameters:
del ase_gaussian.parameters['force']
return ase_gaussian

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

return ase_gaussian

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

if 'force' in ase_gaussian.parameters:
del ase_gaussian.parameters['force']

return ase_gaussian

Expand Down Expand Up @@ -399,7 +404,8 @@ 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']
if 'force' in ase_gaussian.parameters:
del ase_gaussian.parameters['force']

return ase_gaussian

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

return ase_gaussian

Expand Down
22 changes: 12 additions & 10 deletions autotst/calculator/gaussian_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@
import cclib.io

import autotst
from ..reaction import Reaction, TS
from ..species import Species, Conformer
from ..geometry import Torsion
from .gaussian import Gaussian
from autotst.common import AUTOTST_PATH
from autotst.reaction import Reaction, TS
from autotst.species import Species, Conformer
from autotst.geometry import Torsion
from autotst.calculator.gaussian import Gaussian


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

class TestGaussian(unittest.TestCase):
def setUp(self):
os.environ["PATH"] = os.path.expandvars("$AUTOTST/test/bin:") + os.environ["PATH"]
os.environ["PATH"] = os.path.join(AUTOTST_PATH, "test/bin") + os.pathsep + os.environ["PATH"]
rxn = Reaction(label='C+[O]O_[CH3]+OO')
ts = rxn.ts["forward"][0]
ts.get_molecules()
Expand Down Expand Up @@ -105,11 +107,11 @@ 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"))

if os.path.exists(os.path.join(AUTOTST_PATH, "calculator/ts")):
shutil.rmtree(os.path.join(AUTOTST_PATH, "calculator/ts"))
if os.path.exists(os.path.join(AUTOTST_PATH, "calculator/species")):
shutil.rmtree(os.path.join(AUTOTST_PATH, "calculator/species"))
if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))

Expand Down
22 changes: 10 additions & 12 deletions autotst/calculator/orca_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,17 @@
import unittest
import os, shutil

from .orca import Orca
from ..species import Conformer
from autotst.common import AUTOTST_PATH
from autotst.calculator.orca import Orca
from autotst.species import Conformer



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=os.path.join(AUTOTST_PATH,"calculator/fod"))

def test_load_conformer_attributes(self):
charge = 0
Expand All @@ -59,21 +61,17 @@ 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")
path = os.path.join(AUTOTST_PATH,"test/bin/log-files/C_fod.log")
self.assertTrue(self.orca.check_normal_termination(path))

def test_read_fod_log(self):
path = os.path.expandvars(
"$AUTOTST/test/bin/log-files/C_fod.log")
path = os.path.join(AUTOTST_PATH,"test/bin/log-files/C_fod.log")
fod = self.orca.read_fod_log(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"))
if os.path.exists(os.path.join(AUTOTST_PATH,"calculator/fod")):
shutil.rmtree(os.path.join(AUTOTST_PATH,"calculator/fod"))

if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
11 changes: 6 additions & 5 deletions autotst/calculator/statmech_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
##########################################################################

import unittest, os, sys, shutil
from ..reaction import Reaction
from .statmech import StatMech
from autotst.common import AUTOTST_PATH
from autotst.reaction import Reaction
from autotst.calculator.statmech import StatMech
import rmgpy.reaction
import rmgpy.kinetics

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

directory = os.path.expandvars("$AUTOTST/test")
directory = os.path.join(AUTOTST_PATH, "test")
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")):
Expand All @@ -66,13 +67,13 @@ def setUp(self):

def tearDown(self):
try:
directory = os.path.expandvars("$AUTOTST/test")
directory = os.path.join(AUTOTST_PATH, "test")
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(AUTOTST_PATH):
for fi in files:
if fi.endswith(".symm"):
os.remove(os.path.join(head, fi))
Expand Down
13 changes: 7 additions & 6 deletions autotst/calculator/vibrational_analysis_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
import cclib.io
import rmgpy
import rmgpy.molecule
from ..reaction import Reaction, TS
from ..species import Species, Conformer
from .vibrational_analysis import percent_change, VibrationalAnalysis
from autotst.common import AUTOTST_PATH
from autotst.reaction import Reaction, TS
from autotst.species import Species, Conformer
from autotst.calculator.vibrational_analysis import percent_change, VibrationalAnalysis

class VibrationalAnalysisTest(unittest.TestCase):

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

directory = os.path.expandvars("$AUTOTST/test")
directory = os.path.join(AUTOTST_PATH,"test")
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")):
Expand Down Expand Up @@ -140,11 +141,11 @@ def test_validate(self):
if __name__ == "__main__":
unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
try:
directory = os.path.expandvars("$AUTOTST/test")
directory = os.path.join(AUTOTST_PATH, "test")
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(AUTOTST_PATH):
for fi in files:
if fi.endswith(".symm"):
os.remove(os.path.join(head, fi))
Expand Down
22 changes: 22 additions & 0 deletions autotst/common.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""

This module contains common functions that are used throughout AutoTST
Therefore, it should not import any other AutoTST modules to avoid circular imports

"""

import os

import rmgpy


# Absolute path to the AutoTST directory
AUTOTST_PATH = os.path.dirname(os.path.abspath(__file__))
# Absolute path to the AutoTST database directory - One directory above AUTOTST_PATH
AUTOTST_DATABASE_PATH = os.path.abspath(os.path.join(AUTOTST_PATH, os.pardir))
# Abolsute path to RMG-Py directory
RMG_PY_PATH = os.path.abspath(os.path.dirname(os.path.dirname(rmgpy.__file__)))
# Absolute path to the RMG-database directory
RMG_DATABASE_PATH = os.path.abspath(os.path.dirname(os.path.dirname(rmgpy.settings['database.directory'])))

VERSION = "1.0.0"
11 changes: 6 additions & 5 deletions autotst/data/base_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@
import logging
import numpy as np
import autotst
from ..reaction import Reaction
from .base import QMData, DistanceData, TransitionStates, TransitionStateDepository, TSGroups
from autotst.common import AUTOTST_PATH, AUTOTST_DATABASE_PATH
from autotst.reaction import Reaction
from autotst.data.base import QMData, DistanceData, TransitionStates, TransitionStateDepository, TSGroups
import rmgpy
import rmgpy.data.rmg

Expand All @@ -61,7 +62,7 @@ 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"))
self.qmdata.get_qmdata(os.path.join(AUTOTST_PATH, "test", "bin", "log-files", "CC+[O]O_[CH2]C+OO_forward_0.log"))

self.assertEqual(self.qmdata.ground_state_degeneracy, 2)
self.assertAlmostEqual(self.qmdata.molecular_mass[0], 126.1, places=1)
Expand Down Expand Up @@ -155,7 +156,7 @@ def setUp(self):

self.settings = {
"file_path": os.path.join(
os.path.expandvars("$AUTOTST"), "database", "H_Abstraction", "TS_training", "reactions.py"
os.path.join(AUTOTST_DATABASE_PATH, "database", "H_Abstraction", "TS_training", "reactions.py")
),
"local_context": {"DistanceData":DistanceData},
"global_context": {'__builtins__': None}
Expand All @@ -177,7 +178,7 @@ def setUp(self):

self.settings = {
"file_path": os.path.join(
os.path.expandvars("$AUTOTST"), "database", "H_Abstraction", "TS_groups.py"
os.path.join(AUTOTST_DATABASE_PATH, "database", "H_Abstraction", "TS_groups.py")
),
"local_context": {"DistanceData":DistanceData},
"global_context": {'__builtins__': None}
Expand Down
Loading
Loading