Skip to content

Instantly share code, notes, and snippets.

View ghutchis's full-sized avatar

Geoff Hutchison ghutchis

View GitHub Profile
@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 / 12steps-of-grad-school.md
Created March 28, 2019 02:35
12 Steps of Grad School

The 12 Steps of Grad School

by Geoff Hutchison (with thanks to Andrew Metz) http://hutchison.chem.pitt.edu/

  1. Initial Optimism: (I will solve problem X and change the world!)
  2. Pessimism: (Hmm, this problem is hard)
  3. Apathy: (Meh, I’m getting okay results, but not great)
  4. Delusion: (I’m not sure what’s going on - it’s complicated)
  5. Cynicism: (Nobody can solve this..)
  6. Procrastination: (Eh, it’s a multi-year project, one day won’t hurt)
@ghutchis
ghutchis / correlated-smarts.py
Created July 18, 2019 17:23
looking for correlated dihedral angles
#!/usr/bin/env python
import sys
import os
import glob
import pybel
# don't need to reimport openbabel
ob = pybel.ob
@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:]:
git fetch origin # get tags
git checkout openbabel-3-0-0a1
cp -pr openbabel openbabel-3.0.0a1
cd openbabel-3.0.0a1
rm .travis.yml authors.txt
find . -name "*~" | xargs rm
find . -name ".git*" | xargs rm -r
(cd scripts/python/; rm -fr build)
(cd scripts/java/; rm -fr org)
@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 / benzene2d.sdf
Created October 29, 2019 14:17
Benzene SDF (2d vs. 3d)
OpenBabel10291910162D
6 6 0 0 0 0 0 0 0 0999 V2000
-0.8660 -0.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.7321 -0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-1.7321 1.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.8660 1.5000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
-0.0000 1.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
@ghutchis
ghutchis / ch3co2.sdf
Created October 29, 2019 14:20
CH3CO2- example
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
@ghutchis
ghutchis / ob-optimize.py
Created January 24, 2020 20:52
Open Babel optimizer
#!/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 / selected atoms.diff
Created February 11, 2020 20:44
Diff for selected atoms
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;