Ejemplo n.º 1
0
    def test_connected_substructs_converge(self):
        from e3fp.fingerprint import fprinter
        from e3fp.conformer.util import mol_from_sdf
        mol = mol_from_sdf(PLANAR_SDF_FILE)
        conf = mol.GetConformers()[0]
        atoms = list(range(3))
        bonds_dict = {0: {1, 2}, 1: {0}, 2: {0}}
        for atom in atoms:
            conf.SetAtomPosition(atom, [0, 0, .45 * atom])
        with mock.patch('e3fp.fingerprint.fprinter.bound_atoms_from_mol',
                        return_value=bonds_dict):
            shells_gen = fprinter.ShellsGenerator(conf,
                                                  atoms,
                                                  radius_multiplier=0.5,
                                                  include_disconnected=False)
            for i in range(4):
                shells_dict = next(shells_gen)
                substructs_dict = {
                    k: v.substruct
                    for k, v in shells_dict.items()
                }

            next_shells_dict = next(shells_gen)
            next_substructs_dict = {
                k: v.substruct
                for k, v in next_shells_dict.items()
            }

            self.assertDictEqual(substructs_dict, next_substructs_dict)
Ejemplo n.º 2
0
 def test_generates_correct_connected_shells_level2(self):
     from e3fp.fingerprint import fprinter
     from e3fp.fingerprint.structs import Shell
     from e3fp.conformer.util import mol_from_sdf
     mol = mol_from_sdf(PLANAR_SDF_FILE)
     conf = mol.GetConformers()[0]
     atoms = list(range(3))
     bonds_dict = {0: {1, 2}, 1: {0}, 2: {0}}
     for atom in atoms:
         conf.SetAtomPosition(atom, [0, 0, .45 * atom])
     expected_shells_dict1 = {
         0: Shell(0, {1}),
         1: Shell(1, {0}),
         2: Shell(2, {})
     }
     expected_shells_dict2 = {
         0: Shell(0, {expected_shells_dict1[1], expected_shells_dict1[2]}),
         1: Shell(1, {expected_shells_dict1[0]}),
         2: Shell(2, {expected_shells_dict1[0]})
     }
     with mock.patch('e3fp.fingerprint.fprinter.bound_atoms_from_mol',
                     return_value=bonds_dict):
         shells_gen = fprinter.ShellsGenerator(conf,
                                               atoms,
                                               radius_multiplier=0.5,
                                               include_disconnected=False)
         for i in range(3):
             shells_dict = next(shells_gen)
         self.assertDictEqual(shells_dict, expected_shells_dict2)