Debian Codegraph @

test/bridge/testopenbabel.py

raw
1 # -*- coding: utf-8 -*-
2 #
3 # Copyright (c) 2017, the cclib development team
4 #
5 # This file is part of cclib (http://cclib.github.io) and is distributed under
6 # the terms of the BSD 3-Clause License.
7
8 import os
9 import unittest
10
11 import numpy
12
13 from cclib.bridge import cclib2openbabel
14
15
16 class OpenbabelTest(unittest.TestCase):
17 """Tests for the cclib2openbabel bridge in cclib."""
18
19 def setUp(self):
20 self.path = os.path.abspath(os.path.dirname(__file__))
21
22 def test_makeopenbabel(self):
23 import openbabel
24 atomnos = numpy.array([1, 8, 1], "i")
25 atomcoords = numpy.array([[[-1., 1., 0.], [0., 0., 0.], [1., 1., 0.]]])
26 obmol = cclib2openbabel.makeopenbabel(atomcoords, atomnos)
27 obconversion = openbabel.OBConversion()
28 formatok = obconversion.SetOutFormat("inchi")
29 assert obconversion.WriteString(obmol).strip() == "InChI=1S/H2O/h1H2"
30
31 def test_readfile(self):
32 """Try to load an XYZ file with uracyl through Openbabel"""
33 data = cclib2openbabel.readfile(self.path + "/uracil.xyz", "XYZ")
34 assert data.natom == 12
35
36
37 if __name__ == "__main__":
38 unittest.main()