A primitive Python wrapper around the Gromacs tools.

Overview

README: GromacsWrapper

Build Status Code Coverage Documentation Latest release on zenodo (with DOI) PRs Welcome! Anaconda.org package install with conda

A primitive Python wrapper around the Gromacs tools. The library is tested with GROMACS 4.6.5, 2018.x, 2019.x, 2020.x, and 2021.x (and 5.x and 2016.x should also work). It supports Python 2.7 and 3.6--3.9 on Linux and macOS.

GromacsWrapper also provides a small library (cook book) of often-used recipes and helper functions to set up MD simulations.

Documentation is mostly provided through the python doc strings and available at https://gromacswrapper.readthedocs.org for recent releases.

The source code is available in the GromacsWrapper git repository.

Please be aware that this is beta software that most definitely contains bugs. It is your responsibility to ensure that you are running simulations with sensible parameters.

Quick Start

Given a PDB file 1iee.pdb, set up and run a simple simulation (assuming you have all other input files at hand such as the MDP files):

>>> import gromacs
>>> print(gromacs.release)
2018.2
>>> help(gromacs.pdb2gmx)
DESCRIPTION

gmx pdb2gmx reads a .pdb (or .gro) file, reads some database files,
adds hydrogens to the molecules and generates coordinates in GROMACS
...
...
OPTIONS

Options to specify input files:

-f      [<.gro/.g96/...>]  (eiwit.pdb)
          Structure file: gro g96 pdb brk ent esp tpr
...
...
>>> gromacs.pdb2gmx(f="1iee.pdb", o="protein.gro", p="topol.top",
...                 ff="oplsaa", water="tip4p")
>>> gromacs.editconf(f="protein.gro", o="boxed.gro",
...                  bt="dodecahedron", d=1.5, princ=True,
...                  input="Protein")
>>> gromacs.solvate(cp="boxed.gro", cs="tip4p", p="topol.top",
...                 o="solvated.gro")
>>> gromacs.grompp(f="emin.mdp", c="solvated.gro", p="topol.top",
...                o="emin.tpr")
>>> gromacs.mdrun(v=True, deffnm="emin")
>>> gromacs.grompp(f="md.mdp", c="emin.gro", p="topol.top", o="md.tpr")
>>> gromacs.mdrun(v=True, deffnm="md")

License

The GromacsWrapper package is made available under the terms of the GNU Public License v3 (or any higher version at your choice) except as noted below. See the file COPYING for the licensing terms for all modules.

Installation

Releases

The latest version of GromacsWrapper from PyPi can be installed with

pip install GromacsWrapper

or as a bioconda package with conda from the bioconda channel

conda install -c conda-forge -c bioconda gromacswrapper

Development version

The master branch in the GitHub source repository generally contains useful code but nevertheless, things can break in weird and wonderful ways. Please report issues through the Issue Tracker and mention that you used the develop branch.

To use the development code base: checkout the master branch:

git clone https://github.com/Becksteinlab/GromacsWrapper.git
cd GromacsWrapper

and install

python setup.py install

Download and Availability

The GromacsWrapper home page is http://github.com/Becksteinlab/GromacsWrapper. The latest release of the package is being made available from https://github.com/Becksteinlab/GromacsWrapper/releases

You can also clone the GromacsWrapper git repository or fork for your own development:

git clone git://github.com/Becksteinlab/GromacsWrapper.git

Questions

Please ask questions in the Issue Tracker (instead of private email).

Reporting Bugs and Contributing to GromacsWrapper

Please use the Issue Tracker to report bugs, installation problems, and feature requests.

Pull requests for bug fixes and enhancements are very welcome. See http://makeapullrequest.com for a general introduction on how make a pull request and contribute to open source projects.

Building Documentation

Install Sphinx:

pip install sphinx

and compile:

cd GromacsWrapper
python setup.py build_sphinx

Citing

Latest release on zenodo (with DOI)

