コード例 #1
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);
        }
    }