-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #125 from nlesc-nano/md_asa_test
TST: Add more tests for the MD-ASA workflow
- Loading branch information
Showing
5 changed files
with
134 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,17 @@ on: | |
pull_request: | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
build: | ||
name: ${{ matrix.os }} (py ${{ matrix.version }}${{ matrix.special }}) | ||
name: ${{ matrix.os }}; py ${{ matrix.version }}${{ matrix.special }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
|
@@ -28,21 +36,31 @@ jobs: | |
special: '; slow' | ||
version: '3.10' | ||
env: | ||
CP2K_DATA_DIR: "/usr/share/cp2k" | ||
CP2K_DATA_DIR: "/home/runner/work/nano-CAT/nano-CAT/cp2k/data" | ||
MATCH: "/home/runner/work/nano-CAT/nano-CAT/MATCH/MATCH" | ||
PerlChemistry: "/home/runner/work/nano-CAT/nano-CAT/MATCH/PerlChemistry" | ||
|
||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Install CP2K | ||
- name: Install cp2k | ||
if: matrix.os == 'ubuntu-latest' | ||
run: | | ||
git clone https://github.com/cp2k/cp2k -q | ||
cd cp2k | ||
git -c advice.detachedHead=false checkout tags/v9.1.0 | ||
wget -nv https://github.com/cp2k/cp2k/releases/download/v9.1.0/cp2k-9.1-Linux-x86_64.ssmp -O cp2k.ssmp | ||
chmod a+rx cp2k.ssmp | ||
mv cp2k.ssmp /usr/local/bin/cp2k.popt | ||
- name: Install MATCH | ||
if: matrix.special == '; slow' | ||
run: | | ||
sudo apt-get update | ||
sudo apt install cp2k | ||
git clone https://github.com/nlesc-nano/MATCH -q | ||
cd MATCH | ||
git -c advice.detachedHead=false checkout main | ||
chmod -R a+rx MATCH/scripts | ||
ln -s MATCH/scripts/*.pl /usr/local/bin/ | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
|
@@ -74,7 +92,7 @@ jobs: | |
run: pip list | ||
|
||
- name: Info CP2K | ||
if: matrix.special == '; slow' | ||
if: matrix.os == 'ubuntu-latest' | ||
run: cp2k.popt --version | ||
|
||
- name: Run tests | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
from __future__ import annotations | ||
|
||
import shutil | ||
from pathlib import Path | ||
from collections.abc import Generator | ||
from distutils.spawn import find_executable | ||
|
||
import numpy as np | ||
import yaml | ||
import pytest | ||
from scm.plams import Settings | ||
from assertionlib import assertion | ||
from CAT.base import prep | ||
|
||
PATH = Path("tests") / "test_files" | ||
|
||
|
||
@pytest.mark.skipif(find_executable("cp2k.popt") is None, reason="requires CP2K") | ||
@pytest.mark.slow | ||
class TestMDASA: | ||
SETTINGS = Settings(yaml.load("""\ | ||
path: tests/test_files | ||
input_cores: | ||
- Cd68Se55.xyz | ||
input_ligands: | ||
- 'CCCCCCCCC(=O)O' | ||
optional: | ||
core: | ||
dummy: Cl | ||
ligand: | ||
optimize: True | ||
split: True | ||
functional_groups: 'O(C=O)[H]' | ||
qd: | ||
dirname: QD | ||
optimize: False | ||
activation_strain: | ||
use_ff: True | ||
md: True | ||
dump_csv: True | ||
job1: Cp2kJob | ||
s1: | ||
input: | ||
motion: | ||
md: | ||
steps: | ||
100 | ||
shift_cutoff: True | ||
el_scale14: 1.0 | ||
lj_scale14: 1.0 | ||
distance_upper_bound: 10.0 | ||
forcefield: | ||
charge: | ||
keys: [input, force_eval, mm, forcefield, charge] | ||
Cd: 0.9768 | ||
Se: -0.9768 | ||
O2D2: -0.4704 | ||
C2O3: 0.4524 | ||
epsilon: | ||
unit: kjmol | ||
keys: [input, force_eval, mm, forcefield, nonbonded, lennard-jones] | ||
Cd Cd: 0.3101 | ||
Se Se: 0.4266 | ||
Cd Se: 1.5225 | ||
Cd O2D2: 1.8340 | ||
Se O2D2: 1.6135 | ||
sigma: | ||
unit: nm | ||
keys: [input, force_eval, mm, forcefield, nonbonded, lennard-jones] | ||
Cd Cd: 0.1234 | ||
Se Se: 0.4852 | ||
Cd Se: 0.2940 | ||
Cd O2D2: 0.2471 | ||
Se O2D2: 0.3526 | ||
""", Loader=yaml.SafeLoader)) | ||
|
||
@pytest.fixture(scope="function", autouse=True) | ||
def clear_dirs(self) -> Generator[None, None, None]: | ||
"""Teardown script for deleting directies.""" | ||
yield None | ||
shutil.rmtree(PATH / "database", ignore_errors=True) | ||
shutil.rmtree(PATH / "ligand", ignore_errors=True) | ||
shutil.rmtree(PATH / "qd", ignore_errors=True) | ||
|
||
def test_pass(self) -> None: | ||
df, *_ = prep(self.SETTINGS.copy()) | ||
|
||
values = df["ASA"].values | ||
assertion.eq(values.dtype, np.float64) | ||
assertion.eq(values.shape, (1, 3)) | ||
assertion.assert_(np.isreal, values, post_process=np.all) |