Debian Codegraph @

cclib/bridge/cclib2biopython.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 """Bridge for using cclib data in biopython (http://biopython.org)."""
8
9 from cclib.parser.utils import PeriodicTable
10 from cclib.parser.utils import find_package
11
12 _found_biopython = find_package("Bio")
13 if _found_biopython:
14 from Bio.PDB.Atom import Atom
15
16
17 def makebiopython(atomcoords, atomnos):
18 """Create a list of BioPython Atoms.
19
20 This creates a list of BioPython Atoms suitable for use by
21 Bio.PDB.Superimposer, for example.
22 """
23 if not _found_biopython:
24 raise ImportError("You must install `biopython` to use this function")
25 pt = PeriodicTable()
26 bioatoms = []
27 for coords, atomno in zip(atomcoords, atomnos):
28 symbol = pt.element[atomno]
29 bioatoms.append(Atom(symbol, coords, 0, 0, 0, symbol, 0, symbol.upper()))
30 return bioatoms
31
32
33 del find_package