Skip to content

Commit

Permalink
Merge pull request #20 from martimunicoy/devel
Browse files Browse the repository at this point in the history
Minor release 0.2.1
  • Loading branch information
martimunicoy committed Aug 6, 2020
2 parents d71f1d5 + 24060d3 commit bd9895e
Show file tree
Hide file tree
Showing 16 changed files with 659 additions and 62 deletions.
20 changes: 20 additions & 0 deletions docs/charge.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. _charge ::

Charge methods
==============

This module provides different methods to calculate partial charges
for PELE.

.. currentmodule:: offpele.charge

Primary objects
---------------

.. autosummary::
:nosignatures:
:toctree: api/autogenerated
:template: class.rst

Am1bccCalculator
GasteigerCalculator
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ User guide
:maxdepth: 1

installation
releasehistory


API documentation
Expand All @@ -24,3 +25,4 @@ API documentation
topology
template
solvent
charge
76 changes: 73 additions & 3 deletions docs/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,81 @@
Installation
************

Installing via PyPI
===================
Installing via `conda`
======================
The more straightforward way to install `offpele` along with the required
dependencies is through the `conda <http://www.continuum.io/blog/conda>`_
package manager.

It can be easily install through PyPI with the following command:
First, you need to install the
`miniconda <http://conda.pydata.org/miniconda.html>`_ distribution, which is
the minimal installation of the Anaconda Python package.

To install the Python 3 version on ``linux`` (on ``bash`` systems):

.. code-block:: bash
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash ./Miniconda3-latest-Linux-x86_64.sh -b -p $HOME/miniconda3
It can also be installed on ``osx`` with:

.. code-block:: bash
$ curl https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O
$ bash ./Miniconda3-latest-MacOSX-x86_64.sh -b -p $HOME/miniconda3
Once installed, the bases environment of `conda` can be loaded with
the following commands:

.. code-block:: bash
$ source ~/miniconda3/etc/profile.d/conda.sh
$ conda activate base
You can also create a custom conda environment to handle offpele:

.. code-block:: bash
$ conda create --name offpele_env
which can be activated and deactivated with the two commands from below:

.. code-block:: bash
$ conda activate offpele_env
$ conda deactivate
To install de dependencies of offpele, the following `conda` channels need
to be added and updated:

.. code-block:: bash
$ conda config --add channels omnia --add channels conda-forge --add channels martimunicoy
$ conda update --all
Finally, you can install the latest stable build of `offpele`

.. code-block:: bash
$ conda install offpele
Installing via `PyPI`
=====================

`offpele` can also be installed through `PyPI <https://pypi.org>`_
with the following command:

.. code-block:: bash
$ pip install offpele
However, with `PyPI` some of the required dependencies of `offpele` are not
installed and have to be installed manually such as:

- Open Force Field Toolkit
- RDKit
- AmberTools

For this reason, the installation through `conda` is recommended.
53 changes: 50 additions & 3 deletions docs/releasehistory.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,51 @@
Release history
###############
Release History
===============

To do
Releases follow the ``major.minor.micro`` scheme recommended by `PEP440 <https://www.python.org/dev/peps/pep-0440/#final-releases>`_, where

* ``major`` increments denote a change that may break API compatibility with previous ``major`` releases
* ``minor`` increments add features but do not break API compatibility
* ``micro`` increments represent bugfix releases or improvements in documentation

0.3.0 - Current development
-------------------------

This is still a preliminary version of the Open Force Field to PELE package.


0.2.1
-----

This is a micro release that includes new features and parameters to configurate the behaviour of the program.
It is designed to be employed to run the first benchmarks of the implementation in PELE.
It also includes many stability improvements and an extended test coverage.

