Coverage for cclib/bridge/cclib2biopython.py : 94%
Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
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)."""
9from cclib.parser.utils import PeriodicTable
10from cclib.parser.utils import find_package
12_found_biopython = find_package("Bio")
13if _found_biopython:
14 from Bio.PDB.Atom import Atom
17def makebiopython(atomcoords, atomnos):
18 """Create a list of BioPython Atoms.
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
33del find_package