MDanalysis and Rdkit

234 views
Skip to first unread message

Jan Meyer

unread,
Mar 13, 2021, 6:09:41 PM3/13/21
to MDnalysis discussion
Dear Community,

very recently I read that there should be an interface from mdanalysis to rdkit. And since the pattern search from within rdkit (via smiles/smarts) is really a very powerful tool, I wanted to give it a try. 

To be a bit more precise: The first task I was aiming at was to filter all ring structures (c1ccccc1) from a polymer and compare angles. Just to make sure that the forcefield I choose gives a good representation.

However, when I tried to interface rdkit from mdanalysis and build a rdkit object from a groups of atoms (u.atoms.convert_to("RDKIT")) I always got an error (something like "convert_to has no attribute RDKIT"). 

My first thought was, that I had an old version, so I updated via conda to MDanalysis 1.0.1. But still I got this error. 

So I wanted to ask, if anyone could confirm which versions I need to install, to make use of the mdanalysis-to-rdkit interface? I am very sorry, if the answer to my question is kind of obvious, but I was so far unable to answer it by myself. Any comments would be very much appreciated.

By the way: Is there an equivalent way to get atoms of ring structures from the default MDanalysis search engine? I was able to do it, but it involved several steps. An easier and more direct solution would be nice :).

Many thanks in advance!
Best regards,
Jan

Irfan Alibay

unread,
Mar 13, 2021, 6:19:09 PM3/13/21
to MDnalysis discussion
Hi,

> My first thought was, that I had an old version, so I updated via conda to MDanalysis 1.0.1. But still I got this error. 
Unfortunately the RDKIT converter is part of our current development code (the future MDAnalysis 2.0). We aim to bring out 2.0 in the near future (~ early summer hopefully!), but we still have quite a few things (including an upcoming 1.0.2 release) to complete first. For now, if you would like to try out the RDKIT converter you will have to install the MDAnalysis development code as detailed here: https://userguide.mdanalysis.org/stable/contributing_code.html#building-mdanalysis

> By the way: Is there an equivalent way to get atoms of ring structures from the default MDanalysis search engine?
Not currently (unless I'm missing something). It is one of the aims of one of this year's GSoC proposals, so we hope we might be able to remedy this in the near future.

Best regards,

Irfan

Jan Meyer

unread,
Mar 17, 2021, 2:11:31 PM3/17/21
to mdnalysis-...@googlegroups.com
Many thanks for your response! I am really looking forward to version 2.0.0.

I was wondering if there are also any plans to adapt a chemical language like smiles for the coarse grained level. 

Best regards, 
Jan

--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/29df6a36-f771-4c99-8f94-157fe6cd8b10n%40googlegroups.com.

Irfan Alibay

unread,
Mar 17, 2021, 3:20:36 PM3/17/21
to MDnalysis discussion
Hi Jan,

> I was wondering if there are also any plans to adapt a chemical language like smiles for the coarse grained level. 

Unfortunately I am not sure what you mean here. Could you provide more information about the type of thing you are looking for? (maybe one of the other developers might have some ideas?)

- Irfan

Hugo Macdermott-Opeskin

unread,
Mar 17, 2021, 5:32:02 PM3/17/21
to MDnalysis discussion
Hi Jan,

A very interesting problem. I haven't ever seen a tool or language that does this. 
My guess is that a smiles like language for coarse-grain representations would be ill formed in the majority of cases, unless you came up with your own specific ontology and retain information about how to transform the CG representation back to a smiles or selfies string.  Thats just my guess however and I would love to be proved wrong!
Cheers

Hugo

Jan Meyer

unread,
Jun 3, 2021, 3:05:47 PM6/3/21
to mdnalysis-...@googlegroups.com
Dear Hugo, 


I have to apologize for my so much delayed response. Actually I was thinking about his for quite a while but also had quite a bunch load of other things in mind, which is why I never came back to this. 

In principle I guess that you are right with your assumption, that a cg smiles language is not so trivial, because you know nothing about the chemistry of the cg model per default. However I sometimes face the problem of picking certain groups from a polymer chain, where I would love to specify the groups in a smiles way. Actually I thought about mapping cg beads to atoms types via a dict and using rdkit for that purpose :). 

By the way: last week I wanted to grep certain atomistic groups from a polymer chain to calculate their center of mass for a mapping to the cg level. With the rdkit implementation in MDanalysis this would have been very straight forward, but I guess version 2.0 is still some way to go, right? Maybe I would need to test the dev version in the upcoming days. I was wondering what would actually be the most efficient way to execute my task with version 1.x.x. So let me give an example let's say I have polymer  chain with 100 repeat units. And I want to pick all atomic groups "OC(=O) O". What would be the best way to do it? Pick the C atom and than all neighbors, or is there a direct specification for the whole group possible? What about groups that consist of even more than those 4 atoms? 


Many thanks in advance! 
Best regards,
Jan
You received this message because you are subscribed to a topic in the Google Groups "MDnalysis discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mdnalysis-discussion/FU8i_Vp8fyA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/fc776849-648d-46ed-927c-1931a11b1bdcn%40googlegroups.com.

Oliver Beckstein

unread,
Jun 3, 2021, 3:11:31 PM6/3/21
to mdnalysis-discussion
Hi Jan,

On Jun 3, 2021, at 12:05 PM, Jan Meyer <bienewi...@gmail.com> wrote:

By the way: last week I wanted to grep certain atomistic groups from a polymer chain to calculate their center of mass for a mapping to the cg level. With the rdkit implementation in MDanalysis this would have been very straight forward, but I guess version 2.0 is still some way to go, right?

You can install the beta version of 2.0.0 with

pip install MDAnalysis==2.0.0b0
pip install MDAnalysisTests==2.0.0b0

We’d love to get feedback from users.

Oliver


--
Oliver Beckstein (he/his/him)


MDAnalysis – a NumFOCUS fiscally sponsored project




Lily Wang

unread,
Jun 3, 2021, 3:54:09 PM6/3/21
to mdnalysis-...@googlegroups.com
Hi Jan,

There are a few ways you could do that. Firstly, you could install the MDAnalysis 2.0 beta with:

pip install mdanalysis==2.0.0b0

If you used MDAnalysis, you could use the smarts matching. I got the smarts pattern from Chem.MolToSmarts(Chem.MolFromSmiles("OC(=O)O")):

u = mda.Universe("my file")
matching_atoms = u.select_atoms("smarts [#8]-[#6](=[#8])-[#8]")

This gets you all the matching atoms, I suppse you will want to split them by residue for further processing.

list_of_atomgroups = matching_atoms.split("residue")

Alternatively you could head straight to the center of mass (you might need to set the pbc and unwrap keywords to get good values):

centers = matching_atoms.center_of_mass(compound="residue")

Re: CG smiles. Perhaps a model like HELM would be interesting, where a "monomer" is just the CG bead and the atom-level structural representation is the substructure that it represents.


Cheers,
Lily

Jan Meyer

unread,
Jun 4, 2021, 2:00:34 PM6/4/21
to mdnalysis-...@googlegroups.com
Great many thanks! 

I will test it and let you know about the results. 

Best regards, 
Jan

Jan Meyer

unread,
Jun 7, 2021, 12:06:25 PM6/7/21
to mdnalysis-...@googlegroups.com
Hi again, 

is the installation of version 2.0.0beta only possible via pip or is an installation via conda possible as well? I am working from a corporate environment and I am having trouble setting up pip in my wsl environment, while conda is working properly. I might be able to figure out how to resolve this, but the conda option would be way faster :). 

Many thanks
Jan

Irfan Alibay

unread,
Jun 7, 2021, 12:14:04 PM6/7/21
to MDnalysis discussion
Hi,

Unfortunately have decided to restrict the beta to pip installs only.

If you can provide more details about your pip issues I can try to help (although given "corporate" is brought up, I assume it's something along the lines of a firewall issue?).

Regards,

Irfan

Oliver Beckstein

unread,
Jun 7, 2021, 3:04:00 PM6/7/21
to mdnalysis-discussion
Hi Jan,

You can set up a conda environment with everything that’s needed (that’s what we do for our tests) and then pip-install in this environment. If pip cannot fetch the package, download the tarball from https://pypi.org/project/MDAnalysis/2.0.0b0/#files

For conda the package list is something like (from https://github.com/MDAnalysis/mdanalysis/blob/develop/.github/workflows/gh-ci.yaml) via conda-forge

numpy
pip pytest mmtf-python biopython networkx cython matplotlib-base scipy griddataformats hypothesis gsd codecov threadpoolctl
seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles>=0.9 tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py openmm

possible additional pip-based dependencies:
duecredit parmed


Oliver


On Jun 7, 2021, at 9:14 AM, Irfan Alibay <ial...@mdanalysis.org> wrote:

Hi,

Unfortunately have decided to restrict the beta to pip installs only.

If you can provide more details about your pip issues I can try to help (although given "corporate" is brought up, I assume it's something along the lines of a firewall issue?).

Regards,

Irfan

On Monday, June 7, 2021 at 5:06:25 PM UTC+1 bienewi...@gmail.com wrote:
Hi again, 

is the installation of version 2.0.0beta only possible via pip or is an installation via conda possible as well? I am working from a corporate environment and I am having trouble setting up pip in my wsl environment, while conda is working properly. I might be able to figure out how to resolve this, but the conda option would be way faster :). 

Many thanks
Jan

--
Oliver Beckstein (he/his/him)







Jan Meyer

unread,
Jun 8, 2021, 1:59:06 PM6/8/21
to mdnalysis-...@googlegroups.com
Great suggestion. Many thanks! 

Best regards, 
Jan

--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages