MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.32k stars 652 forks source link

AtomGroup selection of the closest atoms #3601

Open HadrienNU opened 2 years ago

HadrienNU commented 2 years ago

Is your feature request related to a problem?

I would like to have a way a creating an AtomGroup by selection of fixed number of atoms the closest to a selection. That would be useful when using this selection to feed later machine learning code that requires fixed length entries.

Describe the solution you'd like

I would like to have run

closest_solvent = u.select_atoms("closest 5 protein")

to get the closest 5 atoms of my protein.

Describe alternatives you've considered

Additional context

I have written the code to add this feature and before creating a pull request I would like to known if this is of interest.

IAlibay commented 2 years ago

Thanks for the feature request @HadrienNU

Just to add here - there is some ongoing work on this by @richardjgowers (https://github.com/MDAnalysis/mdanalysis/pull/3382) but we've just not had time to properly review it yet.