Skip to content
Snippets Groups Projects
Commit 21caafb4 authored by Christian Kunkel's avatar Christian Kunkel
Browse files

py3 compatibility for converters

parent 40d7b21a
No related branches found
No related tags found
No related merge requests found
......@@ -21,14 +21,22 @@ codes, e.h. ase2rdkit or ase2pybel.
Author: Christoph Schober, 2015
"""
import StringIO
try:
import StringIO as io
except ImportError:
import io
import ase
import ase.io
try:
import pybel as pb
except ImportError:
print('pybel is not installed, related methods will fail.')
try:
import openbabel.pybel as pb
except:
print('pybel is not installed, related methods will fail.')
try:
from rdkit import Chem
......@@ -107,7 +115,7 @@ def xyz2ase(xyz_str):
"""
Convert a xyz file to an ASE atoms object via in-memory file (StringIO).
"""
xyzfile = StringIO.StringIO()
xyzfile = io.StringIO()
xyzfile.write(xyz_str)
mol = ase.io.read(xyzfile, format="xyz")
return mol
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment