{"action":"opened","issue":{"url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1027","labels_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1027/labels{/name}","comments_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1027/comments","events_url":"https://api.github.com/repos/mdtraj/mdtraj/issues/1027/events","html_url":"https://github.com/mdtraj/mdtraj/issues/1027","id":128971001,"number":1027,"title":"Merge two trajectories","user":{"login":"cxhernandez","id":5142365,"avatar_url":"https://avatars.githubusercontent.com/u/5142365?v=3","gravatar_id":"","url":"https://api.github.com/users/cxhernandez","html_url":"https://github.com/cxhernandez","followers_url":"https://api.github.com/users/cxhernandez/followers","following_url":"https://api.github.com/users/cxhernandez/following{/other_user}","gists_url":"https://api.github.com/users/cxhernandez/gists{/gist_id}","starred_url":"https://api.github.com/users/cxhernandez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cxhernandez/subscriptions","organizations_url":"https://api.github.com/users/cxhernandez/orgs","repos_url":"https://api.github.com/users/cxhernandez/repos","events_url":"https://api.github.com/users/cxhernandez/events{/privacy}","received_events_url":"https://api.github.com/users/cxhernandez/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mdtraj/mdtraj/labels/question","name":"question","color":"cc317c"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-26T22:58:51Z","updated_at":"2016-01-26T22:58:51Z","closed_at":null,"body":"Would a `merge` function be useful? A possible use case is if I have structures for both a protein and a ligand and then want them to exist in the same `Trajectory` object.\r\n\r\nThis is the code I have so far:\r\n\r\n``` python\r\ndef merge(sys1, sys2):\r\n    xyz = np.hstack((sys1.xyz, sys2.xyz))\r\n    top = sys1.topology.copy()\r\n    top.add_chain()\r\n    for res in sys2.topology.residues:\r\n        top.add_residue(res.name, top.chain(-1), res.resSeq)\r\n    for at in sys2.topology.atoms:\r\n        top.add_atom(at.name, at.element,\r\n                     top.chain(-1).residue(at.residue.index), at.serial)\r\n    for at1, at2 in sys2.topology.bonds:\r\n        top.add_bond(top.chain(-1).atom(at1.index),\r\n                     top.chain(-1).atom(at2.index))\r\n    return md.Trajectory(xyz, top)\r\n```\r\n"}}