Code Monkey home page Code Monkey logo

mbuild's Introduction

mBuild: a hierarchical, component based molecule builder

Gitter chat CI Anaconda Badge codecov

With just a few lines of mBuild code, you can assemble reusable components into complex molecular systems for molecular dynamics simulations.

  • mBuild is designed to minimize or even eliminate the need to explicitly translate and orient components when building systems: you simply tell it to connect two pieces!
  • mBuild keeps track of the system's topology so you don't have to worry about manually defining bonds when constructing chemically bonded structures from smaller components.

To learn more, get started or contribute, check out our website.

mBuild within the MoSDeF Ecosystem

mBuild within the MoSDeF Ecosystem

The mBuild package is part of the Molecular Simulation Design Framework (MoSDeF) project. Libraries in the MoSDeF ecosystem are designed to provide utilities neccessary to streamline a researcher's simulation workflow. When setting up simulation studies, we also recommend users to follow the TRUE (Transparent, Reproducible, Usable-by-others, and Extensible) standard, which is a set of common practices meant to improve the reproducibility of computational simulation research.

Installation

For full, detailed instructions, refer to the documentation for installation

conda installation quickstart

mBuild is available on conda and can be installed as:

conda install -c conda-forge mbuild

Installing from source

Dependencies of mBuild are listed in the files environment.yml (lightweight environment specification containing minimal dependencies) and environment-dev.yml (comprehensive environment specification including optional and testing packages for developers). The mbuild or mbuild-dev conda environments can be created with

git clone https://github.com/mosdef-hub/mbuild.git
cd mbuild
# for mbuild conda environment
conda env create -f environment.yml
conda activate mbuild

# for mbuild-dev
conda env create -f environment-dev.yml
conda activate mbuild-dev

# install a non-editable version of mbuild
pip install .

Install an editable version from source

Once all dependencies have been installed and the conda environment has been created, the mBuild itself can be installed.

cd mbuild
conda activate mbuild-dev # or mbuild depending on your installation
pip install -e .

Quick Start with Docker

To use mbuild in a jupyter-notebook that runs from a docker container with all the dependencies installed use the following command:

$ docker pull mosdef/mbuild:latest
$ docker run -it --name mbuild -p 8888:8888 mosdef/mbuild:latest su anaconda -s\
      /bin/sh -l -c "jupyter-notebook --no-browser --ip="0.0.0.0" --notebook-dir\
      /home/anaconda/mbuild-notebooks

Alternatively, you can also start a Bourne shell directly:

$ docker run -it --name mbuild mosdef/mbuild:latest

To learn more about using mBuild with docker, please refer to the documentation here.

Tutorials

Interactive tutorials can be found here:

Binder

Components in dashed boxes are drawn by hand using, e.g., Avogadro or generated elsewhere. Each component is wrapped as a simple python class with user defined attachment sites, or ports. That's the "hard" part! Now mBuild can do the rest. Each component further down the hierarchy is, again, a simple python class that describes which piece should connect to which piece.

Ultimately, complex structures can be created with just a line or two of code. Additionally, this approach seamlessly exposes tunable parameters within the hierarchy so you can actually create whole families of structures simply by adjusting a variable:

import mbuild as mb
from mbuild.examples import PMPCLayer

pattern = mb.Random2DPattern(20)  # A random arrangement of 20 pieces on a 2D surface.
pmpc_layer = PMPCLayer(chain_length=20, pattern=pattern, tile_x=3, tile_y=2)

Zwitterionic brushes on beta-cristobalite substrate

Community Recipes

Use case-specific systems can be generated via mBuild recipes. Some users have graciously contributed recipes for particular systems, including:

Citing mBuild

If you use this package, please cite our paper. The BibTeX reference is

@article{Klein2016mBuild,
      author = "Klein, Christoph and Sallai, János and Jones, Trevor J. and Iacovella, Christopher R. and McCabe, Clare and Cummings, Peter T.",
      title = "A Hierarchical, Component Based Approach to Screening Properties of Soft Matter",
      booktitle = "Foundations of Molecular Modeling and Simulation",
      series = "Molecular Modeling and Simulation: Applications and Perspectives",
      year = "2016",
      doi = "http://dx.doi.org/10.1007/978-981-10-1128-3_5"
}

License

Various sub-portions of this library may be independently distributed under different licenses. See those files for their specific terms.

This material is based upon work supported by the National Science Foundation under grants NSF CBET-1028374 and NSF ACI-1047828. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.

mbuild's People

Contributors

ahy3nz avatar argon1999 avatar bc118 avatar bdice avatar calcraven avatar chrisiacovella avatar chrisjonesbsu avatar ctk3b avatar daico007 avatar ftiet avatar guilingfeng avatar jaclark5 avatar jennyfothergill avatar joaander avatar jonestj1 avatar jpotoff avatar justingilmer avatar mattwthompson avatar pre-commit-ci[bot] avatar rmatsum836 avatar rsdefever avatar rwsmith7531 avatar sallai avatar sperka avatar summeraz avatar tcmoore3 avatar umesh-timalsina avatar uppittu11 avatar whitead avatar witteaj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mbuild's Issues

NeighborsXXX wrappers should accept multiple types

It should be possible to say NeighborsExactly([141, 142, 143], 1) which is evaluated as "neighbors exactly one atom of type 141, 142 or 143."

Similarly for NeighborsAtLeast and NeighborsAtMost.

There may also be a cleaner, more natural syntax to express this but some function like these should exist.

Expand CI coverage

Python versions

  • Python 2.7
  • Python 3.3
  • Python 3.4

Platforms

See TravisCI issue.

  • Linux, debian (Travis)
  • OS X, (presumably on Travis)
  • Windows (Appveyor)

Bilayer buliding

Input parameters:
Multiple ways to specify composition

  • Fractions of lipids, e.g.: [(lipid_A, 0.3), (lipid_B, 0.7)]
  • Specify number of lipids and figure out box dimensions

Multiple arrangements

  • random
  • patterned
  • phase separated
  • flag mirror bottom and top layer or not

Orientation and placement of lipids

  • how do we provide the reference atom?
  • could assume that provided lipids are always oriented with head-groups up in the z-direction

Spread of lipids

  • average area per lipid
  • specific areas for different types of lipids

Multiple ways to add solvent

  • height of solvent
  • lipid to solvent ratio
  • height of full box

Performance issues:
Solvation (see #19)

  • benchmark for bottlenecks
  • accelerate our code
  • can we intelligently wrap genbox? (or wait for the python api to come out)

Local energy minimization

  • write to gromacs/hoomd/lammps, run, read coordinates back in

Tagging of residues?

Something we may or may not want to implement is the ability to label a certain compound as a residue. Generally this would be a compound one or two levels below the top level.

For example in a monolayer, the chains could be tagged as individual residues for easier indexing/grouping/slicing later down the road.

Also 'residue' may not be the most appropriate name since it typically refers to portions of proteins but something along those lines...

Translate-to convenience function

Would be nice to be able to supply one atom in a compound as a reference instead of having to first translate to zero and then moving it to where you want it.

Low priority but a nice thing to have.

Patterning on surfaces

Users should be able to attach molecules to surfaces in easily specifiable patterns.

Basic patterns of interest would be:

  1. random
  2. random but with a minimum separation
  3. equally spaced (e.g. hexagonal)

Library ideas

  • A library of elements with ports attached to them. The default would be to have a ports oriented in the most common orientations. E.g. hydrogen with one port, oxygen with two ports in opposite directions, carbon with ports forming a tetrahedron.
  • A library of common organic building blocks with ports attached to them. E.g. methyl, carbonyl, amine etc.

It may make sense to host the library in a separate repo, especially if it begins to grow in size.

Unit tests that need implementing

Most of these came from checking out coveralls

Trajectory

  • load relative to module
  • atoms in range xyz

Masks

  • grid mask 3d
  • disk mask

Solvate

  • solvent box

Atom

  • deepcopy atom with no parent

Compound

  • batch add to compound
  • add duplicated label
  • _remove labels in this part pointing into the hierarchy
  • center of mass - compound
  • wrap

Bond

  • bond with modified kind
  • print bond
  • deepcopy bond as root of deep copy

Polymer

  • polymer with n < 1

Tiled Compound

  • tiled_comp periodic in all 3
  • tiled_comp with modified kind
  • tiled_comp that contains more than one type of sub compounds as well

Solvation

Things to investigate:

  • wrapper around genbox for both the solvate and solvent_box functions
  • look into Cython or equivalent acceleration for functions
  • wrapper around packmol

Wrappers for forcefield parameterization tools

It may not make sense to implement all of these. Will update as I try each of them. Please add any other potentially useful programs to this list (I've ignored programs like pdb2gmx and antechamber since they don't seem to be very generic but if this is of interest we can certainly look into it).

  • CGenFF (CGenFF)
  • PRODRG (GROMOS)
    • sounds like we should be using ATB for GROMOS
  • ATB (GROMOS)
  • MKTOP (OPLS)
    • works for limited cases (gotten stuck in a few infinite loops)
    • doesn't seem to play nicely with CONECT fields
  • Topolgen (OPLS)
    • kinda sorta works but doesn't do atomtyping
  • Topolbuild (AMBER, GAFF, GLYCAM, OPLS-aa, and GROMOS)
    • pretty finicky but need to do some more testing

Moving away from gitflow

The whole gitflow concept seems really nice but in practice it seems a bit more cumbersome than it is useful. It might just be easier to have a single master branch and periodic tags for release?

Once we have a stable core (perhaps now?), I also think it would make sense to move towards only contributing code via pull requests so we get at least one set of extra eyes on it before merging.

@sallai, thoughts?

Documentation

  • Installation instructions
  • High level introductory overview
  • Tutorials
    • Methane: Atoms, Bonds and Compounds and their labeling
    • Ethane: Ports, coordinate transforms and reading from files
    • Monolayer: Complex hierarchies, masks, tiling and writing to files
    • Re-write tutorials as ipython notebooks with WebGL visualization
    • Gallery of cool structures? Perhaps links to examples and nice visualizations of them?
  • Development
    • How to contribute
  • Autodoc API
    • Sphinx setup
    • Proper versioning in docs/setup.py
    • Proper doc strings throughout the code
    • Simple automated re-building and push to latest
    • Cleaner sections for API in sidebar, e.g.: Core data structures (Atom, Bond, Compound), Tools
  • Website: github pages

Bilayer building

Input parameters:

  • Fractions of lipids, e.g.: [(lipid_A, 0.3), (lipid_B, 0.7)]
  • Specify number of lipids and figure out box dimensions
  • Various arrangements
    • random
    • patterned
    • phase separated
  • spacing between layers
    • how do we provide the reference atom?
    • could assume that provided lipids are always oriented with head-groups up in the z-direction
  • area per lipid
  • solvent
    • height of solvent
    • lipid to solvent ratio
    • height of full box
  • flag mirror bottom and top layer or not

Performance issues:

  • solvation
    • benchmark for bottlenecks
    • accelerate our code
    • can we intelligently wrap genbox? (or wait for the python api to come out)
  • local energy minimization
    • write to gromacs/hoomd/lammps, run, read coordinates back in

SMILES string to Compound

Generate a Compound object based on a SMILES string using pybel.

Tricky part appears to be easily installing pybel...

Handle LJ units

There should be a way to handle LJ units (i.e., not 'real' units).

This needs to be added to the load_hoomdxml, save_hoomdxml, save_lammpsdata, and load_lammpsdata functions.

  • load_hoomdxml
    • box, positions
    • velocity, acceleration, mass, charge, diameter, moment of inertia
  • save_hoomdxml
    • box, positions
    • velocity, acceleration, mass, charge, diameter, moment of inertia
  • save_lammpsdata
    • box, positions

Consistent terminology

While documenting it's becoming clear that we're mostly but not 100% consistent with how we refer to certain types of objects. I think we should discuss and rigorously define what we mean by each term here and then write it up as part of the intro in the documentation.

Edit this list as you please:

Atom:

  • Definition: Elementary container class - typically a leaf in the hierarchy.
  • Notes:
    • Also used as "ghost" particles in Ports.
    • Atoms can be added and subtracted using the +/- operators. The result is the addition or subtraction of the Atoms' cartesian coordinates.

Bond:

  • Definition: Connection between two atoms.

Compound:

  • Definition: A building block in the mBuild hierarchy.

Port:

  • Definition: A set of four "ghost" Atoms used to connect parts.
  • Notes:
    • These "ghost" Atoms are contained in the hierarchy but not output in the final structure except for debugging purposes.

Part/Component:

  • Definition: (we've been using this to refer to any of the above objects)
  • Notes:
    • We currently use these terms very interchangeably both in comments and variable names. I think we should choose one and stick with it throughout.

Packaging

  • Sensible setup.py
  • Documentation with Sphinx
    • Proper build on readthedocs.org
  • TravisCI
  • Coveralls
  • PyPI

GAFF/UFF or similar energy minimization

Might be achievable via OpenBabel/pybel.

Alternative are hooking up with HOOMD, OpenMM or LAMMPS built as a library (requires quite a bit of set up on the user's end - might be interesting to see if it's possible to get LAMMPS as a library working with conda...)

Ignored exceptions in OrderedSet implementation in Python 3

It seems like our orderedset implementation might not be fully compatible with Python 3. Running py.test gives a wall of these messages:

Exception ignored in: <bound method OrderedSet.__del__ of OrderedSet()>
Traceback (most recent call last):
  File "/Users/CTK/science/python-modules/mbuild/mbuild/orderedset.py", line 45, in __del__
  File "/anaconda/envs/mbuild3/lib/python3.4/collections/__init__.py", line 104, in clear
ReferenceError: weakly-referenced object no longer exists

Seems like this is semi-intended behavior but I'm not sure how to fix it yet
http://stackoverflow.com/a/16620987/2597468

Loading a file directly into a trajectory creates an mdtraj topology and not an mbuild topology

For example, this topology is not the subclassed version from mbuild.

    from mbuild.trajectory import Trajectory
    system = Trajectory.load('methyl.pdb')
    >>> dir(system.topology)
['__class__', '__copy__', '__deepcopy__', '__delattr__', '__dict__', '__doc__', '__eq__', '__format__', '__getattribute__', '__hash__', '__init__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_atoms', '_bonds', '_chains', '_numAtoms', '_numResidues', '_residues', '_standardBonds', '_string_summary_basic', 'add_atom', 'add_bond', 'add_chain', 'add_residue', 'atom', 'atoms', 'atoms_by_name', 'bonds', 'chain', 'chains', 'copy', 'create_disulfide_bonds', 'create_standard_bonds', 'from_dataframe', 'from_openmm', 'join', 'n_atoms', 'n_chains', 'n_residues', 'residue', 'residues', 'subset', 'to_bondgraph', 'to_dataframe', 'to_openmm']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.