Skip to content
Merged
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
40 changes: 40 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI

on:
push:
branches: [main, uv_tests]
pull_request:

jobs:
test:
strategy:
matrix:
python-version: ['3.14']
os: [ubuntu-latest]

name: Python ${{ matrix.os }} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v5

- name: Install the latest version of uv
uses: astral-sh/setup-uv@v6.5.0 # later versions crash locally: https://github.com/astral-sh/setup-uv/issues/535
with:
enable-cache: true

- name: Install Python
run: uv python install ${{ matrix.python-version }}

- name: Install dependencies
run: uv sync --dev

- run: uv run ruff format .
- run: uv run ruff check .
- run: uv run ty check
- run: uv run pytest --cov --cov-report=xml

- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v5
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,20 @@ env/

# Pytest cache
.pytest_cache/
ruff.out
ty.out

# ruff
.ruff_cache/

# mypy
.mypy_cache/

# Coverage reports
htmlcov/
.coverage
.coverage.*
coverage.xml

# macOS files
.DS_Store
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ Identify bond formation/breaking, angle changes, and dihedral rotations from vib

[![PyPI Downloads](https://static.pepy.tech/badge/vib-analysis)](https://pepy.tech/projects/vib-analysis)
[![PyPI Downloads](https://static.pepy.tech/badge/graphrc)](https://pepy.tech/projects/graphrc)
[![License](https://img.shields.io/github/license/aligfellow/graphrc)](https://github.com/aligfellow/graphrc/blob/main/LICENSE)
[![Powered by: uv](https://img.shields.io/badge/-uv-purple)](https://docs.astral.sh/uv)
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
[![Typing: ty](https://img.shields.io/badge/typing-ty-EFC621.svg)](https://github.com/astral-sh/ty)
[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/aligfellow/graphrc/ci.yml?branch=main&logo=github-actions)](https://github.com/aligfellow/graphrc/actions)
[![Codecov](https://img.shields.io/codecov/c/github/aligfellow/graphrc)](https://codecov.io/gh/aligfellow/graphrc)

---

Expand Down Expand Up @@ -813,3 +819,21 @@ Must contain ≥2 frames.
- Visualization examples with [v.2.0](https://github.com/briling/v) by Ksenia Briling

---

## Developer Setup

To develop with `xyzgraph`, you can clone the repo and use
[`just`](https://github.com/casey/just) and [`uv`](https://docs.astral.sh) to setup the dev environment:

```bash
just setup
```
The cli can be used with:
```bash
uv run xyzgraph filename.xyz
```

Run the checks using:
```bash
just check
```
60 changes: 29 additions & 31 deletions examples/data/expected_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,47 @@
"""

EXPECTED_RESULTS = {
'ambh': {
'bonds': [(2, 11), (11, 18)] # C-H and H-N
"ambh": {
"bonds": [(2, 11), (11, 18)] # C-H and H-N
},
'atrop': {
'dihedrals': [(1, 5, 6, 7), (6, 7, 25, 27)]
"atrop": {"dihedrals": [(1, 5, 6, 7), (6, 7, 25, 27)]},
"bimp": {
"bonds": [(11, 12), (10, 14)], # O-C and C-C
},
'bimp': {
'bonds': [(11, 12), (10, 14)], # O-C and C-C
"cpa": {
"bonds": [(23, 35), (35, 75), (70, 74)] # O-H, H-O, C-C
},
'cpa': {
'bonds': [(23, 35), (35, 75), (70, 74)] # O-H, H-O, C-C
"cycl": {
"bonds": [(2, 6)], # C-N cyclisation
},
'cycl': {
'bonds': [(2, 6)], # C-N cyclisation
"dihedral": {
"dihedrals": [(6, 0, 3, 7)], # F-C-C-F rotation
},
'dihedral': {
'dihedrals': [(6, 0, 3, 7)], # F-C-C-F rotation
"mn-h2": {
"bonds": [(1, 64), (5, 65), (63, 64), (64, 66), (65, 66)], # Mn-H, N-H, H-H, H-O, H-O
},
'mn-h2': {
'bonds': [(1, 64), (5, 65), (63, 64), (64, 66), (65, 66)], # Mn-H, N-H, H-H, H-O, H-O
"mn-hy": {
"bonds": [(1, 67), (67, 77)] # Mn-H, H-C
},
'mn-hy': {
'bonds': [(1, 67), (67, 77)] # Mn-H, H-C
"ru-co-nuc": {
"bonds": [(3, 66), (64, 65), (65, 66)], # N-H, C-N, N-H
},
'ru-co-nuc': {
'bonds': [(3, 66), (64, 65), (65, 66)], # N-H, C-N, N-H
"ru-co": {
"bonds": [(0, 63), (0, 64), (3, 66), (64, 66)], # Ru-O, Ru-C, N-H, C-H
},
'ru-co': {
'bonds': [(0, 63), (0, 64), (3, 66), (64, 66)], # Ru-O, Ru-C, N-H, C-H
"sn2": {
"bonds": [(0, 4), (0, 5)], # C-F and C-Cl
},
'sn2': {
'bonds': [(0, 4), (0, 5)], # C-F and C-Cl
"sn2_large": {
"bonds": [(0, 1), (0, 21)], # C-I and C-N
},
'sn2_large': {
'bonds': [(0, 1), (0, 21)], # C-I and C-N
"spiro-ts1": {
"bonds": [(14, 15)], # C-N
},
'spiro-ts1': {
'bonds': [(14, 15)], # C-N
"spiro-ts2": {
"bonds": [(13, 14)], # O-C
},
'spiro-ts2': {
'bonds': [(13, 14)], # O-C
},
'thia-ma': {
'bonds': [(35, 47)], # C-S
"thia-ma": {
"bonds": [(35, 47)], # C-S
},
}
99 changes: 49 additions & 50 deletions examples/example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -24,46 +24,45 @@
}
],
"source": [
"import os\n",
"from graphrc import run_vib_analysis\n",
"\n",
"vib_trj_dihedral = 'data/dihedral.v000.xyz'\n",
"vib_trj_dihedral = \"data/dihedral.v000.xyz\"\n",
"\n",
"# ORCA_PATH = os.system('which orca')\n",
"# ORCA_PATH = '/path/to/orca'\n",
"\n",
"results = run_vib_analysis(\n",
" input_file=vib_trj_dihedral,\n",
" # bond_tolerance=1.5,\n",
" # angle_tolerance=1.1,\n",
" # dihedral_tolerance=1.0,\n",
" # bond_threshold=0.5,\n",
" # angle_threshold=10.0,\n",
" # dihedral_threshold=20.0,\n",
" # orca_pltvib_path=ORCA_PATH,\n",
" )\n",
"vib = results['vibrational']\n",
" input_file=vib_trj_dihedral,\n",
" # bond_tolerance=1.5,\n",
" # angle_tolerance=1.1,\n",
" # dihedral_tolerance=1.0,\n",
" # bond_threshold=0.5,\n",
" # angle_threshold=10.0,\n",
" # dihedral_threshold=20.0,\n",
" # orca_pltvib_path=ORCA_PATH,\n",
")\n",
"vib = results[\"vibrational\"]\n",
"# print the results that have entries (dont print empty results)\n",
"if vib['bond_changes']:\n",
" print('Bond changes:')\n",
" for bond in vib['bond_changes']:\n",
"if vib[\"bond_changes\"]:\n",
" print(\"Bond changes:\")\n",
" for bond in vib[\"bond_changes\"]:\n",
" print(bond)\n",
"if vib['angle_changes']:\n",
" print('Angle changes:')\n",
" for angle in vib['angle_changes']:\n",
"if vib[\"angle_changes\"]:\n",
" print(\"Angle changes:\")\n",
" for angle in vib[\"angle_changes\"]:\n",
" print(angle)\n",
"if vib['dihedral_changes']:\n",
" print('Dihedral changes:')\n",
" for dihedral in vib['dihedral_changes']:\n",
"if vib[\"dihedral_changes\"]:\n",
" print(\"Dihedral changes:\")\n",
" for dihedral in vib[\"dihedral_changes\"]:\n",
" print(dihedral)\n",
"\n",
"if vib['minor_angle_changes']:\n",
" print('Minor angle changes:')\n",
" for minor_angle in vib['minor_angle_changes']:\n",
"if vib[\"minor_angle_changes\"]:\n",
" print(\"Minor angle changes:\")\n",
" for minor_angle in vib[\"minor_angle_changes\"]:\n",
" print(minor_angle)\n",
"if vib['minor_dihedral_changes']:\n",
" print('Minor dihedral changes:')\n",
" for minor_dihedral in vib['minor_dihedral_changes']:\n",
"if vib[\"minor_dihedral_changes\"]:\n",
" print(\"Minor dihedral changes:\")\n",
" for minor_dihedral in vib[\"minor_dihedral_changes\"]:\n",
" print(minor_dihedral)"
]
},
Expand Down Expand Up @@ -120,19 +119,19 @@
"source": [
"from graphrc import run_vib_analysis\n",
"\n",
"out_file = 'data/spiro-ts1.log'\n",
"out_file = \"data/spiro-ts1.log\"\n",
"\n",
"results = run_vib_analysis(\n",
" input_file=out_file,\n",
" # mode=0, \n",
" print_output=True,\n",
" # bond_tolerance=1.5,\n",
" # angle_tolerance=1.1,\n",
" # dihedral_tolerance=1.0,\n",
" # bond_threshold=0.5,\n",
" # angle_threshold=10.0,\n",
" # dihedral_threshold=20.0,\n",
" )"
" input_file=out_file,\n",
" # mode=0,\n",
" print_output=True,\n",
" # bond_tolerance=1.5,\n",
" # angle_tolerance=1.1,\n",
" # dihedral_tolerance=1.0,\n",
" # bond_threshold=0.5,\n",
" # angle_threshold=10.0,\n",
" # dihedral_threshold=20.0,\n",
")"
]
},
{
Expand All @@ -153,18 +152,18 @@
"source": [
"from graphrc import run_vib_analysis\n",
"\n",
"orca_out = 'data/bimp.v000.xyz'\n",
"orca_out = \"data/bimp.v000.xyz\"\n",
"\n",
"results = run_vib_analysis(\n",
" input_file=orca_out,\n",
" )\n",
" input_file=orca_out,\n",
")\n",
"\n",
"vib = results['vibrational']\n",
"vib = results[\"vibrational\"]\n",
"print(vib)\n",
"\n",
"theoretical_bond_changes = [(11,12), (10,14)]\n",
"if all(bond in vib['bond_changes'] for bond in theoretical_bond_changes):\n",
" print(f'True: All theoretical bond changes {theoretical_bond_changes} found in results.')\n"
"theoretical_bond_changes = [(11, 12), (10, 14)]\n",
"if all(bond in vib[\"bond_changes\"] for bond in theoretical_bond_changes):\n",
" print(f\"True: All theoretical bond changes {theoretical_bond_changes} found in results.\")"
]
},
{
Expand All @@ -184,14 +183,14 @@
"source": [
"from graphRC import run_vib_analysis\n",
"\n",
"orca_out = 'data/sn2_large.v000.xyz'\n",
"orca_out = \"data/sn2_large.v000.xyz\"\n",
"\n",
"results = run_vib_analysis(\n",
" input_file=orca_out,\n",
" )\n",
" input_file=orca_out,\n",
")\n",
"\n",
"vib = results['vibrational']\n",
"print(vib)\n"
"vib = results[\"vibrational\"]\n",
"print(vib)"
]
}
],
Expand Down
Loading