Ejemplo n.º 1
0
  def _featurize_complex(self, mol_pdb_file, protein_pdb_file):
    try:
      frag1_coords, frag1_mol = rdkit_util.load_molecule(
          mol_pdb_file, is_protein=False, sanitize=True, add_hydrogens=False)
      frag2_coords, frag2_mol = rdkit_util.load_molecule(
          protein_pdb_file, is_protein=True, sanitize=True, add_hydrogens=False)
    except MoleculeLoadException:
      # Currently handles loading failures by returning None
      # TODO: Is there a better handling procedure?
      logging.warning("Some molecules cannot be loaded by Rdkit. Skipping")
      return None
    system_mol = rdkit_util.merge_molecules([frag1_mol, frag2_mol])
    system_coords = rdkit_util.get_xyz_from_mol(system_mol)

    frag1_coords, frag1_mol = self._strip_hydrogens(frag1_coords, frag1_mol)
    frag2_coords, frag2_mol = self._strip_hydrogens(frag2_coords, frag2_mol)
    system_coords, system_mol = self._strip_hydrogens(system_coords, system_mol)

    try:
      frag1_coords, frag1_neighbor_list, frag1_z = self.featurize_mol(
          frag1_coords, frag1_mol, self.frag1_num_atoms)

      frag2_coords, frag2_neighbor_list, frag2_z = self.featurize_mol(
          frag2_coords, frag2_mol, self.frag2_num_atoms)

      system_coords, system_neighbor_list, system_z = self.featurize_mol(
          system_coords, system_mol, self.complex_num_atoms)
    except ValueError as e:
      logging.warning(
          "max_atoms was set too low. Some complexes too large and skipped")
      return None

    return frag1_coords, frag1_neighbor_list, frag1_z, frag2_coords, frag2_neighbor_list, frag2_z, \
           system_coords, system_neighbor_list, system_z
Ejemplo n.º 2
0
  def test_get_xyz_from_mol(self):
    current_dir = os.path.dirname(os.path.realpath(__file__))
    ligand_file = os.path.join(current_dir, "../../dock/tests/1jld_ligand.sdf")

    xyz, mol = rdkit_util.load_molecule(
        ligand_file, calc_charges=False, add_hydrogens=False)
    xyz2 = rdkit_util.get_xyz_from_mol(mol)

    equal_array = np.all(xyz == xyz2)
    assert_true(equal_array)
Ejemplo n.º 3
0
    def test_load_docked_ligand(self):
        docked_ligands, scores = vina_utils.load_docked_ligands(
            self.docked_ligands)
        assert len(docked_ligands) == 9
        assert len(scores) == 9

        for ligand, score in zip(docked_ligands, scores):
            xyz = rdkit_util.get_xyz_from_mol(ligand)
            assert score < 0  # This is a binding free energy
            assert np.count_nonzero(xyz) > 0
Ejemplo n.º 4
0
    def test_get_xyz_from_mol(self):
        current_dir = os.path.dirname(os.path.realpath(__file__))
        ligand_file = os.path.join(current_dir,
                                   "../../dock/tests/1jld_ligand.sdf")

        xyz, mol = rdkit_util.load_molecule(ligand_file,
                                            calc_charges=False,
                                            add_hydrogens=False)
        xyz2 = rdkit_util.get_xyz_from_mol(mol)

        equal_array = np.all(xyz == xyz2)
        assert equal_array
Ejemplo n.º 5
0
  def _featurize_complex(self, mol_pdb_file, protein_pdb_file):
    frag1_coords, frag1_mol = rdkit_util.load_molecule(mol_pdb_file)
    frag2_coords, frag2_mol = rdkit_util.load_molecule(protein_pdb_file)
    system_mol = rdkit_util.merge_molecules(frag1_mol, frag2_mol)
    system_coords = rdkit_util.get_xyz_from_mol(system_mol)

    frag1_coords, frag1_mol = self._strip_hydrogens(frag1_coords, frag1_mol)
    frag2_coords, frag2_mol = self._strip_hydrogens(frag2_coords, frag2_mol)
    system_coords, system_mol = self._strip_hydrogens(system_coords, system_mol)

    frag1_coords, frag1_neighbor_list, frag1_z = self.featurize_mol(
        frag1_coords, frag1_mol, self.frag1_num_atoms)

    frag2_coords, frag2_neighbor_list, frag2_z = self.featurize_mol(
        frag2_coords, frag2_mol, self.frag2_num_atoms)

    system_coords, system_neighbor_list, system_z = self.featurize_mol(
        system_coords, system_mol, self.complex_num_atoms)

    return frag1_coords, frag1_neighbor_list, frag1_z, frag2_coords, frag2_neighbor_list, frag2_z, \
           system_coords, system_neighbor_list, system_z
Ejemplo n.º 6
0
  def _featurize_complex(self, mol_pdb_file, protein_pdb_file):
    frag1_coords, frag1_mol = rdkit_util.load_molecule(mol_pdb_file)
    frag2_coords, frag2_mol = rdkit_util.load_molecule(protein_pdb_file)
    system_mol = rdkit_util.merge_molecules(frag1_mol, frag2_mol)
    system_coords = rdkit_util.get_xyz_from_mol(system_mol)

    frag1_coords, frag1_mol = self._strip_hydrogens(frag1_coords, frag1_mol)
    frag2_coords, frag2_mol = self._strip_hydrogens(frag2_coords, frag2_mol)
    system_coords, system_mol = self._strip_hydrogens(system_coords, system_mol)

    frag1_coords, frag1_neighbor_list, frag1_z = self.featurize_mol(
        frag1_coords, frag1_mol, self.frag1_num_atoms)

    frag2_coords, frag2_neighbor_list, frag2_z = self.featurize_mol(
        frag2_coords, frag2_mol, self.frag2_num_atoms)

    system_coords, system_neighbor_list, system_z = self.featurize_mol(
        system_coords, system_mol, self.complex_num_atoms)

    return frag1_coords, frag1_neighbor_list, frag1_z, frag2_coords, frag2_neighbor_list, frag2_z, \
           system_coords, system_neighbor_list, system_z