File: testbiopython.py

package info (click to toggle)
cclib 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 55,300 kB
  • sloc: python: 23,276; makefile: 84; sh: 26
file content (37 lines) | stat: -rw-r--r-- 1,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
#
# Copyright (c) 2023, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.

import unittest

import numpy

from cclib.bridge import cclib2biopython
from cclib.parser.utils import find_package


class BiopythonTest(unittest.TestCase):
    """Tests for the cclib2biopython bridge in cclib."""

    def setUp(self):
        super(BiopythonTest, self).setUp()
        if not find_package("Bio"):
            raise ImportError("Must install biopython to run this test")

    def test_makebiopython(self):
        from Bio.PDB.Superimposer import Superimposer
        atomnos = numpy.array([1, 8, 1], "i")
        a = numpy.array([[-1, 1, 0], [0, 0, 0], [1, 1, 0]], "f")
        b = numpy.array([[1.1, 2, 0], [1, 1, 0], [2, 1, 0]], "f")
        si = Superimposer()
        si.set_atoms(cclib2biopython.makebiopython(a, atomnos),
                     cclib2biopython.makebiopython(b, atomnos))
        ref = 0.29337859596
        assert abs(si.rms - ref) < 1.0e-6


if __name__ == "__main__":
    unittest.main()