{"action":"created","issue":{"url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1188","repository_url":"https://api.github.com/repos/mdtraj/mdtraj","labels_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1188/labels{/name}","comments_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1188/comments","events_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1188/events","html_url":"https://github.com/mdtraj/mdtraj/issues/1188","id":184667697,"number":1188,"title":"Simplest way to compute RMSD for selection1 while aligning on selection2","user":{"login":"jchodera","id":3656088,"avatar_url":"https://avatars.githubusercontent.com/u/3656088?v=3","gravatar_id":"","url":"https://api.github.com/users/jchodera","html_url":"https://github.com/jchodera","followers_url":"https://api.github.com/users/jchodera/followers","following_url":"https://api.github.com/users/jchodera/following{/other_user}","gists_url":"https://api.github.com/users/jchodera/gists{/gist_id}","starred_url":"https://api.github.com/users/jchodera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchodera/subscriptions","organizations_url":"https://api.github.com/users/jchodera/orgs","repos_url":"https://api.github.com/users/jchodera/repos","events_url":"https://api.github.com/users/jchodera/events{/privacy}","received_events_url":"https://api.github.com/users/jchodera/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-10-23T02:43:16Z","updated_at":"2016-10-25T18:17:34Z","closed_at":null,"body":"Is there a simple way to use `mdtraj` to align a trajectory to a reference structure on `selection2` and compute the RMSD on `selection2`? \r\n\r\n[`mdtraj.rmsd`](http://mdtraj.org/1.7.2/api/generated/mdtraj.rmsd.html#mdtraj.rmsd) doesn't seem to have a provision to specify the subset used for alignment, and while there is a [`Trajectory.superpose`](http://mdtraj.org/1.7.2/api/generated/mdtraj.Trajectory.superpose.html#mdtraj.Trajectory.superpose), there's no way to then compute the RMSD in place without aligning again.\r\n\r\nMy guess is that the easiest way to do this is\r\n```python\r\n# Align to reference\r\ntrajectory.superpose(reference, atom_indices=selection1, ref_atom_indices=selection1)\r\n# Compute the RMSD manually without additional alignment\r\nrmsd = np.sqrt(3*np.mean((trajectory.xyz[:, selection2, :] - reference.xyz[:, selection2, :])**2, axis=(1,2)))\r\n```\r\nDoes that sound right?\r\n\r\nThat's not incredibly complicated, but may be worth wrapping in a convenience function."},"comment":{"url":"https://api.github.com/repos/mdtraj/mdtraj/issues/comments/256119442","html_url":"https://github.com/mdtraj/mdtraj/issues/1188#issuecomment-256119442","issue_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1188","id":256119442,"user":{"login":"jchodera","id":3656088,"avatar_url":"https://avatars.githubusercontent.com/u/3656088?v=3","gravatar_id":"","url":"https://api.github.com/users/jchodera","html_url":"https://github.com/jchodera","followers_url":"https://api.github.com/users/jchodera/followers","following_url":"https://api.github.com/users/jchodera/following{/other_user}","gists_url":"https://api.github.com/users/jchodera/gists{/gist_id}","starred_url":"https://api.github.com/users/jchodera/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jchodera/subscriptions","organizations_url":"https://api.github.com/users/jchodera/orgs","repos_url":"https://api.github.com/users/jchodera/repos","events_url":"https://api.github.com/users/jchodera/events{/privacy}","received_events_url":"https://api.github.com/users/jchodera/received_events","type":"User","site_admin":false},"created_at":"2016-10-25T18:17:34Z","updated_at":"2016-10-25T18:17:34Z","body":"Just to add to that argument: I managed to mess this up twice, even though\nthe expression was simple. So there would be value in making it easy for\nusers to not make mistakes the first time!\n"}}
{"actor":{"display_login":"jchodera"}}