isayevlab / Auto3D_pkg

Auto3D generates low-energy conformers from SMILES/SDF
MIT License
146 stars 32 forks source link

Error on tautomer example #38

Open izxle opened 1 year ago

izxle commented 1 year ago

Describe the bug The tautomer example gets an error when running on a clean install. This error seems to be originating from RDKit.

To Reproduce Steps to reproduce the behavior:

  1. Follow the instalation instructions
  2. Install and start jupyterlab
  3. Run the cells of the tautomers examples: /examples/tautomer.ipynb
  4. See error

Expected behavior The example should run without errors.

Error messages

/examples/tautomer.ipynb

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/var/folders/c1/ly1p3sf14rnc9fpcrzq46q440000gp/T/ipykernel_1014/1582100770.py in <module>
      4                    optimizing_engine="ANI2xt",  #ANI2xt is NNP designed for tautomers
      5                    max_confs=10, patience=200, use_gpu=False)
----> 6     tautomer_out = get_stable_tautomers(args, tauto_k=3)

~/miniconda3/envs/autoed-2/lib/python3.7/site-packages/Auto3D/tautomer.py in get_stable_tautomers(args, tauto_k, tauto_window)
     81     """
     82     out = main(args)
---> 83     out_tautomer = select_tautomers(out, tauto_k, tauto_window)
     84     return out_tautomer

~/miniconda3/envs/autoed-2/lib/python3.7/site-packages/Auto3D/tautomer.py in select_tautomers(sdf, k, window)
     63     basename = os.path.basename(sdf).split(".")[0].strip() + "_top_tautomers.sdf"
     64     output_path = os.path.join(folder, basename)
---> 65     with Chem.SDWriter(output_path) as w:
     66         for mol in results:
     67             w.write(mol)

AttributeError: __enter__

image

System information:

LiuCMU commented 1 year ago

Hey @izxle , thanks for the detailed bug information!

This indeed seems like an issue with RDKit. Could you try to update RDkit to be at least 2022.03.1, then run again to see if the problem persists? For me, I run tautomer.ipynb on MBP, and it took just 3 minutes.

conda install "rdkit >= 2022.03.1"

izxle commented 1 year ago

Thanks, it worked now. It took more than an hour to run on my machine.

LiuCMU commented 1 year ago

After using rdkit >= 2022.03.1, did it still take about 1 hour to run the tautomer example?

isayev commented 1 year ago

@izxle do you use GPU? Please check if you have a CUDA device in your system.

izxle commented 1 year ago

@LiuCMU No, I just checked it again. It now took 45 min.

izxle commented 1 year ago

@isayev I have an NVIDIA GeForce GTX 512 MB. But I didn't tell the program to use it, do I have to enable it somehow?

izxle commented 1 year ago

Also, a minor "error" on the order of the cells. The fourth code cell displays the tautomers list but this variable is defined on the next code cell. So if you run it all you get a NameError and need to backtrack after running the fifth code cell to not get the error.

LiuCMU commented 1 year ago

Thanks for the feedback! I will update the tautomer.ipynb example.

It should be within minutes even on the CPU. Could you check you RDKit version (using print(rdkit.__version__)) in the jupyter notebook you are running? Just to make sure the RDKit in this specific environment is expected. I noted that you got 533 total conformers even when max_confs=10, which indicating the this argument is not working. This behavior happens on older RDKit versions.

It runs much faster on GPU. To use GPU, you just need to specify that use_gpu=True:

    args = options(input_path, k=1, enumerate_tautomer=True, tauto_engine="rdkit",
                   optimizing_engine="ANI2xt",  #ANI2xt is NNP designed for tautomers
                   max_confs=10, patience=200, use_gpu=True)
izxle commented 1 year ago

rdkit version = 2022.09.1

I tried the use_gpu=True but it said that it didn't detect any CUDA device.

isayev commented 1 year ago

@izxle You need to install a modern NVIDIA GPU driver and CUDA toolkit. Next, if all work correctly, you could run nvidia-smi from the command line. It will show you available CUDA devices e.g.: image

izxle commented 1 year ago

Apparently, there aren't any drivers for MacOS for the NVIDIA GeForce GTX 660M 512 MB.