Created
March 22, 2017 23:39
-
-
Save ghutchis/892cc1f709698b276e8bedd47d3df228 to your computer and use it in GitHub Desktop.
piezo-distance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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