Ejemplo n.º 1
0
def fallback(source):
    """Attempt to read standard molecular formats using other libraries.

    Currently this will read XYZ files with OpenBabel, but this can easily
    be extended to other formats and libraries, too.
    """

    if isinstance(source, str):
        ext = os.path.splitext(source)[1][1:].lower()
        if _has_cclib2openbabel:
            if ext in ('xyz', ):
                return cclib2openbabel.readfile(source, ext)
        else:
            print("Could not import openbabel, fallback mechanism might not work.")
Ejemplo n.º 2
0
def fallback(source):
    """Attempt to read standard molecular formats using other libraries.

    Currently this will read XYZ files with OpenBabel, but this can easily
    be extended to other formats and libraries, too.
    """

    if isinstance(source, str):
        ext = os.path.splitext(source)[1][1:].lower()
        if _has_cclib2openbabel:
            if ext in ('xyz', ):
                return cclib2openbabel.readfile(source, ext)
        else:
            print("Could not import openbabel, fallback mechanism might not work.")
Ejemplo n.º 3
0
def fallback(source):
    """Attempt to read standard molecular formats using other libraries.

    Currently this will read XYZ files with OpenBabel, but this can easily
    be extended to other formats and libraries, too.
    """

    if isinstance(source, str):
        ext = os.path.splitext(source)[1][1:].lower()
        if _has_cclib2openbabel:
            # From OB 3.0 onward, Pybel is contained inside the OB module.
            try:
                import openbabel.pybel as pb
            except:
                import pybel as pb
            if ext in pb.informats:
                return cclib2openbabel.readfile(source, ext)
        else:
            print("Could not import `openbabel`, fallback mechanism might not work.")
Ejemplo n.º 4
0
 def test_readfile(self):
     """Try to load an XYZ file with uracyl through Openbabel"""
     data = cclib2openbabel.readfile(self.path + "/uracil.xyz", "XYZ")
     assert data.natom == 12
Ejemplo n.º 5
0
def test_uracil():
    data = cclib2openbabel.readfile("uracil.xyz", "XYZ")
    assert data.natom == 12
Ejemplo n.º 6
0
 def test_xyz_uracyl(self):
     """Try to load an XYZ file with uracyl through Openbabel"""
     data = cclib2openbabel.readfile(self.path + "/uracil.xyz", "XYZ")
     assert data.natom == 12