Beispiel #1
0
    def setUp(self):
        super(Horton2Test, self).setUp()

        self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16",
                                              ["dvb_un_sp.fchk"])
        datadir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "..", "..", "data"))
        inputfile = os.path.join(datadir, "Gaussian", "basicGaussian16",
                                 "dvb_un_sp.fchk")

        self._old_horton = False
        self._found_horton = find_package("horton")

        if self._found_horton:
            try:
                from horton import __version__
            except:
                self._old_horton = (
                    True  # Old horton versions do not have this __version__ attribute
                )
            else:
                if __version__[0] == "2":
                    from horton.io.iodata import IOData
                    from horton import log

                    log.set_level(
                        0
                    )  # This suppresses horton outputs so that they do not flood the test log.
                    self._hortonver = 2
                    self.iodat = IOData.from_file(inputfile)
Beispiel #2
0
 def setUp(self):
     super(PyscfTest, self).setUp()
     if not find_package("pyscf"):
         raise ImportError("Must install pyscf to run this test")
     self.data, self.logfile = getdatafile(
         "GAMESS", "basicGAMESS-US2018", ["dvb_sp.out"]
     )
     self.udata, self.ulogfile = getdatafile(
         "GAMESS", "basicGAMESS-US2018", ["dvb_un_sp.out"]
     )
Beispiel #3
0
    def test_makepsi4(self):
        if not find_package('psi4'):
            raise ImportError('Must install psi4 to run this test')

        import psi4
        from psi4 import energy

        psi4.core.set_output_file("psi4_output.dat", False)

        atomnos = np.array([1, 8, 1], "i")
        atomcoords = np.array([[-1, 1, 0], [0, 0, 0], [1, 1, 0]], "f")
        psi4mol = cclib2psi4.makepsi4(atomcoords, atomnos)
        psi4.set_options({'scf_type': 'pk'})
        en = energy("scf/6-31G**", molecule=psi4mol)
        ref = -75.824754602
        assert abs(en - ref) < 1.0e-6
Beispiel #4
0
    def setUp(self):
        super(Horton3Test, self).setUp()

        self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16",
                                              ["dvb_un_sp.fchk"])
        datadir = os.path.abspath(
            os.path.join(os.path.dirname(__file__), "..", "..", "data"))
        inputfile = os.path.join(datadir, "Gaussian", "basicGaussian16",
                                 "dvb_un_sp.fchk")

        self._found_iodata = find_package("iodata")

        from iodata import IOData
        from iodata.orbitals import MolecularOrbitals
        from iodata.api import load_one

        self._hortonver = 3

        self.iodat = load_one(filename=inputfile)
Beispiel #5
0
# Copyright (c) 2017, 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.

"""Calculate properties of nuclei based on data parsed by cclib."""

import logging

import numpy as np

from cclib.method.calculationmethod import Method
from cclib.parser.utils import PeriodicTable
from cclib.parser.utils import find_package

_found_periodictable = find_package("periodictable")
if _found_periodictable:
    import periodictable as pt

_found_scipy = find_package("scipy")
if _found_scipy:
    import scipy.constants as spc


def _check_periodictable(found_periodictable):
    if not _found_periodictable:
        raise ImportError("You must install `periodictable` to use this function")


def _check_scipy(found_scipy):
    if not _found_scipy:
Beispiel #6
0
    "F": [
        (3, 0, 0),
        (2, 1, 0),
        (2, 0, 1),
        (1, 2, 0),
        (1, 1, 1),
        (1, 0, 2),
        (0, 3, 0),
        (0, 2, 1),
        (0, 1, 2),
        (0, 0, 3),
    ],
}


_found_pyquante = find_package("PyQuante")
if _found_pyquante:
    from PyQuante.CGBF import CGBF

    def getbfs(ccdata):
        from cclib.bridge import cclib2pyquante

        pymol = cclib2pyquante.makepyquante(ccdata)

        bfs = []
        for i, atom in enumerate(pymol):
            bs = ccdata.gbasis[i]
            for sym, prims in bs:
                for power in sym2powerlist[sym]:
                    bf = CGBF(atom.pos(), power)
                    for expnt, coef in prims:
Beispiel #7
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, 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.
"""Facilities for moving parsed data to other cheminformatic libraries."""

from cclib.parser.utils import find_package

if find_package("Bio"):
    from cclib.bridge.cclib2biopython import makebiopython

if find_package("openbabel"):
    from cclib.bridge.cclib2openbabel import makeopenbabel

if find_package("PyQuante"):
    from cclib.bridge.cclib2pyquante import makepyquante

if find_package("psi4"):
    from cclib.bridge.cclib2psi4 import makepsi4

if find_package("ase"):
    from cclib.bridge.cclib2ase import makease

if find_package("iodata"):
    from cclib.bridge.cclib2horton import makehorton

if find_package("pyscf"):
    from cclib.bridge.cclib2pyscf import makepyscf, makepyscf_mos
del find_package
Beispiel #8
0
#
# Copyright (c) 2020, 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.

"""Bridge for using cclib data in horton (http://theochem.github.io/horton)."""
# Support for horton 2 will likely be dropped when Python 2 support is dropped from cclib.

import numpy
from cclib.parser.data import ccData
from cclib.parser.utils import find_package

# First check horton version
_old_horton = False
_found_horton = find_package("horton")
_found_iodata = find_package("iodata")

# Detect whether horton 2 is present or not
if _found_horton:
    # Older horton packages do not have __version__, causing exceptions.
    try:
        from horton import __version__
    except:
        _old_horton = True
    else:
        if __version__[0] == "2":
            from horton.io.iodata import IOData

# Detect whether iodata (part of horton 3) is present or not
# Horton 3 is divided into smaller (sub)packages that each take different functionalities.
Beispiel #9
0
#
# Copyright (c) 2017, 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.
"""Calculate properties of nuclei based on data parsed by cclib."""

import logging

import numpy as np

from cclib.method.calculationmethod import Method
from cclib.parser.utils import PeriodicTable
from cclib.parser.utils import find_package

_found_periodictable = find_package("periodictable")
if _found_periodictable:
    import periodictable as pt

_found_scipy = find_package("scipy")
if _found_scipy:
    import scipy.constants as spc


def _check_periodictable(found_periodictable):
    if not _found_periodictable:
        raise ImportError(
            "You must install `periodictable` to use this function")


def _check_scipy(found_scipy):
Beispiel #10
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.

"""Bridge between cclib data and openbabel (http://openbabel.org)."""

from cclib.parser.data import ccData
from cclib.parser.utils import find_package

_found_openbabel = find_package("openbabel")
if _found_openbabel:
    import openbabel as ob


def _check_openbabel(found_openbabel):
    if not found_openbabel:
        raise ImportError("You must install `openbabel` to use this function")


def makecclib(mol):
    """Create cclib attributes and return a ccData from an OpenBabel molecule.

    Beyond the numbers, masses and coordinates, we could also set the total charge
    and multiplicity, but often these are calculated from atomic formal charges
    so it is better to assume that would not be correct.
    """
    _check_openbabel(_found_openbabel)
    attributes = {
Beispiel #11
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.
"""Bridge for using cclib data in biopython (http://biopython.org)."""

from cclib.parser.utils import PeriodicTable
from cclib.parser.utils import find_package

_found_biopython = find_package("Bio")
if _found_biopython:
    from Bio.PDB.Atom import Atom


def makebiopython(atomcoords, atomnos):
    """Create a list of BioPython Atoms.

    This creates a list of BioPython Atoms suitable for use by
    Bio.PDB.Superimposer, for example.
    """
    if not _found_biopython:
        raise ImportError("You must install `biopython` to use this function")
    pt = PeriodicTable()
    bioatoms = []
    for coords, atomno in zip(atomcoords, atomnos):
        symbol = pt.element[atomno]
        bioatoms.append(Atom(symbol, coords, 0, 0, 0, symbol, 0, symbol.upper()))
    return bioatoms
Beispiel #12
0
#
# Copyright (c) 2019, 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.
"""Script for writing data tables from computational chemistry files."""

import argparse
import os.path
import sys

from cclib.io import ccopen
from cclib.io import ccframe
from cclib.parser.utils import find_package

_has_pandas = find_package("pandas")
if _has_pandas:
    import pandas as pd


def process_logfiles(filenames, output, identifier):
    df = ccframe([ccopen(path) for path in filenames])
    if output is not None:
        outputtype = os.path.splitext(os.path.basename(output))[1][1:]
        if not outputtype:
            raise RuntimeWarning(
                "The output type could not be determined from the given path, "
                "not writing DataFrame to disk"
            )

        if outputtype in {'csv'}:
Beispiel #13
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.

"""A writer for chemical markup language (CML) files."""

import xml.etree.cElementTree as ET

from cclib.io import filewriter
from cclib.parser.utils import find_package

_has_openbabel = find_package("openbabel")


class CML(filewriter.Writer):
    """A writer for chemical markup language (CML) files."""

    def __init__(self, ccdata, *args, **kwargs):
        """Initialize the CML writer object.

        Inputs:
          ccdata - An instance of ccData, parsed from a logfile.
        """

        # Call the __init__ method of the superclass
        super(CML, self).__init__(ccdata, *args, **kwargs)

    def generate_repr(self):
Beispiel #14
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, 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.
"""Bridge for using cclib data in ASE (https://wiki.fysik.dtu.dk/ase/)."""

import numpy as np

from cclib.parser.data import ccData
from cclib.parser.utils import find_package

_found_ase = find_package("ase")
if _found_ase:
    from ase import Atoms, units
    from ase.io.trajectory import Trajectory
    from ase.calculators.calculator import PropertyNotImplementedError


def _check_ase(found_ase):
    if not found_ase:
        raise ImportError("You must install `ase` to use this function")


def makease(atomcoords,
            atomnos,
            atomcharges=None,
            atomspins=None,
            atommasses=None):
    """Create an ASE Atoms object from cclib attributes.
Beispiel #15
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.

"""Bridge for using cclib data in PyQuante (http://pyquante.sourceforge.net)."""

from cclib.parser.utils import find_package

_found_pyquante = find_package("PyQuante")
if _found_pyquante:
    from PyQuante.Molecule import Molecule


def _check_pyquante(found_pyquante):
    if not found_pyquante:
        raise ImportError("You must install `PyQuante` to use this function")


def makepyquante(atomcoords, atomnos, charge=0, mult=1):
    """Create a PyQuante Molecule."""
    _check_pyquante(_found_pyquante)
    return Molecule("notitle",
                    list(zip(atomnos, atomcoords)),
                    units="Angstrom",
                    charge=charge, multiplicity=mult)


del find_package
Beispiel #16
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, 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.
"""Facilities for moving parsed data to other cheminformatic libraries."""

from cclib.parser.utils import find_package

if find_package("Bio"):
    from cclib.bridge.cclib2biopython import makebiopython

if find_package("openbabel"):
    from cclib.bridge.cclib2openbabel import makeopenbabel

if find_package("PyQuante"):
    from cclib.bridge.cclib2pyquante import makepyquante

if find_package("psi4"):
    from cclib.bridge.cclib2psi4 import makepsi4

if find_package("horton"):
    try:
        from horton import __version__
    except Exception:
        pass
    else:
        if (__version__[0] == '2'):
            from cclib.bridge.cclib2horton import makehorton
Beispiel #17
0
[-0.3880329  0.2227029  0.16703  ]
(array([-3.7422439 , -3.34907393,  0.80222668]), 5.0856910330516865)
[[ 2.9476879   0.39972848 -0.47709812]
 [ 2.648237   -0.2199436  -0.65167883]
 [ 1.183168    1.256816   -0.11061444]]
'''

import logging

import numpy as np

from cclib.method.calculationmethod import Method
from cclib.parser.utils import PeriodicTable
from cclib.parser.utils import find_package

_found_periodictable = find_package("periodictable")
if _found_periodictable:
    import periodictable.covalent_radius as pt


def _check_periodictable(found_periodictable):
    if not _found_periodictable:
        raise ImportError("You must install `periodictable` to use this class")


class CM5(Method):
    def __init__(self,
                 data,
                 fscale=1.20,
                 progress=None,
                 loglevel=logging.INFO,
Beispiel #18
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2020, 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.
"""Bridge for using cclib data in horton (http://theochem.github.io/horton)."""

import numpy
from cclib.parser.data import ccData
from cclib.parser.utils import find_package

_found_iodata = find_package("iodata")

# Detect whether iodata (part of horton 3) is present or not
# Horton 3 is divided into smaller (sub)packages that each take different functionalities.
if _found_iodata:
    from iodata import IOData
    from iodata.orbitals import MolecularOrbitals


def check_horton():
    if not _found_iodata:
        raise ImportError("You must install `horton` to use this function.")


def makehorton(data):
    """ Create horton IOData object from ccData object """

    check_horton()
    attributes = {}
Beispiel #19
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019, 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.
"""Bridge for using cclib data in Psi4 (http://www.psicode.org/)."""

from cclib.parser.utils import find_package

_found_psi4 = find_package("psi4")
if _found_psi4:
    from psi4.core import Molecule


def _check_psi4(found_psi4):
    if not found_psi4:
        raise ImportError("You must install `psi4` to use this function")


def makepsi4(atomcoords, atomnos, charge=0, mult=1):
    """Create a Psi4 Molecule."""
    _check_psi4(_found_psi4)
    return Molecule.from_arrays(
        name="notitle",
        elez=atomnos,
        geom=atomcoords,
        units="Angstrom",
        molecular_charge=charge,
        molecular_multiplicity=mult,
    )
Beispiel #20
0
#
# Copyright (c) 2021, 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.
"""Tests for the cclib2ase bridge in cclib."""

import unittest

import numpy as np

from cclib import ccopen
from cclib.bridge import cclib2ase
from cclib.parser.utils import find_package

if not find_package('ase'):
    raise ImportError('Must install ase to run this test')

from ase import Atoms
from ase.calculators.emt import EMT


class ASETest(unittest.TestCase):
    """Tests for the cclib2ase bridge in cclib."""
    def setUp(self):
        super(ASETest, self).setUp()

    def test_makease_allows_optimization(self):
        """Ensure makease works from direct input."""
        h2 = cclib2ase.makease([[0, 0, 0], [0, 0, 0.7]], [1, 1])
Beispiel #21
0
 def setUp(self):
     super(pyquante2Test, self).setUp()
     self._found_pyquante2 = find_package("pyquante2")
     self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16",
                                           ["water_ccsd.log"])
Beispiel #22
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2019, 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.

"""Bridge for using cclib data in PySCF (https://github.com/pyscf/pyscf)."""

from cclib.parser.utils import find_package, PeriodicTable
import numpy as np

l_sym2num = {"S": 0, "P": 1, "D": 2, "F": 3, "G": 4}


_found_pyscf = find_package("pyscf")
if _found_pyscf:
    from pyscf import gto


def _check_pyscf(found_pyscf):
    if not found_pyscf:
        raise ImportError("You must install `pyscf` to use this function")


def makepyscf(data, charge=0, mult=1):
    """Create a Pyscf Molecule."""
    _check_pyscf(_found_pyscf)
    mol = gto.Mole(
        atom=[
            ["{}".format(data.atomnos[i]), data.atomcoords[-1][i]]
Beispiel #23
0
#
# Copyright (c) 2019, 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.
"""Script for writing data tables from computational chemistry files."""

import argparse
import os.path
import sys

from cclib.io import ccopen
from cclib.io import ccframe
from cclib.parser.utils import find_package

_has_pandas = find_package("pandas")
if _has_pandas:
    import pandas as pd


def process_logfiles(filenames, output, identifier):
    df = ccframe([ccopen(path) for path in filenames])
    if output is not None:
        outputtype = os.path.splitext(os.path.basename(output))[1][1:]
        if not outputtype:
            raise RuntimeWarning(
                "The output type could not be determined from the given path, "
                "not writing DataFrame to disk")

        if outputtype in {'csv'}:
            df.to_csv(output, mode='w')
Beispiel #24
0
    def _read_proatom(
            self,
            directory,
            atom_num,
            charge  # type = str  # type = int  # type = float
    ):
        # type: (...) -> numpy.ndarray, numpy.ndarray
        """Return a list containing proatom reference densities."""
        # TODO: Treat calculations with psuedopotentials
        # TODO: Modify so that proatom densities are read only once for horton
        #       [https://github.com/cclib/cclib/pull/914#discussion_r464039991]
        # File name format:
        #   ** Chargemol **
        #       c2_[atom number]_[nuclear charge]_[electron count]_[cutoff radius]_[# shells]
        #   ** Horton **
        #       atoms.h5
        # File format:
        #   Starting from line 13, each line contains the charge densities for each shell
        # If `charge` is not an integer, proatom densities have to be linearly interpolated between
        # the densities of the ion/atom with floor(charge) and ceiling(charge)
        charge_floor = int(math.floor(charge))
        charge_ceil = int(math.ceil(charge))

        chargemol_path_floor = os.path.join(
            directory,
            "c2_{:03d}_{:03d}_{:03d}_500_100.txt".format(
                atom_num, atom_num, atom_num - charge_floor),
        )
        chargemol_path_ceil = os.path.join(
            directory,
            "c2_{:03d}_{:03d}_{:03d}_500_100.txt".format(
                atom_num, atom_num, atom_num - charge_ceil),
        )
        horton_path = os.path.join(directory, "atoms.h5")

        if os.path.isfile(chargemol_path_floor) or os.path.isfile(
                chargemol_path_ceil):
            # Use chargemol proatom densities
            # Each shell is .05 angstroms apart (uniform).
            # *scalefactor* = 10.58354497764173 bohrs in module_global_parameter.f08
            if atom_num <= charge_floor:
                density_floor = numpy.array([0])
            else:
                density_floor = numpy.loadtxt(chargemol_path_floor,
                                              skiprows=12,
                                              dtype=float)
            if atom_num >= charge_ceil:
                density_ceil = numpy.array([0])
            else:
                density_ceil = numpy.loadtxt(chargemol_path_ceil,
                                             skiprows=12,
                                             dtype=float)

            density = (charge_ceil - charge) * density_floor + (
                charge - charge_floor) * density_ceil
            radiusgrid = numpy.arange(1, len(density) + 1) * 0.05

        elif os.path.isfile(horton_path):
            # Use horton proatom densities
            assert find_package(
                "h5py"
            ), "h5py is needed to read in proatom densities from horton."

            import h5py

            with h5py.File(horton_path, "r") as proatomdb:
                if atom_num <= charge_floor:
                    density_floor = numpy.array([0])
                    radiusgrid = numpy.array([0])
                else:
                    keystring_floor = "Z={}_Q={:+d}".format(
                        atom_num, charge_floor)
                    density_floor = numpy.asanyarray(
                        list(proatomdb[keystring_floor]["rho"]))

                    # gridspec is specification of integration grid for proatom densities in horton.
                    # Example -- ['PowerRTransform', '1.1774580743206259e-07', '20.140888089596444', '41']
                    #   is constructed using PowerRTransform grid
                    #   with rmin = 1.1774580743206259e-07
                    #        rmax = 20.140888089596444
                    #   and  ngrid = 41
                    # PowerRTransform is default in horton-atomdb.py.
                    gridtype, gridmin, gridmax, gridn = (
                        proatomdb[keystring_floor].attrs["rtransform"].split())
                    gridmin = convertor(float(gridmin), "bohr", "Angstrom")
                    gridmax = convertor(float(gridmax), "bohr", "Angstrom")
                    gridn = int(gridn)
                    # Convert byte to string in Python3
                    if sys.version[0] == "3":
                        gridtype = gridtype.decode("UTF-8")

                    # First verify that it is one of recognized grids
                    assert gridtype in [
                        "LinearRTransform",
                        "ExpRTransform",
                        "PowerRTransform",
                    ], "Grid type not recognized."

                    if gridtype == "LinearRTransform":
                        # Linear transformation. r(t) = rmin + t*(rmax - rmin)/(npoint - 1)
                        gridcoeff = (gridmax - gridmin) / (gridn - 1)
                        radiusgrid = gridmin + numpy.arange(
                            1, gridn + 1) * gridcoeff
                    elif gridtype == "ExpRTransform":
                        # Exponential transformation. r(t) = rmin*exp(t*log(rmax/rmin)/(npoint - 1))
                        gridcoeff = math.log(gridmax / gridmin) / (gridn - 1)
                        radiusgrid = gridmin * numpy.exp(
                            numpy.arange(1, gridn + 1) * gridcoeff)
                    elif gridtype == "PowerRTransform":
                        # Power transformation. r(t) = rmin*t^power
                        # with  power = log(rmax/rmin)/log(npoint)
                        gridcoeff = math.log(
                            gridmax / gridmin) / math.log(gridn)
                        radiusgrid = gridmin * numpy.power(
                            numpy.arange(1, gridn + 1), gridcoeff)

                if atom_num <= charge_ceil:
                    density_ceil = numpy.array([0])
                else:
                    keystring_ceil = "Z={}_Q={:+d}".format(
                        atom_num, charge_ceil)
                    density_ceil = numpy.asanyarray(
                        list(proatomdb[keystring_ceil]["rho"]))

                density = (charge_ceil - charge) * density_floor + (
                    charge - charge_floor) * density_ceil

                del h5py

        else:
            raise MissingInputError(
                "Pro-atom densities were not found in the specified path.")

        if charge == charge_floor:
            density = density_floor

        return density, radiusgrid
Beispiel #25
0
from cclib.parser.nwchemparser import NWChem
from cclib.parser.orcaparser import ORCA
from cclib.parser.psi3parser import Psi3
from cclib.parser.psi4parser import Psi4
from cclib.parser.qchemparser import QChem
from cclib.parser.turbomoleparser import Turbomole

from cclib.io import cjsonreader
from cclib.io import cjsonwriter
from cclib.io import cmlwriter
from cclib.io import moldenwriter
from cclib.io import wfxwriter
from cclib.io import xyzreader
from cclib.io import xyzwriter

_has_cclib2openbabel = find_package("openbabel")
if _has_cclib2openbabel:
    from cclib.bridge import cclib2openbabel

_has_pandas = find_package("pandas")
if _has_pandas:
    import pandas as pd

# Regular expression for validating URLs
URL_PATTERN = re.compile(

    r'^(?:http|ftp)s?://'  # http:// or https://
    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  # domain...
    r'localhost|'  # localhost...
    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  # ...or ip
    r'(?::\d+)?'  # optional port
Beispiel #26
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.
"""Bridge for using cclib data in PyQuante (http://pyquante.sourceforge.net)."""

from cclib.parser.utils import find_package

_found_pyquante = find_package("PyQuante")
if _found_pyquante:
    from PyQuante.Molecule import Molecule


def _check_pyquante(found_pyquante):
    if not found_pyquante:
        raise ImportError("You must install `PyQuante` to use this function")


def makepyquante(atomcoords, atomnos, charge=0, mult=1):
    """Create a PyQuante Molecule."""
    _check_pyquante(_found_pyquante)
    return Molecule("notitle",
                    list(zip(atomnos, atomcoords)),
                    units="Angstrom",
                    charge=charge,
                    multiplicity=mult)


del find_package
Beispiel #27
0
 def setUp(self):
     super(BiopythonTest, self).setUp()
     if not find_package("Bio"):
         raise ImportError("Must install biopython to run this test")
Beispiel #28
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.

"""Facilities for moving parsed data to other cheminformatic libraries."""

from cclib.parser.utils import find_package

if find_package("Bio"):
    from cclib.bridge.cclib2biopython import makebiopython

if find_package("openbabel"):
    from cclib.bridge.cclib2openbabel import makeopenbabel

if find_package("PyQuante"):
    from cclib.bridge.cclib2pyquante import makepyquante


del find_package
Beispiel #29
0
# Copyright (c) 2020, 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.

"""Bridge for using cclib data in PyQuante (http://pyquante.sourceforge.net)."""

import numpy
from cclib.parser.utils import find_package


class MissingAttributeError(Exception):
    pass


_found_pyquante2 = find_package("pyquante2")
if _found_pyquante2:
    from pyquante2 import molecule


def _check_pyquante():
    if not _found_pyquante2:
        raise ImportError("You must install `pyquante2` to use this function")


def makepyquante(data):
    """Create a PyQuante Molecule from ccData object."""
    _check_pyquante()

    # Check required attributes.
    required_attrs = {"atomcoords", "atomnos"}
Beispiel #30
0
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, 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.
"""Facilities for moving parsed data to other cheminformatic libraries."""

from cclib.parser.utils import find_package

if find_package("Bio"):
    from cclib.bridge.cclib2biopython import makebiopython

if find_package("openbabel"):
    from cclib.bridge.cclib2openbabel import makeopenbabel

if find_package("PyQuante"):
    from cclib.bridge.cclib2pyquante import makepyquante

if find_package("psi4"):
    from cclib.bridge.cclib2psi4 import makepsi4

del find_package
Beispiel #31
0
from cclib.parser.nwchemparser import NWChem
from cclib.parser.orcaparser import ORCA
from cclib.parser.psi3parser import Psi3
from cclib.parser.psi4parser import Psi4
from cclib.parser.qchemparser import QChem
from cclib.parser.turbomoleparser import Turbomole

from cclib.io import cjsonreader
from cclib.io import cjsonwriter
from cclib.io import cmlwriter
from cclib.io import moldenwriter
from cclib.io import wfxwriter
from cclib.io import xyzreader
from cclib.io import xyzwriter

_has_cclib2openbabel = find_package("openbabel")
if _has_cclib2openbabel:
    from cclib.bridge import cclib2openbabel

_has_pandas = find_package("pandas")
if _has_pandas:
    import pandas as pd

# Regular expression for validating URLs
URL_PATTERN = re.compile(

    r'^(?:http|ftp)s?://'  # http:// or https://
    r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|'  # domain...
    r'localhost|'  # localhost...
    r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})'  # ...or ip
    r'(?::\d+)?'  # optional port
Beispiel #32
0
# Copyright (c) 2017, 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.

"""Calculation methods related to volume based on cclib data."""

from __future__ import print_function
import copy

import numpy

from cclib.parser.utils import convertor
from cclib.parser.utils import find_package

_found_pyquante = find_package("PyQuante")
if _found_pyquante:
    from PyQuante.CGBF import CGBF
    from cclib.bridge import cclib2pyquante

_found_pyvtk = find_package("pyvtk")
if _found_pyvtk:
    from pyvtk import *
    from pyvtk.DataSetAttr import *


def _check_pyvtk(found_pyvtk):
    if not found_pyvtk:
        raise ImportError("You must install `pyvtk` to use this function")

Beispiel #33
0
import logging
import sys
from abc import ABCMeta, abstractmethod
from six import add_metaclass

if sys.version_info <= (3, 3):
    from collections import Iterable
else:
    from collections.abc import Iterable

import numpy

from cclib.parser.utils import PeriodicTable
from cclib.parser.utils import find_package

_has_openbabel = find_package("openbabel")
if _has_openbabel:
    from cclib.bridge import makeopenbabel
    try:
        from openbabel import openbabel as ob
        import openbabel.pybel as pb
    except:
        import openbabel as ob
        import pybel as pb


class MissingAttributeError(Exception):
    pass


@add_metaclass(ABCMeta)
Beispiel #34
0
 def setUp(self):
     super(PyscfTest, self).setUp()
     if not find_package('pyscf'):
         raise ImportError('Must install pyscf to run this test')