New features
""""""""""""
- `PR #15 <https://github.com/martimunicoy/offpele/pull/15>`_: Adds a new method (Antechamber's gasteiger) to calculate partial charges.
- `PR #19 <https://github.com/martimunicoy/offpele/pull/19>`_: Adds a new option to ignore terminal rotatable bonds of each rotamer's branch.
- `PR #17 <https://github.com/martimunicoy/offpele/pull/17>`_: Adds and updates the documentation. However, it is still not completed.

Bugfixes
""""""""
- `PR #18 <https://github.com/martimunicoy/offpele/pull/18>`_: Fixes some problems with proper and improper constructors.

Tests added
"""""""""""
- `PR #15 <https://github.com/martimunicoy/offpele/pull/15>`_: Adds tests ensuring that the run_offpele call from main and the partial charge calculators work as expected.
- `PR #19 <https://github.com/martimunicoy/offpele/pull/19>`_: Adds tests to validate the construction of the `RotamerLibrary` class and the filtering of terminal rotatable bonds.


0.2.0
-----

This is a preliminary version of the Open Force Field to PELE package.

New features
""""""""""""

A first implementation of the package that allows to:

- Build a rotamer library for a small molecule using RDKit's API
- Build a template with the Molecular Mechanics' parameters for a small molecule using the Open Force Field Toolkit
- Assign the OBC implicit solvent parameters to a small molecule using the Open Force Field Toolkit
1 change: 1 addition & 0 deletions offpele/charge/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .charges import Am1bccCalculator, GasteigerCalculator
74 changes: 74 additions & 0 deletions offpele/charge/charges.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
This module handles all classes and functions related with partial charge
calculators.
"""


from offpele.utils.toolkits import AmberToolkitWrapper


class _PartialChargesCalculator(object):
"""
Base class for partial charges calculators.
"""

_name = None
_amber_toolkit = AmberToolkitWrapper()

def __init__(self, molecule):
"""
It initiates a PartialChargesCalculator object.
Parameters
----------
molecule : An offpele.topology.Molecule
The partial charges of this Molecule object will be calculated
"""
self._molecule = molecule

@property
def molecule(self):
"""
The offpele's Molecule.
Returns
-------
molecule : an offpele.topology.Molecule
The offpele's Molecule object
"""
return self._molecule

@property
def name(self):
return self._name

def get_partial_charges(self):
"""
It returns the partial charges that correspond to the molecule's
atoms.
Returns
-------
charges : simtk.unit.Quantity
The array of partial charges
"""

return self._amber_toolkit.compute_partial_charges(self.molecule,
method=self.name)


class Am1bccCalculator(_PartialChargesCalculator):
"""
Implementation of the AM1-BCC partial charges calculator (using RDKit).
"""

_name = 'am1bcc'


class GasteigerCalculator(_PartialChargesCalculator):
"""
Implementation of the gasteiger partial charges calculator (using
RDKit).
"""

_name = 'gasteiger'
17 changes: 0 additions & 17 deletions offpele/data/benchmarks/README.md

This file was deleted.

44 changes: 34 additions & 10 deletions offpele/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@

DEFAULT_OFF_FORCEFIELD = 'openff_unconstrained-1.2.0.offxml'
DEFAULT_RESOLUTION = int(30)
DEFAULT_CHARGES_METHOD = 'am1bcc'
IMPACT_TEMPLATE_PATH = 'DataLocal/Templates/OFF/Parsley/HeteroAtoms/'
ROTAMER_LIBRARY_PATH = 'DataLocal/LigandRotamerLibs/'
SOLVENT_TEMPLATE_PATH = 'DataLocal/OBC/'
DEFAULT_TERMINAL_ROT_TO_IGNORE = 1


def parse_args():
Expand Down Expand Up @@ -52,6 +54,13 @@ def parse_args():
parser.add_argument('--as_DataLocal', dest='as_datalocal',
help="Output will be saved following PELE's DataLocal "
+ "hierarchy", action='store_true')
parser.add_argument('-c', '--charges_method', metavar="NAME",
type=str, help="The name of the method to use to "
+ "compute charges", default=DEFAULT_CHARGES_METHOD)
parser.add_argument('-t', '--terminal_rotamers_to_ignore', metavar="INT",
type=str, help="The number of terminal rotamers " +
" to ignore when building the rotamer library",
default=DEFAULT_TERMINAL_ROT_TO_IGNORE)

parser.set_defaults(as_datalocal=False)
parser.set_defaults(with_solvent=False)
Expand Down Expand Up @@ -112,8 +121,10 @@ def handle_output_paths(molecule, output, as_datalocal):


def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
resolution=DEFAULT_RESOLUTION, output=None,
with_solvent=False, as_datalocal=False,):
resolution=DEFAULT_RESOLUTION,
charges_method=DEFAULT_CHARGES_METHOD,
terminal_rotamers_to_ignore=DEFAULT_TERMINAL_ROT_TO_IGNORE,
output=None, with_solvent=False, as_datalocal=False):
"""
It runs offpele.
Expand All @@ -124,7 +135,13 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
forcefield : str
The name of an OpenForceField's forcefield
resolution : float
The resolution in degrees for the rotamer library
The resolution in degrees for the rotamer library. Default is 30
charges_method : str
The name of the method to use to compute partial charges. Default
is 'am1bcc'
terminal_rotamers_to_ignore : int
The number of terminal rotamers to ignore when building the
rotamer library. Default is 1
output : str
Path where output files will be saved
with_solvent : bool
Expand All @@ -135,12 +152,15 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
not
"""
print('-' * 60)
print('Open Force Field parameterizer for PELE v'
print('Open Force Field parameterizer for PELE '
'{}'.format(offpele.__version__))
print('-' * 60)
print(' - PDB to parameterize: {}'.format(pdb_file))
print(' - Force field: {}'.format(forcefield))
print(' - Rotamer library resolution: {}'.format(resolution))
print(' - Charges method: {}'.format(charges_method))
print(' - Terminal rotamers to ignore: {}'.format(
terminal_rotamers_to_ignore))
print(' - Output path: {}'.format(output))
print(' - Write solvent parameters: {}'.format(with_solvent))
print(' - DataLocal-like output: {}'.format(as_datalocal))
Expand All @@ -158,11 +178,13 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
output = os.getcwd()

molecule = Molecule(pdb_file)
molecule.parameterize(forcefield)
molecule.parameterize(forcefield, charges_method=charges_method)

rotlib_out, impact_out, solvent_out = handle_output_paths(molecule, output, as_datalocal)

molecule.build_rotamer_library(resolution=resolution)
molecule.build_rotamer_library(
resolution=resolution,
n_rot_bonds_to_ignore=terminal_rotamers_to_ignore)
molecule.rotamer_library.to_file(rotlib_out)
impact = Impact(molecule)
impact.write(impact_out)
Expand All @@ -177,20 +199,22 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,

def main():
"""
It reads the command-line arguments and calls offpele.
It reads the command-line arguments and runs offpele.
Examples
--------
From the command-line:
>>> python main.py molecule.pdb -f openff_unconstrained-1.1.1.offxml -r 30
-o output_path/ --with_solvent --as_DataLocal
-o output_path/ --with_solvent --as_DataLocal -c gasteiger
"""
args = parse_args()
run_offpele(args.pdb_file, args.forcefield, args.resolution, args.output,
args.with_solvent, args.as_datalocal)
run_offpele(args.pdb_file, args.forcefield, args.resolution,
args.charges_method, args.terminal_rotamers_to_ignore,
args.output, args.with_solvent,
args.as_datalocal)


if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion offpele/solvent/solvent.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class OBC2(_SolventWrapper):
Implementation of the OBC2 solvent.
"""

_ff_file = get_data_file_path('forcefields/GBSA_OBC1-1.0.offxml')
_ff_file = get_data_file_path('forcefields/GBSA_OBC2-1.0.offxml')
_name = 'OBC2'

def __init__(self, molecule):
Expand Down
Loading

0 comments on commit bd9895e

Please sign in to comment.