Skip to content

Instantly share code, notes, and snippets.

View ghutchis's full-sized avatar

Geoff Hutchison ghutchis

View GitHub Profile
@ghutchis
ghutchis / molml.py
Last active April 20, 2024 16:30
Open Babel / Pybel script to report all bonds, angles, torsions, and non-bonded interactions
#!/usr/bin/env python
import sys, os
from openbabel import openbabel as ob
from openbabel import pybel
# syntax:
# molml.py [files]
@ghutchis
ghutchis / atomtype.cpp
Last active March 6, 2024 21:16
Avogadro2 Atom symbols and Neighbors
auto graph = m_molecule->graph();
for (Index i = 0; i < m_molecule->atomCount(); ++i)
{
// print the symbol for the atom
Core::Atom atom = m_molecule->atom(i);
std::string atomType = Core::Elements::symbol(atom.atomicNumber());
std::cout << "Atom " << atomType << " (" << i << ")" << std::endl;
// check neighbors
@ghutchis
ghutchis / test-avoscript.py
Created October 1, 2023 23:46
Avogadro Script Command Tester
#!/usr/bin/env python
import sys
import json
import subprocess
# example molecule for testing
water = {
"chemicalJson": 1,
"atoms": {
@ghutchis
ghutchis / orbitals.py
Created September 14, 2023 02:57
Avogadro Batch Render Orbitals
#!/usr/bin/python
import json
import socket
import struct
import glob
import tempfile
import os
import time
@ghutchis
ghutchis / data.py
Created October 21, 2018 18:25
Normal Mode Conformer Generation using cclib and OpenBabel Python
element_symbols = [
"Xx", "H", "He", "Li", "Be", "B", "C", "N", "O", "F",
"Ne", "Na", "Mg", "Al", "Si", "P", "S", "Cl", "Ar", "K",
"Ca", "Sc", "Ti", "V", "Cr", "Mn", "Fe", "Co", "Ni", "Cu",
"Zn", "Ga", "Ge", "As", "Se", "Br", "Kr", "Rb", "Sr", "Y",
"Zr", "Nb", "Mo", "Tc", "Ru", "Rh", "Pd", "Ag", "Cd", "In",
"Sn", "Sb", "Te", "I", "Xe", "Cs", "Ba", "La", "Ce", "Pr",
"Nd", "Pm", "Sm", "Eu", "Gd", "Tb", "Dy", "Ho", "Er", "Tm",
"Yb", "Lu", "Hf", "Ta", "W", "Re", "Os", "Ir", "Pt", "Au",
@ghutchis
ghutchis / cclib-rdkit.py
Created August 4, 2023 20:55
Import cclib files to RDKit molecules
#!/usr/bin/env python
import sys
import os
import cclib
from cclib.parser import ccopen
from rdkit import Chem
try:
@ghutchis
ghutchis / scan-dihedrals.py
Created October 1, 2019 16:31
Scan dihedral angles using Open Babel (here using random angles)
#!/usr/bin/env python
from __future__ import print_function
import sys
import os
import math
import random
import pybel
@ghutchis
ghutchis / screenshots.py
Created April 9, 2023 18:58
Avogadro2 XYZ directory to PNG
#!/usr/bin/python
import json
import socket
import struct
import glob
import tempfile
import os
class Connection:
@ghutchis
ghutchis / nConf20.py
Created May 17, 2021 15:46
nConf20 descriptor from Wicker and Cooper 2016 - https://pubs.acs.org/doi/10.1021/acs.jcim.6b00565
# 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 / globalopt.py
Created August 7, 2019 01:25
Convert non-3D molecules to 3D using Open Babel
#!/usr/bin/env python
import sys, os
import pybel
ob = pybel.ob
# read through multiple files on command-line
for argument in sys.argv[1:]: