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
Handy Tool to check the availability of onion site and to extract the title of submitted onion links.

This tool helps is to quickly investigate a huge set of onion sites based by checking its availability which helps to filter out the inactive sites and collect the site title that might helps us to c

Balaji 13 Nov 25, 2022
A simple toolchain for moving Remarkable highlights to Readwise

A simple toolchain for moving Remarkable highlights to Readwise

zach wick 20 Dec 20, 2022
This utility synchronises spelling dictionaries from various tools with each other.

This utility synchronises spelling dictionaries from various tools with each other. This way the words that have been trained on MS Office are also correctly checked in vim or Firefox. And vice versa

Patrice Neff 2 Feb 11, 2022
Finger is a function symbol recognition engine for binary programs

Finger is a function symbol recognition engine for binary programs

332 Jan 01, 2023
Python HTTP Agent Parser

Features Fast Detects OS and Browser. Does not aim to be a full featured agent parser Will not turn into django-httpagentparser ;) Usage import ht

Shekhar 213 Dec 06, 2022
Playing with python imports and inducing those pesky errors.

super-duper-python-imports In this repository we are playing with python imports and inducing those pesky ImportErrors. File Organization project │

James Kelsey 2 Oct 14, 2021
Python type-checker written in Rust

pravda Python type-checker written in Rust Features Fully typed with annotations and checked with mypy, PEP561 compatible Add yours! Installation pip

wemake.services 31 Oct 21, 2022
jsoooooooon derulo - Make sure your 'jason derulo' is featured as the first part of your json data

jsonderulo Make sure your 'jason derulo' is featured as the first part of your json data Install: # python pip install jsonderulo poetry add jsonderul

jesse 3 Sep 13, 2021
This python program will display all SSID usernames and SSID passwords you once connected to your laptop

Windows-Wifi-password-extractor This python program will display all SSID usernames and SSID passwords you once connected to your laptop How to run th

Bhaskar Pal 3 Apr 26, 2022
A Container for the Dependency Injection in Python.

Python Dependency Injection library aiodi is a Container for the Dependency Injection in Python. Installation Use the package manager pip to install a

Denis NA 3 Nov 25, 2022
A python module to validate input.

A python module to validate input.

Matthias 6 Sep 13, 2022
A collection of custom scripts for working with Quake assets.

Custom Quake Tools A collection of custom scripts for working with Quake assets. Features Script to list all BSP files in a Quake mod

Jason Brownlee 3 Jul 05, 2022
Factoral Methods using two different method

Factoral-Methods-using-two-different-method Here, I am finding the factorial of a number by using two different method. The first method is by using f

Sachin Vinayak Dabhade 4 Sep 24, 2021
Color box that provides various colors‘ rgb decimal code.

colorbox Color box that provides various colors‘ rgb decimal code

1 Dec 07, 2021
Display your calendar on the wallpaper.

wallCal Have your calendar appear as the wallpaper. disclaimer Use at your own risk. Don't blame me if you miss a meeting :-) Some parts of the script

7 Jun 14, 2022
A set of Python scripts to surpass human limits in accomplishing simple tasks.

Human benchmark fooler Summary A set of Python scripts with Selenium designed to surpass human limits in accomplishing simple tasks available on https

Bohdan Dudchenko 3 Feb 10, 2022
Two fast AUC calculation implementations for python

fastauc Two fast AUC calculation implementations for python: python-based is approximately 5X faster than the default sklearn.metrics.roc_auc_score()

Vsevolod Kompantsev 26 Dec 11, 2022
A simple, console based nHentai Code Generator

nHentai Code Generator A simple, console based nHentai Code Generator. How to run? Windows Android Windows Make sure you have python and git installed

5 Jun 02, 2022
A meme error handler for python

Pwython OwO what's this? Pwython is project aiming to fill in one of the biggest problems with python, which is that it is slow lacks owoified text. N

SystematicError 23 Jan 15, 2022
A repo for working with and building daos

DAO Mix DAO Mix About How to DAO No Code Tools Getting Started Prerequisites Installation Usage On-Chain Governance Example Off-Chain governance Examp

Brownie Mixes 86 Dec 19, 2022