Skip to content

Instantly share code, notes, and snippets.

Avatar
🧑‍💻
I may be slow to respond. Busy writing proposals and teaching

Geoff Hutchison ghutchis

🧑‍💻
I may be slow to respond. Busy writing proposals and teaching
View GitHub Profile
@ghutchis
ghutchis / chemicaljson.py
Last active Aug 4, 2022
Draft pydantic model for Chemical JSON (cjson)
View chemicaljson.py
from __future__ import annotations
from typing import List, Optional
from pydantic import BaseModel, Field
# todo:
# - double-check open-spin systems
# - other suggestions
@ghutchis
ghutchis / cjson.patch
Created Jun 8, 2022
OB CJSON support
View cjson.patch
diff --git a/src/formats/formats.cmake b/src/formats/formats.cmake
index c94c8def2..70ee7d81c 100644
--- a/src/formats/formats.cmake
+++ b/src/formats/formats.cmake
@@ -77,6 +77,7 @@ endif(MSVC OR HAVE_REGEX_H)
if(WITH_JSON)
set(formats_json
chemdoodlejsonformat
+ chemicaljsonformat
pubchemjsonformat
@ghutchis
ghutchis / pywrl.py
Created Feb 3, 2022
Open Babel to VRML script
View pywrl.py
#!/usr/bin/env python
import sys, os, math, random
from openbabel import pybel
from openbabel import openbabel as ob
colors = [ [ 0, 0, 0 ], # Du
[0.75, 0.75, 0.75], # H
[0.85, 1.00, 1.00], # He
@ghutchis
ghutchis / nConf20.py
Created May 17, 2021
nConf20 descriptor from Wicker and Cooper 2016 - https://pubs.acs.org/doi/10.1021/acs.jcim.6b00565
View nConf20.py
# Calculate nConf20 - from https://pubs.acs.org/doi/10.1021/acs.jcim.6b00565
# Jerome G. P. Wicker and Richard I. Cooper J. Chem. Inf. Model. 2016 56(12) pp. 2347-2352
# reformatted for Python3 by Geoffrey R. Hutchison https://hutchison.chem.pitt.edu
from collections import OrderedDict
import fileinput
import numpy as np
from rdkit import Chem
@ghutchis
ghutchis / molml.py
Last active Jul 21, 2022
Open Babel / Pybel script to report all bonds, angles, torsions, and non-bonded interactions
View molml.py
#!/usr/bin/env python
import sys, os
from openbabel import openbabel as ob
from openbabel import pybel
# syntax:
# molml.py [files]
View spectra.py
#!/usr/bin/env python
from __future__ import print_function
import sys
from cclib.parser import ccopen
import logging
def spectra(etens, etoscs, low = 0.5, high = 10.0, resolution = 0.01, smear = 0.04):
"""Return arrays of the energies and intensities of a Lorentzian-blurred spectrum"""
View builder-test.patch
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 1a53e8cdd..bbf92481c 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -23,7 +23,7 @@ set (cpptests
)
set (alias_parts 1)
set (automorphism_parts 1 2 3 4 5 6 7 8 9 10)
-set (builder_parts 1 2 3 4 5)
+set (builder_parts 1 2 3 4 5 6)
@ghutchis
ghutchis / selected atoms.diff
Created Feb 11, 2020
Diff for selected atoms
View selected atoms.diff
diff --git a/avogadro/qtgui/interfacescript.cpp b/avogadro/qtgui/interfacescript.cpp
index f0ad088..c0c2141 100644
--- a/avogadro/qtgui/interfacescript.cpp
+++ b/avogadro/qtgui/interfacescript.cpp
@@ -458,6 +458,14 @@ bool InterfaceScript::insertMolecule(QJsonObject& json,
if (m_moleculeExtension == QLatin1String("None"))
return true;
+ // insert the selected atoms
+ QJsonArray selectedList;
@ghutchis
ghutchis / ob-optimize.py
Created Jan 24, 2020
Open Babel optimizer
View ob-optimize.py
#!/usr/bin/env python
import sys, os
from openbabel import pybel
# read through multiple files on command-line
for argument in sys.argv[1:]:
filename, extension = os.path.splitext(argument)
@ghutchis
ghutchis / ch3co2.sdf
Created Oct 29, 2019
CH3CO2- example
View ch3co2.sdf
ch3co2.sdf
ChemDraw10291910202D
4 3 0 0 0 0 0 0 0 0999 V2000
-0.7145 -0.6187 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 -0.2062 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.7145 -0.6187 0.0000 O 0 5 0 0 0 0 0 0 0 0 0 0
0.0000 0.6187 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
1 2 1 0
2 3 1 0