{ "info": { "author": "Charlie Laughton", "author_email": "charles.laughton@nottingham.ac.uk", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3" ], "description": "# mdio\n\nA Python library to read, write, and manipulate molecular dynamics (MD) trajectory files.\n\n`mdio` is designed to provide basic MD file I/O capabilities. It's not supposed to replace great packages like [mdtraj](www.mdtraj.org) and [mdanalysis](www.mdanalysis.org), but is a lighter weight alternative when all you need is basic MD trajectory file I/O and nothing much more.\n\nFor example, the following script would read in a Gromacs `.xtc` format trajectory file, strip it of water molecules, correct molecule coordinates split up by periodic boundary condition artifacts, least-squares fit each snaphot to the first, and then write out the new coordinates in Amber netcdf (`.nc`) format:\n\n\n```python\nimport mdio\n\ntopfile = '../test/examples/test.gro'\ntrajfile = '../test/examples/test.xtc'\noutfile = 'protein.nc'\n\ntraj = mdio.load(trajfile, top=topfile, selection='not water')\ntraj = traj.make_whole()\ntraj = traj.fitted_to(traj[0])\ntraj.save(outfile)\n```\n\n## Installation\n\nEasiest via `pip`. You need `numpy` and `cython` pre-installed:\n```\n% pip install numpy cython\n% pip install mdio\n```\n\n## User Guide\n\n### Loading data\n\n`mdio` can load data from a variety of file formats: Gromacs (`.xtc` and `.gro`), NAMD/CHARMM (`.dcd`), AMBER (`.nc`, `.mdcrd`, `.rst`), and PDB (`.pdb`). `mdio` auto-detects file formats, so although it may be useful to use the standard file extensions, you don't have to - `mdio` will happily load an AMBER netcdf file that has the extension `.traj` (or even `.xtc`!).\n\n\n```python\nt = mdio.load('../test/examples/test.nc')\nprint(t)\n```\n\n mdio.Trajectory with 10 frames, 892 atoms and box info.\n\n\nAlternative ways of reading files are supported:\n\n\n```python\nf = mdio.open('../test/examples/test.nc', top='../test/examples/test.pdb')\nt2 = f.read()\nf.close()\nprint(t2)\n```\n\n mdio.Trajectory with 10 frames, 892 atoms and box info.\n\n\nOr using a context manager, and in a frame-by-frame way:\n\n\n```python\nwith mdio.open('../test/examples/test.dcd') as f:\n frames = []\n frame = f.read_frame()\n while frame is not None:\n frames.append(frame)\n frame = f.read_frame()\nt3 = mdio.Trajectory(frames)\nprint(t3)\n```\n\n mdio.Trajectory with 10 frames, 892 atoms and box info.\n\n\nYou can create an `mdio` trajectory object from a suitably-shaped numpy array. `mdio` assumes the numbers in the array are in nanometers.\n\n\n```python\nimport numpy as np\nxyz = np.random.random((120, 55, 3))\nt4 = mdio.Trajectory(xyz)\nprint(t4)\n```\n\n mdio.Trajectory with 120 frames, and 55 atoms.\n\n\n### Saving data\n\nTrajectory files can also be written in a variety of ways. The required format is inferred from the filename extension, so unlike for file reading, this must be appropriate.\n\n\n```python\n# a) Using the save() method of a trajectory object:\nt.save('test.nc')\n\n# b) Using mopen():\nwith mdio.open('test2.dcd', \"w\") as f:\n f.write(t)\n\n# c) Frame-by-frame:\nf = mdio.open('test3.xtc', \"w\")\nfor frame in t.frames():\n f.write_frame(frame)\nf.close()\n```\n\n### Manipulating trajectories\n\n#### a) Frame-wise:\n\nTrajectories can be sliced and concatenated/appended (if they are compatible):\n\n\n```python\nt5 = t[2:9:3] + t2\nt5 += t3\nprint(t5)\n```\n\n mdio.Trajectory with 23 frames, 892 atoms and box info.\n\n\n#### b) Atom-wise:\n\nTrajectories with selected subsets of atoms can be created. There are two methods for doing this. One is to specify a list of atom indices:\n\n\n```python\nt6 = t.select([0, 1, 3, 5, 23, 34])\nprint(t6)\n```\n\n mdio.Trajectory with 10 frames, 6 atoms and box info.\n\n\nThe other is to specify a selection string, which uses a syntax very similar to that used by `mdtraj`, see [here](http://mdtraj.org/latest/atom_selection.html):\n\n\n```python\nt7 = t2.select('name CA')\nprint(t7)\n```\n\n mdio.Trajectory with 10 frames, 58 atoms and box info.\n\n\n#### c) Coordinate-wise:\n\nIt is not the purpose of `mdio` to provide a rich variety of trajectory analysis facilities, but a few common functions are implemented. Firstly coordinates can be least-squares fitted to reference structures and the fitting can be weighted:\n\n\n```python\n# a) Simple fit\nt8 = t.fitted_to(t[0])\n\n# b) Mass-weighted fit of t2 to the 6th frame in trajectory t3:\nweights = [atom.element.mass for atom in t2.topology.atoms]\nt9 = t2.fitted_to(t3[5], weights=weights)\n\n# c) Use just residue 1 for the fit:\nweights = np.zeros(t2.n_atoms)\nweights[t2.topology.select('residue 1')] = 1.0\nt10 = t2.fitted_to(t3[5], weights=weights)\n```\n\nSecondly some PBC-related transformations are supported. \n\n* `packed_around()` transforms coordinates so they lie within the unit cell whose centre would be the centre of geometry of the selected atoms. \n* `make_whole()` corrects for molecules split by PBC imaging; this uses bond information generated from analysis of the topology file, so this needs to have 'good' geometry.\n\n\n```python\nt11 = t2.packed_around('residue 3')\nt12 = t11.make_whole()\n```\n\nFinally RMSDs can be calculated:\n\n\n```python\nr2 = t2.rmsd_from(t3[6])\nprint(r2)\n```\n\n [0.09093863981724826, 0.07614511939046421, 0.07949020859896917, 0.07497944478603998, 0.06590847615210413, 0.051843638106744715, 5.960464477539063e-08, 0.07091305468398602, 0.07106069413686344, 0.08153553252567688]\n\n\n### NGLViewer compatibility\n\n`mdio.Trajectory` objects look enough like the ones generated by MDTraj that they can be viewed in Jupyter notebooks with [nglview](https://github.com/arose/nglview) using the `show_mdtraj()` function.\n\n### Author:\n\nCharlie Laughton charles.laughton@nottingham.ac.uk\n\n### License:\n\nBSD 3-clause", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/claughton/mdio", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "mdio", "package_url": "https://pypi.org/project/mdio/", "platform": "", "project_url": "https://pypi.org/project/mdio/", "project_urls": { "Homepage": "https://bitbucket.org/claughton/mdio" }, "release_url": "https://pypi.org/project/mdio/0.2.1/", "requires_dist": null, "requires_python": "", "summary": "Basic I/O for MD trajectory files", "version": "0.2.1" }, "last_serial": 5431327, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "8b481c2c360deb5f6325f1ff43f417de", "sha256": "4518b58979b3b1769668b374ecf8bbe2aab864968c1dccce02f7fbbf588b88c2" }, "downloads": -1, "filename": "mdio-0.0.2.tar.gz", "has_sig": false, "md5_digest": "8b481c2c360deb5f6325f1ff43f417de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 117336, "upload_time": "2019-03-11T15:09:33", "url": "https://files.pythonhosted.org/packages/3a/eb/e0a36607a598955a2f1001ee92488c20cbf5da09060905a42e450dc613ed/mdio-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "b89047f4f63c8be4c38a244b9bbaf35e", "sha256": "caf08fea50eddfb41cec09eebc92c89887682b9d7ce4a7feb6159a87f4121a3b" }, "downloads": -1, "filename": "mdio-0.0.3.tar.gz", "has_sig": false, "md5_digest": "b89047f4f63c8be4c38a244b9bbaf35e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 119030, "upload_time": "2019-03-12T15:38:34", "url": "https://files.pythonhosted.org/packages/a2/b4/9cdadd3be69bde75b96c5a1dc611b0c3f8f13d58b8aa3fa68b8c45ff2af0/mdio-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "a3260769b7aec61b8c0b140bef28a6ea", "sha256": "a234418bdfbb0b6ad63991bbe6e20bea34bd73a4d90f79d2d341e38297427576" }, "downloads": -1, "filename": "mdio-0.0.4.tar.gz", "has_sig": false, "md5_digest": "a3260769b7aec61b8c0b140bef28a6ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 119905, "upload_time": "2019-03-12T16:09:34", "url": "https://files.pythonhosted.org/packages/83/bb/5f633214da3e5e0b8015e8f7d20d1d7ee8b4c66942dc3c0ec6fb378b8ba6/mdio-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "acd8be3a6538ca2c59dc422e5c1b6b87", "sha256": "97f7351d28d8e2c3115a5a1aa371352a239b96b86b9c986c0a73d4361dfe03bd" }, "downloads": -1, "filename": "mdio-0.0.5.tar.gz", "has_sig": false, "md5_digest": "acd8be3a6538ca2c59dc422e5c1b6b87", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 120292, "upload_time": "2019-03-12T20:47:37", "url": "https://files.pythonhosted.org/packages/07/bb/46c7bc3c1176843521084860e195be93714aed29ad14c9d03d998ff685df/mdio-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "49544e2068b6e23f3e387bccfd88a475", "sha256": "10063a95d25d7c384f25aacf27d5d23811303a24dd45ecf9b980df74790b42aa" }, "downloads": -1, "filename": "mdio-0.0.6.tar.gz", "has_sig": false, "md5_digest": "49544e2068b6e23f3e387bccfd88a475", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 124418, "upload_time": "2019-03-26T19:52:15", "url": "https://files.pythonhosted.org/packages/12/c0/77620c95299d8c50b5fa53022c8a2ea3b75819995dfd37c2c60e4db50ea9/mdio-0.0.6.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "566833094a24126ccff99bed9c6d22b5", "sha256": "f0c44a7da7c1224b8e51c553e2ee0904abce7ab24516faebe80d0352414536e3" }, "downloads": -1, "filename": "mdio-0.1.0.tar.gz", "has_sig": false, "md5_digest": "566833094a24126ccff99bed9c6d22b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 130363, "upload_time": "2019-03-27T17:18:42", "url": "https://files.pythonhosted.org/packages/44/5b/128bdf28a591f960dffbd80abdb67458b79c26ac4ec3c501d8148f0c6171/mdio-0.1.0.tar.gz" } ], "0.1.0rc0": [ { "comment_text": "", "digests": { "md5": "98f6a87855c32f70ba5d5ed5e733f4f4", "sha256": "fa859259173b15d566a7c7189219f4069cb3754461f1bd105877e37b62dc4b61" }, "downloads": -1, "filename": "mdio-0.1.0rc0.tar.gz", "has_sig": false, "md5_digest": "98f6a87855c32f70ba5d5ed5e733f4f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 121912, "upload_time": "2019-03-27T12:25:08", "url": "https://files.pythonhosted.org/packages/cb/62/f919c045db0b4da552d7c8d59ba9c3540c090733679b52e974a16100d60a/mdio-0.1.0rc0.tar.gz" } ], "0.1.0rc1": [ { "comment_text": "", "digests": { "md5": "3d5fb25b26cdc70ee2da10df5b6e2eeb", "sha256": "d77e1a3064977b2176e52d22df55501d9c9c50a986b8bc9c53fc893db071a56c" }, "downloads": -1, "filename": "mdio-0.1.0rc1.tar.gz", "has_sig": false, "md5_digest": "3d5fb25b26cdc70ee2da10df5b6e2eeb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 130318, "upload_time": "2019-03-27T14:09:49", "url": "https://files.pythonhosted.org/packages/dd/01/c99d4f0f26619d831536c398f462add1eb5ef653dbf8a1b5c7bc78f92d5a/mdio-0.1.0rc1.tar.gz" } ], "0.1.0rc2": [ { "comment_text": "", "digests": { "md5": "9c8b34584e01661afcd927564c61caac", "sha256": "1c9a590744942d6ab575c451c7a874bae07c41b823ffdeb395ca509c747df6a0" }, "downloads": -1, "filename": "mdio-0.1.0rc2.tar.gz", "has_sig": false, "md5_digest": "9c8b34584e01661afcd927564c61caac", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 130376, "upload_time": "2019-03-27T14:19:51", "url": "https://files.pythonhosted.org/packages/dc/80/ecc7c02dc372d3cc1809002a8078c4dc5a8f06c79c556e4010f3df997701/mdio-0.1.0rc2.tar.gz" } ], "0.1.1rc0": [ { "comment_text": "", "digests": { "md5": "440e8494d7e1d54bfcfc34ad10ca9af4", "sha256": "24894c75b1b0b88b5bc855d01b530a6bab3c778524e7ff3e3cebd080505325be" }, "downloads": -1, "filename": "mdio-0.1.1rc0.tar.gz", "has_sig": false, "md5_digest": "440e8494d7e1d54bfcfc34ad10ca9af4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 134106, "upload_time": "2019-04-05T10:36:24", "url": "https://files.pythonhosted.org/packages/3e/01/7707bc54ee662df1f16ea8f2ed8d8dfcef8d67b0b8b6bc8c30ef78accca7/mdio-0.1.1rc0.tar.gz" } ], "0.1.1rc1": [ { "comment_text": "", "digests": { "md5": "9ea011179ae7a15a0ce925c83fdec3db", "sha256": "30fc62b3de6730d4a8430be500ce595552ba0d0f66263d8bf945ee6aaf1e084a" }, "downloads": -1, "filename": "mdio-0.1.1rc1.tar.gz", "has_sig": false, "md5_digest": "9ea011179ae7a15a0ce925c83fdec3db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 134712, "upload_time": "2019-04-06T12:56:55", "url": "https://files.pythonhosted.org/packages/59/2f/7476f565582c5b9f857fabafc60554292991aec22159a4c632f850fcbe61/mdio-0.1.1rc1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "977357ab06bc4dd555a07d6141082ff5", "sha256": "231051faa62b88e373fc81c97f05adf5be0e17151a4d73d751fc9ced8d281f56" }, "downloads": -1, "filename": "mdio-0.2.0.tar.gz", "has_sig": false, "md5_digest": "977357ab06bc4dd555a07d6141082ff5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 143501, "upload_time": "2019-05-24T07:02:06", "url": "https://files.pythonhosted.org/packages/85/ab/5a7737e4c8fc67d1bcee8d4314bc8d1382aadfc95a60162862a84284109e/mdio-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "90d3fc429eec2069915422505f41007a", "sha256": "cbb596ac31a8ad861aa7ff040229b26342455dc5bb853f2599a149516a897244" }, "downloads": -1, "filename": "mdio-0.2.1.tar.gz", "has_sig": false, "md5_digest": "90d3fc429eec2069915422505f41007a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 488660, "upload_time": "2019-06-21T15:04:10", "url": "https://files.pythonhosted.org/packages/4a/0f/4e9c4e9ba752bfe4e7ff6a57a9a6617d3faaca43a458515856331bd27606/mdio-0.2.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "90d3fc429eec2069915422505f41007a", "sha256": "cbb596ac31a8ad861aa7ff040229b26342455dc5bb853f2599a149516a897244" }, "downloads": -1, "filename": "mdio-0.2.1.tar.gz", "has_sig": false, "md5_digest": "90d3fc429eec2069915422505f41007a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 488660, "upload_time": "2019-06-21T15:04:10", "url": "https://files.pythonhosted.org/packages/4a/0f/4e9c4e9ba752bfe4e7ff6a57a9a6617d3faaca43a458515856331bd27606/mdio-0.2.1.tar.gz" } ] }