/// <summary>
        /// Performs a mol copy and adds explicit hydrogens to each heavy atom to the copy
        /// </summary>
        /// <param name="mol"></param>
        /// <returns>Copy of original mol with explicit hydrogens</returns>
        public static OBMol AddExplicitHydrogens(this OBMol mol)
        {
            var newMol = new OBMol(mol);

            foreach (var atom in newMol.Atoms())
            {
                newMol.AddHydrogens(atom);
            }
            return(newMol);
        }
示例#2
0
    public void readMol(string file)
    {
        bool   hideHydrogens  = PlayerPrefs.GetString("hideHydrogens") == "True";
        bool   polarHydrogens = PlayerPrefs.GetString("polarHydrogens") == "True";
        string ff             = PlayerPrefs.GetString("forceField");

        OpenBabel.OBConversion obconv = new OBConversion();

        extension = file.Split('.')[1];
        if (extension == "pdb")
        {
            obconv.SetInFormat("PDB");
        }
        else if (extension == "sdf")
        {
            obconv.SetInFormat("SDF");
        }
        else if (extension == "mol2")
        {
            obconv.SetInFormat("MOL2");
        }

        mol = new OBMol();
        obconv.ReadFile(mol, file);

        if (hideHydrogens)
        {
            mol.DeleteHydrogens();
        }
        else
        {
            mol.AddHydrogens();
        }

        if (polarHydrogens)
        {
            mol.DeleteNonPolarHydrogens();
        }

        if (ff != "")           //a force field is selected

        // Ghemical, MMFF94, UFF
        {
            OBForceField forceField = OBForceField.FindForceField(ff);

            forceField.Setup(mol);
            forceField.ConjugateGradients(1000);
        }
    }