GromacsWrapper was written by Oliver Beckstein with contributions from many other people. Please see the file AUTHORS for all the names.

If you find this package useful and use it in published work I'd be grateful if it was acknowledged in text as

"... used GromacsWrapper (Oliver Beckstein et al, https://github.com/Becksteinlab/GromacsWrapper doi: 10.5281/zenodo.17901)"

or in the Acknowledgements section.

Thank you.

Comments
  • Load tools automatically

    Load tools automatically

    Proposal for tool loading as in issue #68. Awaiting for opinions or changes proposals.

    Even if almost complete it remains largely untested (eg. extra and groups).

    opened by pslacerda 36
  • Python3

    Python3

    except for two unit tests everything passes. Most changes should be harmless except for the tool registry, could be I broke that. But changing a dict during iteration isn't allowed in python 3 anymore.

    fixes #44

    opened by kain88-de 24
  • How to use GW to process ss.xpm file of secondary structures (ss)?

    How to use GW to process ss.xpm file of secondary structures (ss)?

    Sorry I am new to the GW. I have successfully installed it on PyCharm. What next should I do?

    I tried import GromacsWrapper but got ModuleNotFoundError: No module named 'GromacsWrapper'

    I also tried gromacs.g_hbond(s=TPR, f=XTC, g="hbond.log", hbm="hb.xpm", hbn="hb.ndx") but got NameError: name 'gromacs' is not defined

    I want to import my ss.xpm file, then I can get an numpy array which contains all the ss records of all the residues for all the time frames. For example, ss[32][21] = 'E' means the 33th residue at 22th time frame has beta-sheet structure. Is this doable?

    @orbeckst

    fileformats question 
    opened by lanselibai 21
  • Fixing broken top reader

    Fixing broken top reader

    Fixes #61 @orbeckst

    • Re-enable test cases,
    • Exclusions-related bug,
    • Handling improper overrides in scaling code,
    • Atom naming to match conf.gro file in amber03w tests.
    opened by jandom 17
  • Tries to detect and load GMXRC automatically

    Tries to detect and load GMXRC automatically

    This commit enables to load GMXRC automatically in most common cases. If GMXPRFIX variable is not found in the environmnet, GMXRC is ran in a subprocess and the variables exported by it are set in this environment. I do exactly the same in my weekend toy project pslacerda/gmx. I hope it helps!

    enhancement configuration 
    opened by pslacerda 17
  • Add option to ignore suffix of gmx executables

    Add option to ignore suffix of gmx executables

    In response to my very old issue, this fixes #124.

    This adds an option in the config file called append_suffix. If it is set to 'no', the suffix of the gmx executables (such as "_mpi" or "_d") will be ignored when making the tool names. It's not ideal to not differentiate them, but it can make code much more consistent across computers.

    The largest change here is that in order to properly test this, the config file has to be changed before gromacs is imported. pytest makes all imports relative to the highest package it can find. Therefore, when tests was nested in the gromacs folder, the tests would be imported as gromacs.tests.test_.... This means that the gromacs.__init__.py is run before even running any of the pytest setup functions. By moving the tests folder out of the gromacs package, the config file can be edited before the gromacs.__init__.py is ever called.

    Because of this change, I've tried to refactor all the references to gromacs.tests or gromacs/tests that I could find.

    This PR another item to the travis testing matrix that tests this option. Using two new command line options to pytest, a link to the gmx executable called 'gmx_mpi' is put into the home folder and written in the tools section of the config file; and the config file is written to ignore the suffix of the gmx executables found.

    opened by theavey 15
  • Gromacs 2018 and pytest low-performance custom plugin to control -nt

    Gromacs 2018 and pytest low-performance custom plugin to control -nt

    ~Include Gromacs 2016 in tests (fixes #96)~

    EDIT: We use Gromacs 2018 (see PR #127 and discussion in #130 ). This PR contains experimental pytest plugin to provide the pytest --low-performance flag and code to explicitly set the number of threads for gmx mdrun in the tests.

    tests 
    opened by ianmkenney 13
  • Switch to YAML format for GromacsWrapper configs

    Switch to YAML format for GromacsWrapper configs

    To make it possible to support multiple versions of gromacs installed on a single machine, as well as to make it easier to support custom user environments, we should switch from a INI-style config to a YAML configuration.

    A portion of this config would go a long way in solving #48 and #26. For example, the schema for the tools available from various versions of gromacs could look like:

    versions:
        4.6.5:
            serial:
                base: ""
                names:
                    - grompp
                    - trjconv
                    - g_rms
            mpi:
                base: ""
                names:
                    - mdrun_mpi
    
        5.1.1:
            serial:
                base: "gmx"
                names:
                    - grompp
                    - trjconv
                    - rms
                    - mdrun
            mpi:
                base: "gmx_mpi"
                names:
                    - mdrun
    
    

    We would then probably require specifying which version one plans to use on import. So, one can do:

    import gromacs
    gromacs.listconfig()             # could use interactively to list config keys available
    gromacs.useconfig('4.6.5')  # this will build the classes from the tools found
    
    

    This does not solve the problem where the same name is present multiple times within the same config, such as for mdrun in 5.1.1 above. At present the same class names are built regardless of the version used, so this would result in an exception.

    Unless we build class names with clear namespace differences (such as using the base given in the config), we can't get around this problem. Although possible, having a library that changes its API depending on the config is probably not the best of ideas.

    configuration wontfix 
    opened by dotsdl 12
  • docs incomplete on readthedocs

    docs incomplete on readthedocs

    There are huge gaps in the autogenerated docs on http://gromacswrapper.readthedocs.org. Needs to be read, checked, and fixed.

    Example: missing docs for most building block modules: http://gromacswrapper.readthedocs.org/en/latest/gromacs/building_blocks.html

    documentation 
    opened by orbeckst 12
  • Allow use of Gromacs 5.1.x gmx_mpi command instead of gmx

    Allow use of Gromacs 5.1.x gmx_mpi command instead of gmx

    My IT created a command gmx_mpi to contrast with a simple Gromacs installation. But I can create an UNIX alias (alias gmx=gmx_mpi) to get around the problem !? My Gromacs command seems to work but for GW it not may be sufficient ? So, may be It could be possible to allow GW use internally of Gromacs 5.1.x gmx_mpi command instead of gmx

    configuration 
    opened by frchalaoux 11
  • `sudo pip install` broken

    `sudo pip install` broken

    Dear GromacswRappers,

    I've just installed the GromacsWrapper using pip. Unfortunately, when I try to import any of the available tools, I run into this:

    In [7]: import gromacs

    ImportError Traceback (most recent call last) in () ----> 1 import gromacs

    /usr/local/lib/python2.7/dist-packages/gromacs/init.py in () 184 all = ['config', 'tools', 'cbook', 'fileformats'] 185 --> 186 from . import fileformats 187 188 # Note: analysis not imported by default (requires additional pre-requisites)

    ImportError: cannot import name fileformats

    Hints on how to resolve it are welcome. Thanks

    installation bug 
    opened by bieniekmateusz 10
  • AttributeDict does not support hasattr()

    AttributeDict does not support hasattr()

    AttributeDict does not support hasattr() but it should:

    import gromacs
    
    ad = gromacs.utilities.AttributeDict(a=1, b=2)
    
    assert hasattr(ad, "a")
    assert not hasattr(ad, "x")    # raises AttributeError from KeyError
    

    Using in is a workaround:

    assert "a" in ad
    assert "x" not in ad
    
    bug 
    opened by orbeckst 0
  • Solvate function doesn't support nn and np input

    Solvate function doesn't support nn and np input

    Related to https://github.com/Becksteinlab/MDPOW/pull/174 In gromacs, one can add a specific number of ions by using keywords nn and np. But in gromacs wrapper solvate function, ions only can be added with the keywords concentration. And concentration keywords only works with some specific water models.

    opened by VOD555 0
  • problem with pickle

    problem with pickle

    The problem: .names doubles after interacting with pickle, cPickle and dill.

    How to reproduce (test.txt):

    import gromacs.formats as gmx
    import os
    import pickle
    
    def load_xvg(filepath, failsafe=2):
        xvg_file = gmx.XVG()
        xvg_file.read(filepath)
        return xvg_file
    
    def test_fnc(xvg_file):
        print('names: ', xvg_file.names)
        print('shape: ', xvg_file.array.shape)
        print('names after: ', xvg_file.names)    
        print('shape after: ', xvg_file.array.shape)
        
    xvg_filepath = 'test.txt'
    pickle_filepath = 'test.pkl'
    
    xvg_file = load_xvg(xvg_filepath)
    print('names out: ', xvg_file.names)
    print('shape out: ', xvg_file.array.shape)
    test_fnc(xvg_file)
    
    pickle.dump(xvg_file, open(pickle_filepath, 'wb'))
    xvg_file = pickle.load(open(pickle_filepath, 'rb'))
    print('\n2 out: ', xvg_file.names)
    test_fnc(xvg_file)
    
    os.remove(pickle_filepath)
    

    gives

    names out:  ['Temperature']
    shape out:  (2, 2)
    names:  ['Temperature']
    shape:  (2, 2)
    names after:  ['Temperature']
    shape after:  (2, 2)
    
    2 out:  ['Temperature']
    names:  ['Temperature']
    shape:  (2, 2)
    names after:  ['Temperature', 'Temperature']
    shape after:  (2, 2)
    

    So, something wrong happens on the stage of either dumping or loading. It's also the case for cPickle and dill libs.

    fileformats bug 
    opened by PolyachenkoYA 2
  • edit_mdp() should use the MDP parser

    edit_mdp() should use the MDP parser

    As pointed out in PR #164 , the edit_mdp() function should use the MDP parser.

    This would also reduce extremely cryptic errors such as gmx grompp: -include is not an option, which happens when a custom template MDP file is used with gromacs.setup.MD() but the template does not contain an include = ... line, which edit_mdp() tries to replace but fails. The failed replacement is then interpreted as a commandline option for gromacs.grompp. Although that's pretty hacky/crappy code logic in the https://github.com/Becksteinlab/GromacsWrapper/blob/cda0874a6469238197e1bef2bd51274b5c80f641/gromacs/setup.py#L796 function, writing a better edit_mdp() (which could, for instance, insert variables as opposed to a simple search and replace, or could check if they are legal variables) would help.

    opened by orbeckst 1
  • list of software that uses GromacsWrapper

    list of software that uses GromacsWrapper

    For the paper #147 it would be very beneficial to demonstrate that GromacsWrapper has been used elsewhere, especially in software or work that can be cited.

    Please add to this issue any citation for work that used GromacsWrapper.

    paper 
    opened by orbeckst 7
Releases(release-0.8.2)
  • release-0.8.2(Sep 9, 2021)

  • release-0.8.1(Jul 23, 2021)

    Bug fixes and improved testing

    • see CHANGES for fixes (mostly to make it work under Python 3)
    • tested with Gromacs 2021.1, 2020.6, 2019.1, 2018.6, 4.6.5 (and Gromacs 5 and 2016.x should als work)
    • tested with Python 2.7 and 3.6 – 3.9
    • tested on Linux and macOS (Windows should work but we don't have Gromacs builds for testing)
    • updated style of the online docs
    Source code(tar.gz)
    Source code(zip)
  • release-0.8.0(Apr 30, 2019)

    Major release of GromacsWrapper (see CHANGES for details).

    Highlights:

    • tested with Gromacs 2019.1, 2018.4, 4.6.5 (and Gromacs 2016.x also works)
    • supported on Python 2.7 and 3.4+ (tested on 2.7 and 3.6/3.7)
    • better handling of _mpi and _d suffixes for Gromacs executables
    • new gromacs.release() command to show the Gromacs version string (such as "4.6.5" or "2019.1")
    • bug fixes
    Source code(tar.gz)
    Source code(zip)
  • release-0.7.0(Aug 9, 2018)

    Major release of GromacsWrapper (see CHANGES for details).

    Highlights:

    • supports Python 2.7.x and Python 3.5+ (Python 3.4 probably also works)
    • supports Gromacs 4.6.x, 5.x, 2016, 2018
    • obsolete code removed (fileformats.itp, fileformats.preprocessor, gromacs.analysis, gromacs.manager, vmd, staging)
    • numkit was moved to its own package https://github.com/Becksteinlab/numkit
    Source code(tar.gz)
    Source code(zip)
  • release-0.6.2(Mar 23, 2017)

    Bug fixes.

    Note that this is the last release that contains the bundled packages vmd (for remote execution of scripts in the vmd server), staging (obsolete), and numkit as well as gromacs.analysis. numkit is now available as a separate package at Becksteinlab/numkit.

    Source code(tar.gz)
    Source code(zip)
  • release-0.6.1(Sep 17, 2016)

  • release-0.6.0(Sep 9, 2016)

    Major release with usability improvements but also backwards-incompatible configuration file changes

    Performance improvements

    • GromacsWrapper does not execute all tools on start up anymore but instead loads documentation lazily. This means that import gromacs is now instantaneous (instead of taking a few seconds)

    Configuration

    • The configuration file (.gromacswrapper.cfg) is not strictly necessary anymore and can be omitted when used with the new automatic tool loading feature.
    • automatic tool loading from the environment (manually source GMXRC and either Gromacs 4 or 5 tools are picked up)
    • automatic tool loading with GMXRC keyword in the Gromacs section of the config file (GromacsWrapper loads the GMXRC file and automatically loads the environment and all tools)
    • Backwards-incompatible change: The Gromacs 5 syntax for tools ("gmx:toolname") is not supported any more in the config file (and an error will be raised). Instead, just provide the driver in the tools keyword, e.g. tools = gmx and all tools are automatically set up).

    For more details see the new docs on configuring GromacsWrapper.

    Source code(tar.gz)
    Source code(zip)
  • release-0.5.1(Jun 29, 2016)

  • release-0.5.0(May 24, 2016)

    • Python 2.7 is required (earlier versions are not supported anymore)
    • Support for Gromacs 5.x is now the default
      • You can use custom driver prefixes such as gmx or gmx_mpi in your gromacswrapper.cfg file to customize the tools that are being made available.
      • Gromacs 4.6.x still works. typically, GromacsWrapper scripts ought to be able to either use Gromacs 4 or Gromacs 5 because a number of compatibility hacks are included that make Gromacs 5 tools also appear under Gromacs 4 names.
    • Removed GridMAT-MD and gridmatmd plugin (no demand and thus no longer supported)
    Source code(tar.gz)
    Source code(zip)
  • release-0.4.0(Dec 16, 2015)

  • release-0.3.3(May 24, 2015)

Owner
Becksteinlab
Computational Biophysics at Arizona State University
Becksteinlab
A tool for testing improper put method vulnerability

Putter-CUP A tool for testing improper put method vulnerability Usage :- python3 put.py -f live-subs.txt Result :- The result in txt file "result.txt"

Zahir Tariq 6 Aug 06, 2021
Entropy-controlled contexts in Python

Python module ordered ordered module is the opposite to random - it maintains order in the program. import random x = 5 def increase(): global x

HyperC 36 Nov 03, 2022
These scripts look for non-printable unicode characters in all text files in a source tree

find-unicode-control These scripts look for non-printable unicode characters in all text files in a source tree. find_unicode_control.py should work w

Siddhesh Poyarekar 25 Aug 30, 2022
Manage your exceptions in Python like a PRO

A linter to manage all your python exceptions and try/except blocks (limited only for those who like dinosaurs).

Guilherme Latrova 353 Dec 31, 2022
A python app which aggregates and splits costs from multiple public cloud providers into a csv

Cloud Billing This project aggregates the costs public cloud resources by accounts, services and tags by importing the invoices from public cloud prov

1 Oct 04, 2022
Michael Vinyard's utilities

Install vintools To download this package from pypi: pip install vintools Install the development package To download and install the developmen

Michael Vinyard 2 May 22, 2022
ColorController is a Pythonic interface for managing colors by english-language name and various color values.

ColorController.py Table of Contents Encode color data in various formats. 1.1: Create a ColorController object using a familiar, english-language col

Tal Zaken 2 Feb 12, 2022
A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt

Kerning A Tool that provides automatic kerning for ligature based OpenType fonts in Microsoft Volt There are three stages of the algorithm. The first

Sayed Zeeshan Asghar 6 Aug 01, 2022
Rabbito is a mini tool to find serialized objects in input values

Rabbito-ObjectFinder Rabbito is a mini tool to find serialized objects in input values What does Rabbito do Rabbito has the main object finding Serial

7 Dec 13, 2021
This is discord nitro code generator and checker made with python. This will generate nitro codes and checks if the code is valid or not. If code is valid then it will print the code leaving 2 lines and if not then it will print '*'.

Discord Nitro Generator And Checker ⚙️ Rᴜɴ Oɴ Rᴇᴘʟɪᴛ 🛠️ Lᴀɴɢᴜᴀɢᴇs Aɴᴅ Tᴏᴏʟs If you are taking code from this repository without a fork, then atleast

Vɪɴᴀʏᴀᴋ Pᴀɴᴅᴇʏ 37 Jan 07, 2023
Helpful functions for use alongside the rich Python library.

🔧 Rich Tools A python package with helpful functions for use alongside with the rich python library. 󠀠󠀠 The current features are: Convert a Pandas

Avi Perl 14 Oct 14, 2022
A repository containing several general purpose Python scripts to automate daily and common tasks.

General Purpose Scripts Introduction This repository holds a curated list of Python scripts which aim to help us automate daily and common tasks. You

GDSC RCCIIT 46 Dec 25, 2022
The producer-consumer problem implemented with threads in Python

This was developed using a Python virtual environment, I would strongly recommend to do the same if you want to clone this repository. How to run this

Omar Beltran 1 Oct 30, 2021
Regression Metrics Calculation Made easy

Regression Metrics Mean Absolute Error Mean Square Error Root Mean Square Error Root Mean Square Logarithmic Error Root Mean Square Logarithmic Error

Ashish Patel 12 Jan 02, 2023
Python implementation of Gorilla time series compression

Gorilla Time Series Compression This is an implementation (with some adaptations) of the compression algorithm described in section 4.1 (Time series c

Ghiles Meddour 19 Jan 01, 2023
Python utilities for writing cross-version compatible libraries

Python utilities for writing cross-version compatible libraries

Tyler M. Kontra 85 Jun 29, 2022
Brainfuck rollup scaling experiment for fun

Optimistic Brainfuck Ever wanted to run Brainfuck on ethereum? Don't ask, now you can! And at a fraction of the cost, thanks to optimistic rollup tech

Diederik Loerakker 48 Dec 28, 2022
A utility tool to create .env files

A utility tool to create .env files dump-env takes an .env.template file and some optional environmental variables to create a new .env file from thes

wemake.services 89 Dec 08, 2022
NFT-Generator is the best way to generate thousands of NFTs quick and easily with Python.

NFT-Generator is the best way to generate thousands of NFTs quick and easily with Python. Just add your files, set your configuration and run the scri

78 Dec 27, 2022
Simple web index to use bloom filter for Pwned Passwords

pwbloom Simple web index to use bloom filter for Pwned Passwords The index.py runs a simple CGI web service checking passwords with a bloom filter for

Hanno Böck 4 Nov 23, 2021