Skip to content

Instantly share code, notes, and snippets.

@ghutchis
Created March 22, 2017 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ghutchis/892cc1f709698b276e8bedd47d3df228 to your computer and use it in GitHub Desktop.
Save ghutchis/892cc1f709698b276e8bedd47d3df228 to your computer and use it in GitHub Desktop.
piezo-distance
#!/usr/bin/env python
import sys
import openbabel as ob
import pybel
for filename in sys.argv[1:]:
mol = pybel.readfile("g09", filename).next()
nitro = mol.atoms[0]
amine = mol.atoms[0]
# Strip off common extensions
filename = filename.split('.',1)[0]
if filename.startswith('line'):
filename = filename[4:]
# loop through to find the nitro and amine N atoms
for atom in mol:
if atom.OBAtom.IsNitrogen() and atom.OBAtom.CountFreeOxygens() == 2:
# print "got no2"
nitro = atom
if atom.OBAtom.IsNitrogen() and atom.OBAtom.ExplicitHydrogenCount() == 2:
# print "got nh2"
amine = atom
print filename, amine.OBAtom.GetDistance(nitro.OBAtom)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment