Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation development #17

Merged
merged 26 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d502f4e
Add codecov command
martimunicoy Jul 25, 2020
6ff68cd
Minor fix in codecov run
martimunicoy Jul 25, 2020
34244bf
Add installation badges
martimunicoy Jul 26, 2020
40e2907
Install offpele before Sphinx
martimunicoy Jul 26, 2020
66a98c7
Load conda environtment before Sphinx
martimunicoy Jul 26, 2020
6b4ce83
Fix type in master worflow
martimunicoy Jul 26, 2020
56654bb
Create releasehistory.rst
martimunicoy Jul 26, 2020
1505667
Create PULL_REQUEST_TEMPLATE.md
martimunicoy Jul 26, 2020
120206f
Add link to the Open Force Field repo
martimunicoy Jul 27, 2020
53278ce
Add charges module with partial charges calculators
martimunicoy Jul 27, 2020
7636074
Update README.md
martimunicoy Jul 28, 2020
b8555d2
Merge branch 'devel' into multi_pcharges_methods
martimunicoy Jul 28, 2020
206ad61
Use gasteiger charges in test_parameters.py
martimunicoy Jul 28, 2020
b8555fa
Parameterize molecule with the supplied charge method
martimunicoy Jul 28, 2020
1ee45c3
Minor changes
martimunicoy Jul 28, 2020
1f1e228
Remove unused import
martimunicoy Jul 28, 2020
d71f1d5
Add extensions to Sphinx
martimunicoy Jul 31, 2020
a7ec6d4
Add tests for charges
martimunicoy Aug 4, 2020
04a4451
Choose charges method to use through the command-line
martimunicoy Aug 4, 2020
50309eb
Create new module for charge-related methods
martimunicoy Aug 4, 2020
c6565d9
Merge branch 'master' into multi_pcharges_methods
martimunicoy Aug 4, 2020
4cd30fa
Update releasehistory.rst
martimunicoy Aug 4, 2020
b937f0b
Update releasehistory.rst
martimunicoy Aug 4, 2020
4a362c6
Update releasehistory.rst
martimunicoy Aug 4, 2020
49a71be
Merge branch 'multi_pcharges_methods' into docs
martimunicoy Aug 4, 2020
62f44bd
Add installation and charge methods to docs
martimunicoy Aug 4, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- [ ] Tag issue being addressed
- [ ] Add [tests](https://github.com/martimunicoy/offpele/tree/master/offpele/tests)
- [ ] Update docstrings/[documentation](https://github.com/martimunicoy/offpele/tree/master/docs), if applicable
- [ ] Update [changelog](https://github.com/martimunicoy/offpele/blob/master/docs/releasehistory.rst)
10 changes: 8 additions & 2 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,23 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Set up Python 3.7
uses: actions/setup-python@v2
- uses: goanpeca/setup-miniconda@v1
name: Conda setup
with:
python-version: 3.7
activate-environment: standard
environment-file: devtools/envs/standard.yaml
auto-activate-base: false

- name: Install dependencies
shell: bash -l {0}
run: |
python -m pip install --upgrade pip
python -m pip install --no-deps -v .
if [ -f docs/requirements.txt ]; then pip install -r docs/requirements.txt; fi

- name: Build sphinx documentation
shell: bash -l {0}
run: |
cd docs/
make github
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,6 @@ jobs:
pytest -r fE --tb=short --cov=offpele --cov-config=setup.cfg offpele/

- name: Codecov
uses: codecov/codecov-action@v1
shell: bash -l {0}
run: |
codecov --token=${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
| **About** | [![License](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE) [![Python](https://img.shields.io/badge/python-3.6%2C%203.7-blue.svg)](https://martimunicoy.github.io/offpele) [![Release](https://img.shields.io/github/release/martimunicoy/offpele.svg?include_prereleases)](https://github.com/martimunicoy/offpele/releases/) |
| :------ | :------- |
| **Status** | [![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/martimunicoy/offpele.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/martimunicoy/offpele/context:python) [![Test](https://github.com/martimunicoy/offpele/workflows/Test/badge.svg)](https://github.com/martimunicoy/offpele/actions?query=workflow%3ATest) [![codecov](https://codecov.io/gh/martimunicoy/offpele/branch/master/graph/badge.svg)](https://codecov.io/gh/martimunicoy/offpele) |

| **Installation** | [![Conda](https://img.shields.io/conda/v/martimunicoy/offpele.svg)](https://anaconda.org/martimunicoy/offpele) [![PyPI](https://img.shields.io/pypi/v/offpele)](https://pypi.org/project/offpele/) |

# Open Force Field to PELE
The `offpele` (Open Force Field to PELE) is a Python package that builds PELE-compatible force field templates using the Open Force Field toolkit.
The `offpele` (Open Force Field to PELE) is a Python package that builds [PELE](https://pele.bsc.es/pele.wt)-compatible force field templates using the [Open Force Field toolkit](https://github.com/openforcefield/openforcefield).

## Documentation
The documentation for the `offpele` package is available at [GitHub Pages](https://martimunicoy.github.io/offpele).
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
3 changes: 2 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'm2r',
'sphinx.ext.napoleon', 'sphinx.ext.viewcode', ]
'sphinx.ext.napoleon', 'sphinx.ext.viewcode', 'sphinx.ext.todo',
'sphinx.ext.mathjax',]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
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.
36 changes: 36 additions & 0 deletions docs/releasehistory.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Release History
===============

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. It includes some new features and improvements in documentation and unit testing.

New features
""""""""""""
- `PR #15 <https://github.com/martimunicoy/offpele/pull/15>`_: Adds a new method (Antechamber's gasteiger) to calculate partial charges.

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.


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'
22 changes: 16 additions & 6 deletions offpele/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

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/'
Expand Down Expand Up @@ -52,6 +53,9 @@ 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.set_defaults(as_datalocal=False)
parser.set_defaults(with_solvent=False)
Expand Down Expand Up @@ -112,8 +116,9 @@ 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,
output=None, with_solvent=False, as_datalocal=False):
"""
It runs offpele.

Expand All @@ -125,6 +130,9 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
The name of an OpenForceField's forcefield
resolution : float
The resolution in degrees for the rotamer library
charges_method : str
The name of the method to use to compute partial charges. Default
is 'am1bcc'
output : str
Path where output files will be saved
with_solvent : bool
Expand All @@ -141,6 +149,7 @@ def run_offpele(pdb_file, forcefield=DEFAULT_OFF_FORCEFIELD,
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(' - Output path: {}'.format(output))
print(' - Write solvent parameters: {}'.format(with_solvent))
print(' - DataLocal-like output: {}'.format(as_datalocal))
Expand Down Expand Up @@ -177,20 +186,21 @@ 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.output, args.with_solvent,
args.as_datalocal, )


if __name__ == '__main__':
Expand Down
Loading