Exemplo n.º 1
0
    def test_build_unique_relevant_molecules_with_triplets(self):
        ft = FragmentMolecule(molecule=self.pc, edges=self.pc_edges, depth=0, opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = True
        edges = {(e[0], e[1]): None for e in self.pc_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc, edges)
        unique_frag_dict = mol_graph.build_unique_fragments()
        unique_frag_list = []
        for key in unique_frag_dict:
            for frag in unique_frag_dict[key]:
                unique_frag_list.append(frag)
        ft.unique_fragments = unique_frag_list
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 1323)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_mols_with_trips.json"))
        # self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pos_pc, edges=self.pc_edges, depth=0, opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1, 2]
        ft.do_triplets = True
        mol_graph = MoleculeGraph.with_edges(self.pos_pc, edges)
        unique_frag_dict = mol_graph.build_unique_fragments()
        unique_frag_list = []
        for key in unique_frag_dict:
            for frag in unique_frag_dict[key]:
                unique_frag_list.append(frag)
        ft.unique_fragments = unique_frag_list
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 1770)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pos_pc_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pos_pc_mols_with_trips.json"))
        # self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pc_frag1, edges=self.pc_frag1_edges, depth=0)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = True
        pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
        unique_frag_dict = mol_graph.build_unique_fragments()
        unique_frag_list = []
        for key in unique_frag_dict:
            for frag in unique_frag_dict[key]:
                unique_frag_list.append(frag)
        ft.unique_fragments = unique_frag_list
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 54)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_frag1_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_frag1_mols_with_trips.json"))
Exemplo n.º 2
0
    def test_build_unique_relevant_molecules(self):
        ft = FragmentMolecule(molecule=self.pc,
                              edges=self.pc_edges,
                              depth=0,
                              opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = False
        edges = {(e[0], e[1]): None for e in self.pc_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc, edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 295 * 3)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_mols.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_mols.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pos_pc,
                              edges=self.pc_edges,
                              depth=0,
                              opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1, 2]
        ft.do_triplets = False
        mol_graph = MoleculeGraph.with_edges(self.pos_pc, edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 295 * 4)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pos_pc_mols.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pos_pc_mols.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pc_frag1,
                              edges=self.pc_frag1_edges,
                              depth=0)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = False
        pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 12 * 3)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_frag1_mols.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_frag1_mols.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)
Exemplo n.º 3
0
 def test_in_database_through_build_new_FWs(self):
     ft = FragmentMolecule(molecule=self.pc_frag1,
                           edges=self.pc_frag1_edges,
                           depth=0)
     ft.mol = ft.get("molecule")
     ft.depth = ft.get("depth")
     ft.charges = [-1, 0, 1]
     ft.do_triplets = False
     ft.linked = False
     ft.qchem_input_params = {}
     pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
     mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
     unique_frag_dict = mol_graph.build_unique_fragments()
     unique_frag_list = []
     for key in unique_frag_dict:
         for frag in unique_frag_dict[key]:
             unique_frag_list.append(frag)
     ft.unique_fragments = unique_frag_list
     ft._build_unique_relevant_molecules()
     docs = loadfn(os.path.join(module_dir, "doc.json"))
     for doc in docs:
         doc["input"]["initial_molecule"] = doc["input"][
             "initial_molecule"].as_dict()
     ft.all_relevant_docs = docs
     new_FWs = ft._build_new_FWs()
     self.assertEqual(len(new_FWs), 29)
Exemplo n.º 4
0
    def test_build_unique_relevant_molecules_with_triplets(self):
        ft = FragmentMolecule(molecule=self.pc, edges=self.pc_edges, depth=0, opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = True
        edges = {(e[0], e[1]): None for e in self.pc_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc, edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 1323)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_mols_with_trips.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pos_pc, edges=self.pc_edges, depth=0, opt_steps=1000)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1, 2]
        ft.do_triplets = True
        mol_graph = MoleculeGraph.with_edges(self.pos_pc, edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 1770)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pos_pc_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pos_pc_mols_with_trips.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)

        ft = FragmentMolecule(molecule=self.pc_frag1, edges=self.pc_frag1_edges, depth=0)
        ft.mol = ft.get("molecule")
        ft.depth = ft.get("depth")
        ft.charges = [-1, 0, 1]
        ft.do_triplets = True
        pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
        mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
        ft.unique_fragments = mol_graph.build_unique_fragments()
        ft._build_unique_relevant_molecules()
        self.assertEqual(len(ft.unique_molecules), 54)
        #dumpfn(ft.unique_molecules, os.path.join(module_dir,"pc_frag1_mols_with_trips.json"))
        ref_mols = loadfn(os.path.join(module_dir, "pc_frag1_mols_with_trips.json"))
        self.assertEqual(ft.unique_molecules, ref_mols)
Exemplo n.º 5
0
 def test_build_new_FWs(self):
     ft = FragmentMolecule(molecule=self.pc_frag1, edges=self.pc_frag1_edges, depth=0)
     ft.mol = ft.get("molecule")
     ft.depth = ft.get("depth")
     ft.charges = [-1, 0, 1]
     ft.do_triplets = False
     ft.qchem_input_params = {}
     pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
     mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
     ft.unique_fragments = mol_graph.build_unique_fragments()
     ft._build_unique_relevant_molecules()
     ft.all_relevant_docs = list()
     new_FWs = ft._build_new_FWs()
     self.assertEqual(len(new_FWs), 36)
Exemplo n.º 6
0
 def test_build_new_FWs(self):
     ft = FragmentMolecule(molecule=self.pc_frag1,
                           edges=self.pc_frag1_edges,
                           depth=0)
     ft.mol = ft.get("molecule")
     ft.depth = ft.get("depth")
     ft.charges = [-1, 0, 1]
     ft.do_triplets = False
     ft.qchem_input_params = {}
     pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
     mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
     ft.unique_fragments = mol_graph.build_unique_fragments()
     ft._build_unique_relevant_molecules()
     ft.all_relevant_docs = list()
     new_FWs = ft._build_new_FWs()
     self.assertEqual(len(new_FWs), 36)
Exemplo n.º 7
0
 def test_in_database_through_build_new_FWs(self):
     ft = FragmentMolecule(molecule=self.pc_frag1, edges=self.pc_frag1_edges, depth=0)
     ft.mol = ft.get("molecule")
     ft.depth = ft.get("depth")
     ft.charges = [-1, 0, 1]
     ft.do_triplets = False
     ft.qchem_input_params = {}
     pc_frag1_edges = {(e[0], e[1]): None for e in self.pc_frag1_edges}
     mol_graph = MoleculeGraph.with_edges(self.pc_frag1, pc_frag1_edges)
     ft.unique_fragments = mol_graph.build_unique_fragments()
     ft._build_unique_relevant_molecules()
     docs = loadfn(os.path.join(module_dir, "doc.json"))
     for doc in docs:
         doc["input"]["initial_molecule"] = doc["input"]["initial_molecule"].as_dict()
     ft.all_relevant_docs = docs
     new_FWs = ft._build_new_FWs()
     self.assertEqual(len(new_FWs), 29)