Hwoo-Kim / DeepBioisostere

Deep Learning-based Bioisosteric Replacements for Optimization of Multiple Molecular Properties
MIT License
12 stars 2 forks source link

install problem #1

Open sistar2020 opened 3 months ago

sistar2020 commented 3 months ago

I tried to install DeepBioisostere as below:

git clone https://github.com/Hwoo-Kim/DeepBioisostere.git
cd DeepBioisostere/
conda create -n DeepBioisostere python=3.9.11
conda activate DeepBioisostere
conda install scipy numpy pandas scikit-learn
pip install matplotlib
conda install -c rdkit rdkit=2022.03.1
conda install seaborn
conda install pytorch==1.11.0 cudatoolkit=11.3 -c pytorch
pip install torch-scatter==2.0.9 torch-sparse==0.6.15 torch-cluster==1.6.0 torch-geometric==2.1.0 -f https://data.pyg.org/whl/torch-1.11.0+cu113.html

So far, it was successful. But when I tried to run "python example.py", I got the following error:

$ python example.py
Traceback (most recent call last):
  File "/opt/modeling/bioisostere/DeepBioisostere/example.py", line 4, in <module>
    from rdkit import Chem
  File "/opt/anaconda310/envs/DeepBioisostere/lib/python3.9/site-packages/rdkit/Chem/__init__.py", line 23, in <module>
    from rdkit.Chem.rdmolfiles import *
ImportError: /opt/anaconda310/envs/DeepBioisostere/lib/python3.9/site-packages/rdkit/Chem/../../../../libRDKitmaeparser.so.1: undefined symb
ol: _ZN5boost9iostreams4zlib8deflatedE

I thought this may be due to the version problem in rdkit. So I installed the latest rdkit as follow: conda install rdkit

Then the above error was gone but got the following errors:

$ python example.py
SMILES: ClC(Cc1c(C(Nc2c(Br)cccc2)=O)cccc1)=O, logP: 4.009, QED: 0.845, Mw: 350.966, SAscore: 1.942
SMILES: Cc1ccc2cnc(N(C)CCc3ccccn3)nc2c1, logP: 3.012, QED: 0.735, Mw: 278.153, SAscore: 2.309
Loading the fragment library...
Traceback (most recent call last):
  File "/opt/modeling/bioisostere/DeepBioisostere/example.py", line 47, in <module>
    generator = Generator(
  File "/opt/modeling/bioisostere/DeepBioisostere/scripts/generate.py", line 97, in __init__
    frags_lib_dataset = FragmentLibrary.get_insertion_frag_library(
  File "/opt/modeling/bioisostere/DeepBioisostere/scripts/dataset.py", line 752, in get_insertion_frag_library
    return cls(fragment_library_df, smi_to_frag_features, frag_brics_maskings)
  File "/opt/modeling/bioisostere/DeepBioisostere/scripts/dataset.py", line 704, in __init__
    self.frag_features = [smi_to_frag_features[smi] for smi in self.frags_smis]
  File "/opt/modeling/bioisostere/DeepBioisostere/scripts/dataset.py", line 704, in <listcomp>
    self.frag_features = [smi_to_frag_features[smi] for smi in self.frags_smis]
KeyError: '[8*]C([8*])O[C@@H]1C[C@@H]2CC[C@H](C1)N2C'

Any help?

Hwoo-Kim commented 3 months ago

Hi there,

We have carefully read your issue. To reproduce your problem, please let me know your OS environment and anaconda version.

sistar2020 commented 3 months ago

Here is the info:

$ lsb_release -a
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
$ conda --version
conda 23.11.0
$ conda list
# packages in environment at /opt/anaconda310/envs/DeepBioisostere:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                       2_gnu    conda-forge
blas                      1.0                         mkl
boost                     1.78.0           py39hda80f44_5    conda-forge
boost-cpp                 1.78.0               h2c5509c_4    conda-forge
bottleneck                1.3.7            py39ha9d4c09_0
brotli                    1.0.9                h5eee18b_8
brotli-bin                1.0.9                h5eee18b_8
bzip2                     1.0.8                h5eee18b_6
ca-certificates           2024.3.11            h06a4308_0
cairo                     1.16.0               h19f5f5c_2
certifi                   2024.6.2                 pypi_0    pypi
charset-normalizer        3.3.2                    pypi_0    pypi
contourpy                 1.2.1                    pypi_0    pypi
cudatoolkit               11.3.1               h2bc3f7f_2
cycler                    0.12.1                   pypi_0    pypi
expat                     2.6.2                h6a678d5_0
fontconfig                2.14.0               h8e229c2_0    conda-forge
fonttools                 4.53.0                   pypi_0    pypi
freetype                  2.12.1               h4a9f257_0
glib                      2.78.4               h6a678d5_0
glib-tools                2.78.4               h6a678d5_0
greenlet                  3.0.1            py39h6a678d5_0
icu                       73.2                 h59595ed_0    conda-forge
idna                      3.7                      pypi_0    pypi
importlib-resources       6.4.0                    pypi_0    pypi
importlib_resources       6.1.1            py39h06a4308_1
intel-openmp              2023.1.0         hdb19cb5_46306
jinja2                    3.1.4                    pypi_0    pypi
joblib                    1.4.2            py39h06a4308_0
jpeg                      9e                   h5eee18b_1
kiwisolver                1.4.5                    pypi_0    pypi
lcms2                     2.12                 h3be6417_0
ld_impl_linux-64          2.38                 h1181459_1
lerc                      3.0                  h295c915_0
libbrotlicommon           1.0.9                h5eee18b_8
libbrotlidec              1.0.9                h5eee18b_8
libbrotlienc              1.0.9                h5eee18b_8
libdeflate                1.17                 h5eee18b_1
libffi                    3.4.4                h6a678d5_1
libgcc-ng                 13.2.0               h77fa898_9    conda-forge
libgfortran-ng            11.2.0               h00389a5_1
libgfortran5              11.2.0               h1234567_1
libglib                   2.78.4               hdc74915_0
libgomp                   13.2.0               h77fa898_9    conda-forge
libiconv                  1.16                 h5eee18b_3
libopenblas               0.3.21               h043d6bf_0
libpng                    1.6.39               h5eee18b_0
libstdcxx-ng              13.2.0               hc0a3c3a_9    conda-forge
libtiff                   4.5.1                h6a678d5_0
libuuid                   2.38.1               h0b41bf4_0    conda-forge
libuv                     1.44.2               h5eee18b_0
libwebp-base              1.3.2                h5eee18b_0
libxcb                    1.15                 h7f8727e_0
libzlib                   1.2.13               h4ab18f5_6    conda-forge
lz4-c                     1.9.4                h6a678d5_1
markupsafe                2.1.5                    pypi_0    pypi
matplotlib                3.9.0                    pypi_0    pypi
matplotlib-base           3.8.4            py39h1128e8f_0
mkl                       2023.1.0         h213fc3f_46344
mkl-service               2.4.0            py39h5eee18b_1
mkl_fft                   1.3.8            py39h5eee18b_0
mkl_random                1.2.4            py39hdb19cb5_0
ncurses                   6.4                  h6a678d5_0
numexpr                   2.8.7            py39h85018f9_0
numpy                     1.26.4           py39h5f9d8c6_0
numpy-base                1.26.4           py39hb5e798b_0
openjpeg                  2.4.0                h3ad879b_0
openssl                   3.0.14               h5eee18b_0
packaging                 24.1                     pypi_0    pypi
pandas                    2.2.2            py39h6a678d5_0
pcre2                     10.42                hebb0a14_1
pillow                    10.3.0           py39h5eee18b_0
pip                       24.0             py39h06a4308_0
pixman                    0.40.0               h7f8727e_1
pybind11-abi              4                    hd3eb1b0_1
pycairo                   1.23.0           py39hd1222b9_0
pyparsing                 3.1.2                    pypi_0    pypi
python                    3.9.19               h955ad1f_1
python-dateutil           2.9.0post0       py39h06a4308_2
python-tzdata             2023.3             pyhd3eb1b0_0
python_abi                3.9                      2_cp39    conda-forge
pytorch                   1.11.0          py3.9_cuda11.3_cudnn8.2.0_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2024.1           py39h06a4308_0
rdkit                     2022.09.4        py39hb00a813_1    conda-forge
readline                  8.2                  h5eee18b_0
reportlab                 3.5.67           py39hfdd840d_1
requests                  2.32.3                   pypi_0    pypi
scikit-learn              1.4.2            py39h1128e8f_1
scipy                     1.13.1           py39h5f9d8c6_0
seaborn                   0.13.2           py39h06a4308_0
setuptools                69.5.1           py39h06a4308_0
six                       1.16.0             pyhd3eb1b0_1
sqlalchemy                2.0.30           py39h5eee18b_0
sqlite                    3.45.3               h5eee18b_0
tbb                       2021.8.0             hdb19cb5_0
threadpoolctl             2.2.0              pyh0d69192_0
tk                        8.6.14               h39e8969_0
torch-cluster             1.6.0                    pypi_0    pypi
torch-geometric           2.1.0                    pypi_0    pypi
torch-scatter             2.0.9                    pypi_0    pypi
torch-sparse              0.6.15                   pypi_0    pypi
tqdm                      4.66.4                   pypi_0    pypi
typing-extensions         4.11.0           py39h06a4308_0
typing_extensions         4.11.0           py39h06a4308_0
tzdata                    2024a                h04d1e81_0
unicodedata2              15.1.0           py39h5eee18b_0
urllib3                   2.2.1                    pypi_0    pypi
wheel                     0.43.0           py39h06a4308_0
xz                        5.4.6                h5eee18b_1
zipp                      3.19.2                   pypi_0    pypi
zlib                      1.2.13               h4ab18f5_6    conda-forge
zstd                      1.5.5                hc292b87_2
sistar2020 commented 2 months ago

At line 696 of "scripts/dataset.py", I inserted the code between "#----". Changed version of the file looks as below:

class FragmentLibrary(Dataset):
    FRAGMENT_LIBRARY_CSV = "fragment_library.csv"
    FRAG_FEATURES = "frag_features.pkl"
    FRAG_BRICS_MASKINGS = "frag_brics_maskings.pkl"

    def __init__(
        self,
        frag_lib: pd.DataFrame,
        smi_to_frag_features: Dict[SMILES, PairData],
        frag_brics_maskings: Dict[Tuple[int], List[torch.BoolTensor]] = None,
        num_cores: int = None,          # used only when parsing fragment library
    ):
        super().__init__()

        #-----------------------------------------------------------------------------------------
        frag_lib['MISSING'] = 0
        for i,row in frag_lib.iterrows():
            smi = row["FRAG-SMI"]
            if smi not in smi_to_frag_features:
                frag_lib.at[i,'MISSING'] = 1
        frag_lib = frag_lib[frag_lib.MISSING == 0]
        frag_lib.drop('MISSING', axis=1, inplace=True)
        #-----------------------------------------------------------------------------------------

        # Save the data in attributes
        self.frags_smis = frag_lib["FRAG-SMI"].to_numpy()
        self.frags_freq = torch.from_numpy(frag_lib["FRAG-FREQ"].to_numpy()).long()
        self.data_type = frag_lib["DATA-TYPE"].to_numpy()
        self.brics_type = frag_lib["BRICS-TYPE"].tolist()  # for sampling

After doing this, things went OK.

$ python example.py
...
Generator initialization finished.
Option 1. Generate with DeepBioisostere.
Elapsed time:  8.666834831237793
Option 2. Generate with a specific leaving fragment.
Elapsed time:  6.4382524490356445