anncolvar

Collective variables by artificial neural networks

https://github.com/spiwokv/anncolvar

Science Score: 23.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
  • .zenodo.json file
  • DOI references
    Found 6 DOI reference(s) in README
  • Academic publication links
    Links to: frontiersin.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (8.5%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

Collective variables by artificial neural networks

Basic Info
  • Host: GitHub
  • Owner: spiwokv
  • License: mit
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 1.71 MB
Statistics
  • Stars: 8
  • Watchers: 5
  • Forks: 6
  • Open Issues: 4
  • Releases: 0
Created about 8 years ago · Last pushed over 4 years ago
Metadata Files
Readme License

README.rst

|PyPI| |Anaconda| |BuildStatus| |WeeklyBuildStatus|  |codecov| |lgtm| |lgtmpy|
|DOI| |nest|

Read more in 
D. Trapl, I. Horvaćanin, V. Mareška, F. Özçelik, G. Unal and V. Spiwok: anncolvar: Approximation of Complex Collective Variables by Artificial Neural Networks for Analysis and Biasing of Molecular Simulations  *Front. Mol. Biosci.*  2019, **6**, 25 (doi: 10.3389/fmolb.2019.00025)

*********
anncolvar
*********

News
====

August 2020: Support for Python 2.7 terminated, use Python 3.

Current master vsersion makes it possible to use ANN module of recent master version of Plumed.

Syntax
======

Collective variables by artificial neural networks::

  usage: anncolvar [-h] [-i INFILE] [-p INTOP] [-c COLVAR] [-col COL]
                   [-boxx BOXX] [-boxy BOXY] [-boxz BOXZ] [-nofit NOFIT]
                   [-testset TESTSET] [-shuffle SHUFFLE] [-layers LAYERS]
                   [-layer1 LAYER1] [-layer2 LAYER2] [-layer3 LAYER3]
                   [-actfun1 ACTFUN1] [-actfun2 ACTFUN2] [-actfun3 ACTFUN3]
                   [-optim OPTIM] [-loss LOSS] [-epochs EPOCHS] [-batch BATCH]
                   [-o OFILE] [-model MODELFILE] [-plumed PLUMEDFILE]
                   [-plumed2 PLUMEDFILE2]
  
  Artificial neural network learning of collective variables of molecular
  systems, requires numpy, keras and mdtraj
  
  optional arguments:
    -h, --help           show this help message and exit
    -i INFILE            Input trajectory in pdb, xtc, trr, dcd, netcdf or mdcrd,
                         WARNING: the trajectory must be 1. must contain only atoms
                         to be analyzed, 2. must not contain any periodic boundary
                         condition issues!
    -p INTOP             Input topology in pdb, WARNING: the structure must be 1.
                         centered in the PBC box and 2. must contain only atoms
                         to be analyzed!
    -c COLVAR            Input collective variable file in text format, must
                         contain the same number of lines as frames in the
                         trajectory
    -col COL             The index of the column containing collective variables
                         in the input collective variable file
    -boxx BOXX           Size of x coordinate of PBC box (from 0 to set value in
                         nm)
    -boxy BOXY           Size of y coordinate of PBC box (from 0 to set value in
                         nm)
    -boxz BOXZ           Size of z coordinate of PBC box (from 0 to set value in
                         nm)
    -nofit NOFIT         Disable fitting, the trajectory must be properly fited
                         (default False)
    -testset TESTSET     Size of test set (fraction of the trajectory, default =
                         0.1)
    -shuffle SHUFFLE     Shuffle trajectory frames to obtain training and test
                         set (default True)
    -layers LAYERS       Number of hidden layers (allowed values 1-3, default =
                         1)
    -layer1 LAYER1       Number of neurons in the first encoding layer (default =
                         256)
    -layer2 LAYER2       Number of neurons in the second encoding layer (default
                         = 256)
    -layer3 LAYER3       Number of neurons in the third encoding layer (default =
                         256)
    -actfun1 ACTFUN1     Activation function of the first layer (default =
                         sigmoid, for options see keras documentation)
    -actfun2 ACTFUN2     Activation function of the second layer (default =
                         linear, for options see keras documentation)
    -actfun3 ACTFUN3     Activation function of the third layer (default =
                         linear, for options see keras documentation)
    -optim OPTIM         Optimizer (default = adam, for options see keras
                         documentation)
    -loss LOSS           Loss function (default = mean_squared_error, for options
                         see keras documentation)
    -epochs EPOCHS       Number of epochs (default = 100, >1000 may be necessary
                         for real life applications)
    -batch BATCH         Batch size (0 = no batches, default = 256)
    -o OFILE             Output file with original and approximated collective
                         variables (txt, default = no output)
    -model MODELFILE     Prefix for output model files (experimental, default =
                         no output)
    -plumed PLUMEDFILE   Output file for Plumed (default = plumed.dat)
    -plumed2 PLUMEDFILE2 Output file for Plumed with ANN module (default =
                         plumed2.dat)

Introduction
============

Biased simulations, such as metadynamics, use a predefined set of parameters known
as collective variables. An artificial bias force is applied on collective variables
to enhance sampling. There are two conditions for a parameter to be applied as
a collective variable. First, the value of the collective variables can be calculated
solely from atomic coordinates. Second, the force acting on collective variables
can be converted to the force acting on individual atoms. In the other words, it
is possible to calculate the first derivative of the collective variables with
respect to atomic coordinates. Both calculations must be fast enough, because
they must be evaluated in every step of the simulation.

There are many potential collective variables that cannot be easily calculated.
It is possible to calculate the collective variable for hundreds or thousands of
structures, but not for millions of structures (which is necessary for nanosecond
long simulations). *anncolvar* can approximate such collective variables using
a neural network.

Installation
============

You have to chose and install one of keras backends, such as Tensorflow, Theano or
CNTK. For this follow one of these links:

- TensorFlow_
- Theano_
- CNTK_ (CNTK 2.7 is the last release since 2019)

Install numpy and cython by PIP::

  pip install numpy cython

Next, install anncolvar by PIP::

  pip install anncolvar

If you use Anaconda type::

  conda install -c spiwokv anncolvar

Usage
=====

A series of representative structures (hundreds or more) with pre-calculated values
of the collective variable is used to train the neural network. The user can specify
the input set of reference structures (*-i*) in the form of a trajectory in pdb, xtc,
trr, dcd, netcdf or mdcrd. The trajectory must contain only atoms to be analyzed
(for example only non-hydrogen atoms). The trajectory must not contain any periodic
boundary condition issues. Both conversions can be made by molecular dynamics
simulation packages, for example by *gmx trjconv*. It is not necessary to fit
frames to a reference structure. It is possible to switch fitting off by
*-nofit True*.

It is necessary to supply an input topology in PDB. This is a structure used
as a template for fitting. It is also used to define a box. This box must be large
enough to fit the molecule in all frames of the trajectory. It should not be too
large because this suppresses non-linearity in the neural network. When the user
decides to use a 3x3x3 nm box it is necessary to place the molecule to be centered
at coordinates (1.5,1.5,1.5) nm. In Gromacs it is possible to use::

  gmx editconf -f mol.pdb -o reference.pdb -c -box 3 3 3

It must also contain only atoms to be analyzed. Size of the box can be specified
by parameters *-boxx*, *-boxy* and *-boxz* (in nm).

Last input file is the collective variable file. It is a space-separated text
file with the same number of lines as the number of frames in the input trajectory.
The index of the column can be specified by *-col* (e.g. *-col 2* for the second
column of the file.

The option *-testset* can control the fraction of the trajectory used as
the test set. For example *-testset 0.1* means that 10 % of input data is used
as the test set and 90 % as the training set. The option *-shuffle True* causes
that first 90 % is used as the training set and remaining 10 % as the test set.
Otherwise frames are shuffled before separation to the training and test set.

The architecture of the neural network is controlled by multiple parameters.
The input layer contains 3N neurons (where N is the number of atoms). The number
of hidden layers is controlled by *-layers*. This can be 1, 2 or 3. For higher
number of layers contact the authors. Number of neurons in the first, second and
third layer is controlled by *-layer1*, *-layer2* and *-layer3*. It is useful
to use the number of layers equal to powers of 2 (32, 64, 128 etc.). Huge numbers
of neurons can cause that the program is slow or run out of memory. Activation
functions of neurons can be controlled by *-actfun1*, *-actfun2* and *-actfun3*.
Any activation function supported by keras can be used.

The optimizer used in the training process can be controlled by *-optim*. The
default ADAM optimizer (*-optim adam*) works well. The loss function can be
controlled by *-loss*. The default *-loss mean_squared_error* works well. The
number of epochs can be controlled by *-epochs*. The default value (100) is
quite little, usually >1000 is necessary for real life applications. The batch
size can be controlled by *-batch* (*-batch 0* for no batches, default is 256).

Output is written into the text file *-o*. It contains the approximated and
the original values of collective variable. The model can be stored in the set
of text files (try *-model*). The input file is printed into the file controlled
by *-plumed* (by default plumed.dat). This file can be directly used to calculate
the evolution of the collective variable by *plumed driver* or by Plumed-patched
molecular dynamics engine. To use the collective variable in enhances sampling
(for example metadynamics) it is necessary to add a suitable keyword (for example
METAD).

.. |PyPI| image:: https://img.shields.io/pypi/v/anncolvar.svg
    :target: https://pypi.org/project/anncolvar/
    :alt: Latest version released on PyPI

.. |Anaconda| image:: https://anaconda.org/spiwokv/anncolvar/badges/version.svg
    :target: https://anaconda.org/spiwokv/anncolvar
    :alt: Latest version released on Anaconda Cloud

.. |BuildStatus| image:: https://github.com/spiwokv/anncolvar/actions/workflows/ci.yml/badge.svg
    :target: https://github.com/spiwokv/anncolvar/actions
    :alt: Build status of the master branch on Mac/Linux at Github Actions

.. |WeeklyBuildStatus| image:: https://github.com/spiwokv/anncolvar/actions/workflows/weekly.yml/badge.svg
    :target: https://github.com/spiwokv/anncolvar/actions
    :alt: Weekly Monday 10 AM build status of the master branch on Mac/Linux at Github Actions

.. |codecov| image:: https://codecov.io/gh/spiwokv/anncolvar/branch/master/graph/badge.svg
    :target: https://codecov.io/gh/spiwokv/anncolvar/
    :alt: Code coverage

.. |lgtm| image:: https://img.shields.io/lgtm/alerts/g/spiwokv/anncolvar.svg?logo=lgtm&logoWidth=18
    :target: https://lgtm.com/projects/g/spiwokv/anncolvar/alerts/
    :alt: LGTM code alerts

.. |lgtmpy| image:: https://img.shields.io/lgtm/grade/python/g/spiwokv/anncolvar.svg?logo=lgtm&logoWidth=18
    :target: https://lgtm.com/projects/g/spiwokv/anncolvar/context:python
    :alt: LGTM python quality
    
.. |nest| image:: https://www.plumed-nest.org/eggs/19/008/badge.svg
    :target: https://www.plumed-nest.org/eggs/19/008/
    :alt: Plumed Nest ID: 008 

.. |DOI| image:: https://zenodo.org/badge/DOI/10.3389/fmolb.2019.00025.svg
    :target: https://doi.org/10.3389/fmolb.2019.00025 
    :alt: DOI: 10.3389/fmolb.2019.00025 

.. _TensorFlow: https://www.tensorflow.org/install/

.. _Theano: http://deeplearning.net/software/theano/install.html

.. _CNTK: https://docs.microsoft.com/en-us/cognitive-toolkit/setup-cntk-on-your-machine


Owner

  • Name: Vojtech Spiwok
  • Login: spiwokv
  • Kind: user
  • Location: Prague
  • Company: Institute of Chemical Technology, Prague

GitHub Events

Total
  • Watch event: 2
  • Fork event: 1
Last Year
  • Watch event: 2
  • Fork event: 1

Committers

Last synced: almost 3 years ago

All Time
  • Total Commits: 477
  • Total Committers: 2
  • Avg Commits per committer: 238.5
  • Development Distribution Score (DDS): 0.495
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Vaclav Mareska m****v@c****z 241
Vojtech Spiwok s****v@v****z 236
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: over 2 years ago

All Time
  • Total issues: 4
  • Total pull requests: 6
  • Average time to close issues: about 4 hours
  • Average time to close pull requests: about 2 months
  • Total issue authors: 2
  • Total pull request authors: 4
  • Average comments per issue: 0.75
  • Average comments per pull request: 0.83
  • Merged pull requests: 3
  • Bot issues: 0
  • Bot pull requests: 1
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • spiwokv (3)
  • HanatoK (1)
Pull Request Authors
  • mareskav (3)
  • spiwokv (1)
  • ljocha (1)
  • dependabot[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
dependencies (1)

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 50 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 7
  • Total maintainers: 1
pypi.org: anncolvar

Coding collective variables by artificial neural networks

  • Versions: 7
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 50 Last month
Rankings
Dependent packages count: 10.0%
Forks count: 13.3%
Stargazers count: 18.5%
Downloads: 23.1%
Average: 26.5%
Dependent repos count: 67.6%
Maintainers (1)
Last synced: 11 months ago

Dependencies

requirements.txt pypi
  • Cython >=0.29.24
  • DateTime >=4.3
  • Keras-Applications >=1.0.8
  • Keras-Preprocessing >=1.1.2
  • PyYAML >=5.3.1
  • certifi >=2021.10.8
  • h5py >=3.1.0
  • idna >=3.3
  • keras >=2.6.0
  • mdtraj >=1.9.6
  • numpy >=1.19.5
  • pandas >=0.22
  • pytz >=2021.3
  • scipy >=1.5.4
  • six >=1.15.0
  • tensorflow >=2.6.0
  • urllib3 >=1.26.7
  • zipp >=3.6.0
  • zope.interface >=5.4.0
setup.py pypi
  • argparse *
  • codecov *
  • cython *
  • datetime *
  • keras *
  • mdtraj *
  • numpy *
  • pandas *
  • tensorflow *