Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate the 3D SDF from the output? #1

Open
alexgcsa opened this issue Aug 1, 2021 · 2 comments
Open

How to generate the 3D SDF from the output? #1

alexgcsa opened this issue Aug 1, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@alexgcsa
Copy link

alexgcsa commented Aug 1, 2021

Hello,

Congrats on this work. It is quite interesting.

I have some doubts on it. May you help me?
I was able to run the pre-trained models (checkpoints). A pickle is generated, but how to use this pickle to generate the SDF file for the particular molecule?

I noticed that a 2D molecule is generated in this pickle...How to include the conformers -- like an SDF -- so I can use the output 3D molecule?

Cheers,

Alex

@alexgcsa alexgcsa changed the title How to generate the SDF from the output? How to generate the 3D SDF from the output? Aug 1, 2021
@federico-camerota
Copy link

Hi @alexgcsa, I was able to modify the 'gen.py' script to output pdb files doing the following:

from rdkit.Chem.rdmolfiles import  MolToPDBFile
from rdkit.Chem.AllChem import EmbedMolecule

out = solver.generate_samples_from_smiles(*args*)
EmbedMolecule(out.rdmol, useRandomCoords=True)
gen_mol = utils.set_rdmol_positions(out.rdmol, out.pos_gen[-1])
MolToPDBFile(gen_mol, *output_filename*)

where you should replace appropriately args and output_filename.
If I understood properly the code, out.rdmol is the rdkit mol built from the smiles string.
While out.pos_gen are the generated atom positions.

According to the rdkit documentation, you should be able to write into sdf replacing the last line with:

writer = SDWriter('out.sdf')
writer.write(gen_mol)

If you want to write the pkl into sdf, it should be enough to do:
out = pickle.load(*pkl_file*)

Hope you find this helpful :)

P.S. If you find any error in my solution, please let me know

@alexgcsa
Copy link
Author

alexgcsa commented Aug 7, 2021

Thank you @federico-camerota , I will test your solution today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants