{"id":15911276,"url":"https://github.com/janjoswig/mdparser","last_synced_at":"2025-04-24T00:42:46.563Z","repository":{"id":166503982,"uuid":"331926592","full_name":"janjoswig/MDParser","owner":"janjoswig","description":"Parsers for Molecular Dynamics related file types","archived":false,"fork":false,"pushed_at":"2025-02-19T11:14:53.000Z","size":345,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T05:11:30.603Z","etag":null,"topics":["gromacs","molecular-dynamics","parsing","python","topology"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janjoswig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-22T11:31:55.000Z","updated_at":"2025-02-19T11:11:26.000Z","dependencies_parsed_at":null,"dependency_job_id":"a1daae7c-4de4-4a21-add2-5c3642e04d36","html_url":"https://github.com/janjoswig/MDParser","commit_stats":null,"previous_names":["janjoswig/MDParser"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janjoswig%2FMDParser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janjoswig%2FMDParser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janjoswig%2FMDParser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janjoswig%2FMDParser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janjoswig","download_url":"https://codeload.github.com/janjoswig/MDParser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250540939,"owners_count":21447426,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gromacs","molecular-dynamics","parsing","python","topology"],"created_at":"2024-10-06T15:40:59.053Z","updated_at":"2025-04-24T00:42:46.544Z","avatar_url":"https://github.com/janjoswig.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Code Coverage](https://raw.githubusercontent.com/janjoswig/MDParser/master/badges/coverage.svg)](https://github.com/janjoswig/MDParser)\n[![Build Status](https://travis-ci.com/janjoswig/MDParser.svg?branch=main)](https://travis-ci.com/janjoswig/MDParser)\n\n# MDParser\n\nThis is a package for Python-parsers to process typical file formats used for Molecular Dynamics simulations. Currently supported modules and highlights:\n\n## Topologies (`mdparser.topology`)\n\n### GROMACS (`GromacsTopologyParser`)\n\nRead GROMACS topology (.top) files and image them as a Python object or vice versa. The structure of the file is essentially captured in a doubly-linked list exposing it for easy manipulation. Common tasks like adding parts to a topology, merging topologies, retrieval of information, or checking the file for consistency can be performed.\n\nHere is an example topology file from the [GROMACS documentation](https://manual.gromacs.org/documentation/current/reference-manual/topologies/topology-file-formats.html):\n\n```bash\n;\n;       Example topology file (topol.top)\n;\n; The force-field files to be included\n#include \"amber99.ff/forcefield.itp\"\n\n[ moleculetype ]\n; name  nrexcl\nUrea         3\n\n[ atoms ]\n   1  C  1  URE      C      1     0.880229  12.01000   ; amber C  type\n   2  O  1  URE      O      2    -0.613359  16.00000   ; amber O  type\n   3  N  1  URE     N1      3    -0.923545  14.01000   ; amber N  type\n   4  H  1  URE    H11      4     0.395055   1.00800   ; amber H  type\n   5  H  1  URE    H12      5     0.395055   1.00800   ; amber H  type\n   6  N  1  URE     N2      6    -0.923545  14.01000   ; amber N  type\n   7  H  1  URE    H21      7     0.395055   1.00800   ; amber H  type\n   8  H  1  URE    H22      8     0.395055   1.00800   ; amber H  type\n\n[ bonds ]\n    1       2\n    1       3\n    1       6\n    3       4\n    3       5\n    6       7\n    6       8\n\n[ dihedrals ]\n;   ai    aj    ak    al funct  definition\n     2     1     3     4   9\n     2     1     3     5   9\n     2     1     6     7   9\n     2     1     6     8   9\n     3     1     6     7   9\n     3     1     6     8   9\n     6     1     3     4   9\n     6     1     3     5   9\n\n[ dihedrals ]\n     3     6     1     2   4\n     1     4     3     5   4\n     1     7     6     8   4\n\n[ position_restraints ]\n; ai   funct    fc\n   1     1     1000    1000    1000 ; Restrain to a point\n   2     1     1000       0    1000 ; Restrain to a line (Y-axis)\n   3     1     1000       0       0 ; Restrain to a plane (Y-Z-plane)\n\n[ dihedral_restraints ]\n; ai   aj    ak    al  type  phi  dphi  fc\n    3    6     1    2     1  180     0  10\n    1    4     3    5     1  180     0  10\n\n; Include TIP3P water topology\n#include \"amber99.ff/tip3p.itp\"\n\n[ system ]\nUrea in Water\n\n[ molecules ]\n;molecule name   nr.\nUrea             1\nSOL              1000\n\n```\n\nThe file can be read for example like this:\n\n```python\nfrom mdparser import tasks, topology\n\n\nparser = topology.GromacsTopologyParser(\n    include_shared=True,                  # Resolve include directives\n    include_blacklist=[\"forcefield.itp\"]  # Leave some includes untouched\n)\n\nwith open(\"topol.top\") as topfile:\n    top = parser.read(topfile)\n\n```\n\nBy default, comments (starting with `\";\"`) are ignored and conditional directives (`#ifdef`/`#ifndef` blocks) are resolved. Each element of the topology file is represented as a node in the `top` object. More specifically, a topology-element is translated into a specific type of node-value:\n\n```python\nfor node in top:\n    print(f\"{node.value!r}\")\n\n```\n```python\nInclude(\"amber99.ff/forcefield.itp\")\nMoleculetypeSection()\nMoleculetypeEntry(molecule='Urea', nrexcl=3)\nAtomsSubsection()\nAtomsEntry(nr=1, type='C', resnr=1, residue='URE', atom='C', cgnr=1, charge=0.880229, mass=12.01, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=2, type='O', resnr=1, residue='URE', atom='O', cgnr=2, charge=-0.613359, mass=16.0, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=3, type='N', resnr=1, residue='URE', atom='N1', cgnr=3, charge=-0.923545, mass=14.01, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=4, type='H', resnr=1, residue='URE', atom='H11', cgnr=4, charge=0.395055, mass=1.008, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=5, type='H', resnr=1, residue='URE', atom='H12', cgnr=5, charge=0.395055, mass=1.008, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=6, type='N', resnr=1, residue='URE', atom='N2', cgnr=6, charge=-0.923545, mass=14.01, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=7, type='H', resnr=1, residue='URE', atom='H21', cgnr=7, charge=0.395055, mass=1.008, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=8, type='H', resnr=1, residue='URE', atom='H22', cgnr=8, charge=0.395055, mass=1.008, typeB=None, chargeB=None, massB=None)\nBondsSubsection()\nBondsEntry(i=1, j=2, funct=None, c=[])\nBondsEntry(i=1, j=3, funct=None, c=[])\nBondsEntry(i=1, j=6, funct=None, c=[])\nBondsEntry(i=3, j=4, funct=None, c=[])\nBondsEntry(i=3, j=5, funct=None, c=[])\nBondsEntry(i=6, j=7, funct=None, c=[])\nBondsEntry(i=6, j=8, funct=None, c=[])\nDihedralsSubsection()\nDihedralsEntry(i=2, j=1, k=3, l=4, funct=9, c=[])\nDihedralsEntry(i=2, j=1, k=3, l=5, funct=9, c=[])\nDihedralsEntry(i=2, j=1, k=6, l=7, funct=9, c=[])\nDihedralsEntry(i=2, j=1, k=6, l=8, funct=9, c=[])\nDihedralsEntry(i=3, j=1, k=6, l=7, funct=9, c=[])\nDihedralsEntry(i=3, j=1, k=6, l=8, funct=9, c=[])\nDihedralsEntry(i=6, j=1, k=3, l=4, funct=9, c=[])\nDihedralsEntry(i=6, j=1, k=3, l=5, funct=9, c=[])\nDihedralsSubsection()\nDihedralsEntry(i=3, j=6, k=1, l=2, funct=4, c=[])\nDihedralsEntry(i=1, j=4, k=3, l=5, funct=4, c=[])\nDihedralsEntry(i=1, j=7, k=6, l=8, funct=4, c=[])\nPositionRestraintsSubsection()\nPositionRestraintsEntry(i=1, funct=1, c=[1000.0, 1000.0, 1000.0])\nPositionRestraintsEntry(i=2, funct=1, c=[1000.0, 0.0, 1000.0])\nPositionRestraintsEntry(i=3, funct=1, c=[1000.0, 0.0, 0.0])\nDihedralRestraintsSubsection()\nDihedralRestraintsEntry(i=3, j=6, k=1, l=2, funct=1, c=[180.0, 0.0, 10.0])\nDihedralRestraintsEntry(i=1, j=4, k=3, l=5, funct=1, c=[180.0, 0.0, 10.0])\nMoleculetypeSection()\nMoleculetypeEntry(molecule='SOL', nrexcl=2)\nAtomsSubsection()\nAtomsEntry(nr=1, type='OW', resnr=1, residue='SOL', atom='OW', cgnr=1, charge=-0.834, mass=16.0, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=2, type='HW', resnr=1, residue='SOL', atom='HW1', cgnr=1, charge=0.417, mass=1.008, typeB=None, chargeB=None, massB=None)\nAtomsEntry(nr=3, type='HW', resnr=1, residue='SOL', atom='HW2', cgnr=1, charge=0.417, mass=1.008, typeB=None, chargeB=None, massB=None)\nSettlesSubsection()\nSettlesEntry(i=1, funct=1, c=[0.09572, 0.15139])\nExclusionsSubsection()\nExclusionsEntry(indices=[1, 2, 3])\nExclusionsEntry(indices=[2, 1, 3])\nExclusionsEntry(indices=[3, 1, 2])\nSystemSection()\nSystemEntry(name='Urea in Water')\nMoleculesSection()\nMoleculesEntry(molecule='Urea', number=1)\nMoleculesEntry(molecule='SOL', number=1000)\n```\n\nThe following figure illustrates, how these topology-elements are stored.\n\n![Topology-elements stored as doubly-linked list](docsrc/figures/doubly_linked_list.png)\n\nNodes can be modified or deleted and new nodes can be inserted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanjoswig%2Fmdparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanjoswig%2Fmdparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanjoswig%2Fmdparser/lists"}