-
Notifications
You must be signed in to change notification settings - Fork 670
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
Iterative Average structures #2039
Comments
The paper can be added to the class as well, using duecredit and its DOI 10.1021/acs.jpcb.7b11988. |
* added align.AverageStructure * added more tests and example * related to #2039
with the implementation of #2430 the iterative algorithm can be implemented using only def iterative_average(mobile,
ref,
weights=None,
niter=100,
eps=1e-8,
verbose=False,
**kwargs):
"""Calculate an optimal reference that is also the average structure after an
RMSD alignment. The optional reference is defined as average structure of a trajectory, with the optimal reference used as input. This function computes the optimal reference by using a starting reference for the average structure, which is used to calculate the average structure again. This is repeated until the reference structure has converged.
Parameters
----------
mobile : mda.AtomGroup
mobile atomgroup to find the average for
ref : mda.AtomGroup
initial reference structure. Positions are changed by this function!
weights : str, array_like (optional)
weights that can be used. If `None` use equal weights, if `'mass'` use masses of ref as weights or give an array of arbitrary weights.
niter : int (optional)
maximum number of iterations
eps : float (optional)
RMSD distance at which reference and average are assumed to be equal
verbose : bool (optional)
verbosity
**kwargs : dict (optional)
AverageStructure kwargs
Returns
-------
res : AverageStructure
AverageStructure result from the last iteration
"""
drmsd = np.inf
for i in range(niter):
# found a converged structure
if drmsd < eps:
break
res = AverageStructure(mobile, ref, weights, **kwargs).run()
drmsd = mda.analysis.rms.rmsd(ref.positions, res.structure, weights=weights)
ref.positions = res.positions
if verbose:
print("i = {}, rmsd-change = {:.2f}, ave-rmsd = {:.2f}, ave-msf = {:.2f}".
format(i, drmsd, res.rmsd, res.msf.mean()))
return res |
Hello , I would like to take up this issue, Kindly guide me through what needs to be done in this issue. |
@Neel-Shah-29 , you'd add the There hasn't been a lot of discussion on this issue so it's quite possible that reviewers of your code might say that we want this functionality to follow the standard schema for analysis tools, namely being a class derived from AnalysisBase (see https://docs.mdanalysis.org/stable/documentation_pages/analysis/base.html). You can start with a PR where you add the code provided by @kain88-de to the existing code base and make the new tests work. We'll then use your PR for further discussions. Please also introduce yourself on the developer list with your GitHub handle (if you haven't done so already). |
Is your feature request related to a problem? Please describe.
In a recent paper of mine, I describe an iterative algorithm to calculate an average structure from simulations. Below is the description.
I would expect that this algorithm was already previously described. If anyone knows an earlier paper please add it to this issue so we can properly cite it. I currently do not have time to include this properly into MDAnalysis.
Note: I find this a good example to show how the changes of our analysis module in the last two years allow it to quickly write up a new analysis type that is easy to reuse and share.
Describe the solution you'd like
This is the complete implementation I used including tests. I'm posting it here should anyone be interested in including this into the align module of MDAnalysis. If anyone wants to just use this please consider to cite my paper when you do. The code can be used under the same license that MDAnalysis uses.
Some reference tests I have. They only check for regressions. Correctness was only validated visually so don't put too much trust into these tests.
edit kain88-de: Removed class unrelated to this feature from example code.
The text was updated successfully, but these errors were encountered: