Exemplo n.º 1
0
    def test_read_mol(self):
        test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                                'test_files', "molecules")
        for fname in ("methane.log", "c60.xyz", "ethane.gjf"):
            filename = os.path.join(test_dir, fname)
            mol = read_mol(filename)
            self.assertIsInstance(mol, Molecule)

        for ext in [".xyz", ".json", ".gjf"]:
            fn = "smartio_mol_test" + ext
            write_mol(mol, fn)
            back = read_mol(fn)
            self.assertEqual(back, mol)
            os.remove(fn)
Exemplo n.º 2
0
    def test_read_mol(self):
        test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                                'test_files', "molecules")
        for fname in ("methane.log", "c60.xyz", "ethane.gjf"):
            filename = os.path.join(test_dir, fname)
            mol = read_mol(filename)
            self.assertIsInstance(mol, Molecule)

        for ext in [".xyz", ".json", ".gjf"]:
            fn = "smartio_mol_test" + ext
            write_mol(mol, fn)
            back = read_mol(fn)
            self.assertEqual(back, mol)
            os.remove(fn)
Exemplo n.º 3
0
 def test_read_mol_babel(self):
     test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                             'test_files', "molecules")
     for fname in ("ethane.mol", ):
         filename = os.path.join(test_dir, fname)
         mol = read_mol(filename)
         self.assertIsInstance(mol, Molecule)
Exemplo n.º 4
0
 def test_read_mol_babel(self):
     test_dir = os.path.join(os.path.dirname(__file__), "..", "..", "..",
                             'test_files', "molecules")
     for fname in ("ethane.mol", ):
         filename = os.path.join(test_dir, fname)
         mol = read_mol(filename)
         self.assertIsInstance(mol, Molecule)
Exemplo n.º 5
0
    def test_get_meta_from_structure(self):
        mol = read_mol(os.path.join(test_dir, "thiophene1.xyz"))
        meta = get_meta_from_structure(mol)
        json.dumps(meta, indent=4, sort_keys=True)
        meta_ref_text = '''
{
    "anonymized_formula": "AB3C3D5",
    "chemsystem": "C-Cl-H-S",
    "elements": ["C", "Cl", "H", "S"],
    "formula": "H3 C5 S1 Cl3",
    "inchi": "InChI=1S/C5H3Cl3S/c6-5(7,8)4-1-2-9-3-4/h1-3H",
    "is_valid": true,
    "known_bonds": [[0, 1], [1, 2], [1, 10], [1, 11], [2, 3], [2, 5], [3, 4],
                    [3, 9], [5, 6], [5, 7], [7, 8], [7, 9]],
    "nelements": 4,
    "nsites": 12,
    "reduced_cell_formula": "H3C5SCl3",
    "reduced_cell_formula_abc": "C5 Cl3 H3 S1"
}'''
        meta_ref = json.loads(meta_ref_text)
        self.assertEqual(meta, meta_ref)