コード例 #1
0
 def test_in_database_with_actual_database(self):
     db_file = os.path.join(db_dir, "db.json")
     dir2620 = os.path.join(module_dir, "..", "..", "test_files",
                            "2620_complete")
     mol2620 = QCOutput(os.path.join(
         dir2620, "mol.qout.opt_0")).data["initial_molecule"]
     parse_firetask = QChemToDb(calc_dir=dir2620, db_file=db_file)
     parse_firetask.run_task({})
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(
             molecule=self.neg_tfsi,
             db_file=db_file,
             depth=0,
             additional_charges=[-2, 1],
             do_triplets=False,
         )
         ft.run_task({})
         self.assertEqual(ft.check_db, True)
         self.assertEqual(ft.charges, [-1, 0, -2, 1])
         self.assertEqual(len(FWAction_patch.call_args[1]["additions"]),
                          623)
         self.assertEqual(ft._in_database(mol2620), True)
         mol2620.set_charge_and_spin(charge=0)
         self.assertEqual(ft._in_database(mol2620), False)
コード例 #2
0
    def test_babel_PC_depth_0_vs_depth_10(self):
        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(molecule=self.pc,
                                  depth=0,
                                  open_rings=False,
                                  do_triplets=False)
            ft.run_task({})
            self.assertEqual(ft.check_db, False)
            depth0frags = ft.unique_fragments
            self.assertEqual(len(depth0frags), 295)
            self.assertEqual(len(FWAction_patch.call_args[1]["additions"]),
                             295 * 3)

        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(molecule=self.pc,
                                  depth=10,
                                  open_rings=False,
                                  do_triplets=False)
            ft.run_task({})
            self.assertEqual(ft.check_db, False)
            depth10frags = ft.unique_fragments
            self.assertEqual(len(depth10frags), 63)
            self.assertEqual(len(FWAction_patch.call_args[1]["additions"]),
                             63 * 3)

        for fragment10 in depth10frags:
            found = False
            for fragment0 in depth0frags:
                if fragment0.isomorphic_to(fragment10):
                    found = True
            self.assertEqual(found, True)
コード例 #3
0
    def test_babel_PC_depth_0_vs_depth_10(self):
        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(molecule=self.pc, depth=0, open_rings=False, do_triplets=False)
            ft.run_task({})
            self.assertEqual(ft.check_db,False)
            depth0frags = ft.unique_fragments
            self.assertEqual(len(depth0frags), 295)
            self.assertEqual(
                len(FWAction_patch.call_args[1]["additions"]), 295*3)

        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(molecule=self.pc, depth=10, open_rings=False, do_triplets=False)
            ft.run_task({})
            self.assertEqual(ft.check_db,False)
            depth10frags = ft.unique_fragments
            self.assertEqual(len(depth10frags), 63)
            self.assertEqual(
                len(FWAction_patch.call_args[1]["additions"]), 63*3)

        for fragment10 in depth10frags:
            found = False
            for fragment0 in depth0frags:
                if fragment0.isomorphic_to(fragment10):
                    found = True
            self.assertEqual(found, True)
コード例 #4
0
    def test_neg_TFSI_with_additional_charges(self):
        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(
                molecule=self.neg_tfsi,
                depth=0,
                additional_charges=[-2, 1],
                do_triplets=False,
            )
            ft.run_task({})
            self.assertEqual(ft.check_db, False)
            self.assertEqual(ft.charges, [-1, 0, -2, 1])
            self.assertEqual(len(FWAction_patch.call_args[1]["additions"]),
                             624)

        with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                   ) as FWAction_patch:
            ft = FragmentMolecule(
                molecule=self.neg_tfsi,
                depth=0,
                additional_charges=[0, 1],
                do_triplets=False,
            )
            ft.run_task({})
            self.assertEqual(ft.check_db, False)
            self.assertEqual(len(FWAction_patch.call_args[1]["additions"]),
                             468)
コード例 #5
0
 def test_babel_TFSI(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.tfsi, depth=0, do_triplets=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         self.assertEqual(ft.charges,[-1,0,1])
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 468)
コード例 #6
0
 def test_edges_given_PC(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.pc, edges=self.pc_edges, depth=0, open_rings=False, do_triplets=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         self.assertEqual(ft.charges,[-1,0,1])
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 295 * 3)
コード例 #7
0
 def test_babel_TFSI(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.tfsi, depth=0, do_triplets=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         self.assertEqual(ft.charges,[-1,0,1])
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 468)
コード例 #8
0
 def test_edges_given_PC(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.pc, edges=self.pc_edges, depth=0, open_rings=False, do_triplets=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         self.assertEqual(ft.charges,[-1,0,1])
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 295 * 3)
コード例 #9
0
 def test_EC_neg(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.neg_ec, depth=1, check_db=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         frags = ft.unique_fragments
         self.assertEqual(len(frags), 7)
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 15)
コード例 #10
0
 def test_EC_neg(self):
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.neg_ec, depth=1, check_db=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,False)
         frags = ft.unique_fragments
         self.assertEqual(len(frags), 7)
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 14)
コード例 #11
0
 def test_in_database_with_actual_database(self):
     db_file=os.path.join(db_dir, "db.json")
     dir2620=os.path.join(module_dir, "..", "..", "test_files", "2620_complete")
     mol2620=QCOutput(os.path.join(dir2620,"mol.qout.opt_0")).data["initial_molecule"]
     parse_firetask = QChemToDb(calc_dir=dir2620, db_file=db_file)
     parse_firetask.run_task({})
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.neg_tfsi, db_file=db_file, depth=0, additional_charges=[-2,1], do_triplets=False)
         ft.run_task({})
         self.assertEqual(ft.check_db,True)
         self.assertEqual(ft.charges,[-1,0,-2,1])
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 623)
         self.assertEqual(ft._in_database(mol2620),True)
         mol2620.set_charge_and_spin(charge=0)
         self.assertEqual(ft._in_database(mol2620),False)
コード例 #12
0
 def test_in_database_and_EC_neg_frag(self):
     db_file = os.path.join(db_dir, "db.json")
     mmdb = QChemCalcDb.from_db_file(db_file, admin=True)
     with open(os.path.join(module_dir, "..", "..", "test_files","sb40.json")) as f:
         tmp = json.load(f)
         for entry in tmp:
             mmdb.insert(entry)
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.neg_ec, depth=1, qchem_input_params={"pcm_dielectric": 40.0}, check_db=True, db_file=db_file)
         ft.run_task({})
         self.assertEqual(ft.check_db,True)
         frags = ft.unique_fragments
         self.assertEqual(len(frags), 7)
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 0)
     mmdb.reset()
コード例 #13
0
 def test_in_database_and_EC_neg_frag(self):
     db_file = os.path.join(db_dir, "db.json")
     mmdb = QChemCalcDb.from_db_file(db_file, admin=True)
     with open(os.path.join(module_dir, "..", "..", "test_files","sb40.json")) as f:
         tmp = json.load(f)
         for entry in tmp:
             mmdb.insert(entry)
     with patch("atomate.qchem.firetasks.fragmenter.FWAction"
                ) as FWAction_patch:
         ft = FragmentMolecule(molecule=self.neg_ec, depth=1, qchem_input_params={"pcm_dielectric": 40.0}, check_db=True, db_file=db_file)
         ft.run_task({})
         self.assertEqual(ft.check_db,True)
         frags = ft.unique_fragments
         self.assertEqual(len(frags), 7)
         self.assertEqual(
             len(FWAction_patch.call_args[1]["additions"]), 0)
     mmdb.reset()