-
Notifications
You must be signed in to change notification settings - Fork 817
Add no selection option to RMSD analysis class #5296
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
Changes from all commits
a9ebc7e
8f48321
f0bc9d6
5ceb6b6
fe28756
cfa14e2
75754fd
6ed6dc4
975b636
5f5760b
a6a4f27
4cf84a8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -287,17 +287,19 @@ def process_selection(select): | |||||||||||
|
|
||||||||||||
| Parameters | ||||||||||||
| ---------- | ||||||||||||
| select : str or tuple or dict | ||||||||||||
| select : str or tuple or dict or None | ||||||||||||
|
|
||||||||||||
| - `str` -> Any valid string selection | ||||||||||||
| - `dict` -> ``{'mobile':sel1, 'reference':sel2}`` | ||||||||||||
| - `tuple` -> ``(sel1, sel2)`` | ||||||||||||
| - ``None`` | ||||||||||||
|
|
||||||||||||
| Returns | ||||||||||||
| ------- | ||||||||||||
| dict | ||||||||||||
| selections for 'reference' and 'mobile'. Values are guarenteed to be | ||||||||||||
| iterable (so that one can provide selections to retain order) | ||||||||||||
| iterable (so that one can provide selections to retain order) or | ||||||||||||
| ``None`` if no selection is to be performed. | ||||||||||||
|
|
||||||||||||
| Notes | ||||||||||||
| ----- | ||||||||||||
|
|
@@ -325,10 +327,16 @@ def process_selection(select): | |||||||||||
| "select dictionary must contain entries for keys " | ||||||||||||
| "'mobile' and 'reference'." | ||||||||||||
| ) from None | ||||||||||||
| elif select is None: | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing that I keep going back and forth in my head is that 'all' and
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem is that it would be inconsistent with the usual
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just read the docs and it's clear that sorting is intended and not just a side effect. So yea, I think https://docs.mdanalysis.org/2.9.0/documentation_pages/selections.html LGTM now.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reflecting on this, this is how mdanalysis/package/MDAnalysis/analysis/align.py Lines 409 to 413 in 9531c6e
So there is a legitimate debate on whether
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'd say, the fact that align chooses "all" when selecting None is more a historical accident where None was just used as "default" and an argument could be made to change its behavior for "all". It would be more consistent if "all" behaved like a selection. (by the way, "all" is not properly documented in https://docs.mdanalysis.org/2.10.0/documentation_pages/selections.html ... )
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I raised #5317 for documenting "all"... |
||||||||||||
| select = {"reference": None, "mobile": None} | ||||||||||||
| else: | ||||||||||||
| raise TypeError("'select' must be either a string, 2-tuple, or dict") | ||||||||||||
| select["mobile"] = asiterable(select["mobile"]) | ||||||||||||
| select["reference"] = asiterable(select["reference"]) | ||||||||||||
| raise TypeError( | ||||||||||||
| "'select' must be either a string, 2-tuple, dict or None" | ||||||||||||
| ) | ||||||||||||
| if select["mobile"] is not None: | ||||||||||||
| select["mobile"] = asiterable(select["mobile"]) | ||||||||||||
| if select["reference"] is not None: | ||||||||||||
| select["reference"] = asiterable(select["reference"]) | ||||||||||||
| return select | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
|
|
@@ -394,7 +402,7 @@ def __init__( | |||||||||||
| reference : AtomGroup or Universe (optional) | ||||||||||||
| Group of reference atoms; if ``None`` then the current frame of | ||||||||||||
| `atomgroup` is used. | ||||||||||||
| select : str or dict or tuple (optional) | ||||||||||||
| select : str or dict or tuple or None (optional) | ||||||||||||
| The selection to operate on; can be one of: | ||||||||||||
|
|
||||||||||||
| 1. any valid selection string for | ||||||||||||
|
|
@@ -405,16 +413,21 @@ def __init__( | |||||||||||
| and *sel2* are valid selection strings that are applied to | ||||||||||||
| `atomgroup` and `reference` respectively (the | ||||||||||||
| :func:`MDAnalysis.analysis.align.fasta2select` function returns such | ||||||||||||
| a dictionary based on a ClustalW_ or STAMP_ sequence alignment); or | ||||||||||||
| a dictionary based on a ClustalW_ or STAMP_ sequence alignment) or | ||||||||||||
| ``None`` if no selection is to be performed; or | ||||||||||||
|
|
||||||||||||
| 3. a tuple ``(sel1, sel2)`` | ||||||||||||
|
|
||||||||||||
| 4. ``None`` | ||||||||||||
|
|
||||||||||||
| When using 2. or 3. with *sel1* and *sel2* then these selection strings | ||||||||||||
| are applied to `atomgroup` and `reference` respectively and should | ||||||||||||
| generate *groups of equivalent atoms*. *sel1* and *sel2* can each also | ||||||||||||
| be a *list of selection strings* to generate a | ||||||||||||
| :class:`~MDAnalysis.core.groups.AtomGroup` with defined atom order as | ||||||||||||
| described under :ref:`ordered-selections-label`). | ||||||||||||
| described under :ref:`ordered-selections-label`). When using ``None`` | ||||||||||||
| no selection is performed and all atoms from `atomgroup` or `reference` | ||||||||||||
| are used in their original order. | ||||||||||||
|
|
||||||||||||
| groupselections : list (optional) | ||||||||||||
| A list of selections as described for `select`, with the difference | ||||||||||||
|
|
@@ -539,8 +552,16 @@ def __init__( | |||||||||||
| self.tol_mass = tol_mass | ||||||||||||
| self.ref_frame = ref_frame | ||||||||||||
| self.weights_groupselections = weights_groupselections | ||||||||||||
| self.ref_atoms = self.reference.select_atoms(*select["reference"]) | ||||||||||||
| self.mobile_atoms = self.atomgroup.select_atoms(*select["mobile"]) | ||||||||||||
| self.ref_atoms = ( | ||||||||||||
| self.reference.select_atoms(*select["reference"]) | ||||||||||||
| if select["reference"] is not None | ||||||||||||
| else self.reference | ||||||||||||
| ) | ||||||||||||
| self.mobile_atoms = ( | ||||||||||||
| self.atomgroup.select_atoms(*select["mobile"]) | ||||||||||||
| if select["mobile"] is not None | ||||||||||||
| else self.atomgroup | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| if len(self.ref_atoms) != len(self.mobile_atoms): | ||||||||||||
| err = ( | ||||||||||||
|
|
||||||||||||
Uh oh!
There was an error while loading. Please reload this page.