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

Directly using an RDKit mol with the mol_col parameter #3

Merged
merged 5 commits into from Mar 29, 2021

Conversation

fredrikw
Copy link
Contributor

Added an option "mdl_col" to use coordinates allready present in DataFrame or other input. There are probably other ways to implement this, but I needed a way to draw molecules with the coordinates prepared in advance.

@cbouy
Copy link
Owner

cbouy commented Mar 24, 2021

Thank you for your contribution, I like the idea of using pre-existing coordinates!
I think it would make more sense to directly store an RDKit mol in the internal DataFrame and directly use that for drawing instead of relying on a SMILES/MDL column then converting it to a mol then drawing it.
This way it should be possible to add arbitrary annotations on atoms or bonds.
I'll try some changes and come back to you.

@fredrikw
Copy link
Contributor Author

That sounds like a very good alternative! This was simpler to me since I had the Molblock in the dataframe allready :-)

@cbouy
Copy link
Owner

cbouy commented Mar 24, 2021

I've made the changes, can you tell me if it integrates nicely with your use case ?

Assuming your dataframe has a column named "MDL" containing a series of MolBlock, you should be able to do

mols2grid.display(
    df.assign(mol=lambda x:
              [Chem.MolFromMolBlock(mdl) for mdl in x["MDL"]]),
    mol_col='mol')

@fredrikw
Copy link
Contributor Author

I have now tested and it is working great in my use case!

@cbouy cbouy changed the title Mdl option Directly using an RDKit mol with the mol_col parameter Mar 29, 2021
@cbouy cbouy merged commit ca4c81d into cbouy:master Mar 29, 2021
@cbouy
Copy link
Owner

cbouy commented Mar 29, 2021

Thank you @fredrikw 👍

@fredrikw fredrikw deleted the mdl_option branch March 29, 2021 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants