コード例 #1
0
def test_checker_nlimits(sdf=SDF_LIMIT_ATOMS):
    try:
        ch.check_limit_number_atoms(sdf, 100)
    except ce.LigandSizeExceed:
        assert True
    else:
        assert False
コード例 #2
0
ファイル: simulation.py プロジェクト: cescgina/pele_platform
    def _prepare_input_file(self, logger=None):
        from rdkit import Chem
        import rdkit.Chem.rdmolops as rd

        self.parameters.input = "input.conf"

        params = self.parameters

        # Check input file
        limit_atoms_ligand = 100
        ch.check_limit_number_atoms(params.ligands, limit_atoms_ligand)

        # Get core of the ligand
        mol = Chem.MolFromPDBFile(params.core)
        try:
            ligand_core = rd.SplitMolByPDBResidues(mol)[params.residue]
        except KeyError:
            raise ce.MissResidueFlag("Missing residue flag to specify " +
                                     "the ligand core residue name. " +
                                     "i.e resname: 'LIG'")

        # Get sdf full grown ligands
        ligands_grown = Chem.SDMolSupplier(params.ligands, removeHs=False)
        fragment_files = []

        # For each full grown ligand create neutral fragment
        with open(params.input, "w") as fout:
            pass
        for ligand in ligands_grown:
            Chem.AssignAtomChiralTagsFromStructure(ligand)
            try:
                line, fragment = \
                    self._create_fragment_from_ligand(ligand,
                                                      ligand_core)
            except Exception as e:
                try:
                    line, fragment = \
                        self._create_fragment_from_ligand(ligand,
                                                          ligand_core,
                                                          substructure=False)
                except Exception as e:
                    try:
                        # Try to fix symmetry
                        line, fragment = \
                            self._create_fragment_from_ligand(ligand,
                                                              ligand_core,
                                                              symmetry=True)
                    except Exception as e:
                        # Try with second substructure search
                        line, fragment = \
                            self._create_fragment_from_ligand(
                                ligand, ligand_core,
                                result=1, substructure=False)

            logger.info(f"Ligand {fragment.file} preprocessed")
            fragment_files.append(fragment.file)
            with open(params.input, "a") as fout:
                fout.write(line + "\n")

        return fragment_files
コード例 #3
0
    def _prepare_input_file(self):
        from rdkit import Chem
        import rdkit.Chem.rdmolops as rd
        import rdkit.Chem.rdchem as rc
        import rdkit.Chem.AllChem as rp

        self.input = "input.conf"

        #Check input file
        limit_atoms_ligand = 100
        ch.check_limit_number_atoms(self.ligands, limit_atoms_ligand)

        #Get core of the ligand
        mol = Chem.MolFromPDBFile(self.core)
        try:
            ligand_core = rd.SplitMolByPDBResidues(mol)[self.residue]
        except KeyError:
            raise ce.MissResidueFlag(
                "Missing residue flag to specify the ligand core residue name. i.e resname: 'LIG'"
            )

        #Get sdf full grown ligands
        ligands_grown = Chem.SDMolSupplier(self.ligands, removeHs=False)

        #For each full grown ligand create neutral fragment
        self.fragments = []
        lines = []
        for ligand in ligands_grown:
            try:
                line, fragment = self._create_fragment_from_ligand(
                    ligand, ligand_core)
            except Exception as e:
                try:
                    # Try to fix simmetry
                    line, fragment = self._create_fragment_from_ligand(
                        ligand, ligand_core, simmetry=True)
                except Exception as e:
                    try:
                        # Try with second substructure search
                        line, fragment = self._create_fragment_from_ligand(
                            ligand, ligand_core, result=1, substructure=False)
                    except Exception as e:
                        #Skip the ligand
                        print("Ligand Skipped")
                        print(e)
                        continue
            lines.append(line)
            self.fragments.append(fragment)
            print(f"Ligand {fragment.file} preprocessed")
        with open(self.input, "w") as fout:
            fout.write(("\n").join(lines))