{"action":"created","issue":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/726","repository_url":"https://api.github.com/repos/MDAnalysis/mdanalysis","labels_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/726/labels{/name}","comments_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/726/comments","events_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/726/events","html_url":"https://github.com/MDAnalysis/mdanalysis/issues/726","id":134104580,"number":726,"title":"set subtraction for AtomGroups","user":{"login":"khuston","id":4020899,"avatar_url":"https://avatars.githubusercontent.com/u/4020899?v=3","gravatar_id":"","url":"https://api.github.com/users/khuston","html_url":"https://github.com/khuston","followers_url":"https://api.github.com/users/khuston/followers","following_url":"https://api.github.com/users/khuston/following{/other_user}","gists_url":"https://api.github.com/users/khuston/gists{/gist_id}","starred_url":"https://api.github.com/users/khuston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/khuston/subscriptions","organizations_url":"https://api.github.com/users/khuston/orgs","repos_url":"https://api.github.com/users/khuston/repos","events_url":"https://api.github.com/users/khuston/events{/privacy}","received_events_url":"https://api.github.com/users/khuston/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels/Component-Core","name":"Component-Core","color":"ff0000"},{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/labels/usability","name":"usability","color":"5319e7"}],"state":"open","locked":false,"assignee":{"login":"jbarnoud","id":1382074,"avatar_url":"https://avatars.githubusercontent.com/u/1382074?v=3","gravatar_id":"","url":"https://api.github.com/users/jbarnoud","html_url":"https://github.com/jbarnoud","followers_url":"https://api.github.com/users/jbarnoud/followers","following_url":"https://api.github.com/users/jbarnoud/following{/other_user}","gists_url":"https://api.github.com/users/jbarnoud/gists{/gist_id}","starred_url":"https://api.github.com/users/jbarnoud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbarnoud/subscriptions","organizations_url":"https://api.github.com/users/jbarnoud/orgs","repos_url":"https://api.github.com/users/jbarnoud/repos","events_url":"https://api.github.com/users/jbarnoud/events{/privacy}","received_events_url":"https://api.github.com/users/jbarnoud/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2016-02-16T21:42:28Z","updated_at":"2016-02-16T23:10:54Z","closed_at":null,"body":"I apologize if this is already a feature or if has been discussed before, but I've often thought AtomGroup subtraction would be a convenient feature, in the same way `__add__` is already overridden for AtomGroup. It would be defined in the same way set subtraction is defined for Python:\r\n\r\nFor AtomGroup instances:\r\n\r\n    return AtomGroup(list(set(self._atoms) - set(other._atoms)))\r\n\r\nFor Atom instances:\r\n\r\n    return AtomGroup(list(set(self._atoms) - set([other])))\r\n\r\nIt's a simple addition, but it seems to work. If it's alright, I can submit a pull request with the feature and tests.\r\nExample usage:\r\n\r\n    In [2]: u.select_atoms('resname 58')\r\n    Out[2]: <AtomGroup with 300 atoms>\r\n\r\n    In [3]: u.select_atoms('resname 58 and prop z < 220')\r\n    Out[3]: <AtomGroup with 201 atoms>\r\n\r\n    In [4]: u.select_atoms('resname 58') - u.select_atoms('resname 58 and prop z < 220')\r\n    Out[4]: <AtomGroup with 99 atoms>"},"comment":{"url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/comments/184913854","html_url":"https://github.com/MDAnalysis/mdanalysis/issues/726#issuecomment-184913854","issue_url":"https://api.github.com/repos/MDAnalysis/mdanalysis/issues/726","id":184913854,"user":{"login":"mnmelo","id":11721337,"avatar_url":"https://avatars.githubusercontent.com/u/11721337?v=3","gravatar_id":"","url":"https://api.github.com/users/mnmelo","html_url":"https://github.com/mnmelo","followers_url":"https://api.github.com/users/mnmelo/followers","following_url":"https://api.github.com/users/mnmelo/following{/other_user}","gists_url":"https://api.github.com/users/mnmelo/gists{/gist_id}","starred_url":"https://api.github.com/users/mnmelo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnmelo/subscriptions","organizations_url":"https://api.github.com/users/mnmelo/orgs","repos_url":"https://api.github.com/users/mnmelo/repos","events_url":"https://api.github.com/users/mnmelo/events{/privacy}","received_events_url":"https://api.github.com/users/mnmelo/received_events","type":"User","site_admin":false},"created_at":"2016-02-16T23:10:54Z","updated_at":"2016-02-16T23:10:54Z","body":"As a workaround while we decide and develop you can use:\n```python\n# to emulate difference = grp1 - grp2\ndifference = grp1.select_atoms(\"not group other\", other=grp2)\n```"}}