import sys
from pybel import *
mol = readfile("g09", "stauranthine_GC_dimer_xyz_1. out").next()
atomtotal = 0
for mol in readfile("g09", "stauranthine_GC_dimer_xyz_1. out"):
atomtotal += len(mol.atoms)
atom_number = { 1 : 'H',
6 : 'C',
7 : 'N',
8 : 'O'
}
for atom in mol:
x = atom.coords[0]
y = atom.coords[1]
z = atom.coords[2]
print atom_number[atom.atomicnum]+'\ t'+str(x)+'\t'+str(y)+'\t'+ str(z)
#I am having trouble getting the xyz coordinates to form right aligned even columns. Some of the coordinates have negative signs which causes the misalignment.
Not sure what pybel is (which library?)
ReplyDeleteNever mind (!) - located the package called openbabel - will check the code and let you know!
ReplyDelete# seems OK - I imported into excel and it reads ok
ReplyDelete# check this code and let me know
#!/usr/bin/python
import sys
from pybel import *
atom_number = { 1 : 'H',
6 : 'C',
7 : 'N',
8 : 'O'
}
atomtotal = 0
molfile = readfile("g09", "stauranthine_GC_dimer_xyz_1.out")
for mol in molfile:
atomtotal += len(mol.atoms)
for atom in mol:
x = atom.coords[0]
y = atom.coords[1]
z = atom.coords[2]
w = atom.atomicnum
print str(w) + '\t' + str(x) + '\t' + str(y) + '\t' + str(z)