Skip to content

Commit

Permalink
Merge pull request #48 from martimunicoy/output_names_fix
Browse files Browse the repository at this point in the history
Default output names fix
  • Loading branch information
martimunicoy committed Sep 4, 2020
2 parents e9e26d7 + caa2c4c commit f7d5158
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 32 deletions.
16 changes: 13 additions & 3 deletions docs/releasehistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,18 @@ Releases follow the ``major.minor.micro`` scheme recommended by `PEP440 <https:/
* ``micro`` increments represent bugfix releases or improvements in documentation


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

This is a micro release that includes general bug fixes and stability improvements. It is still a preliminary version of the Open Force Field to PELE package which is under development.

Bugfixes
""""""""
- `PR #48 <https://github.com/martimunicoy/offpele/pull/48>`_: Fixes CLI's default output paths.


0.3.0 - Rotamers, OPLS2005, SMILES and stability improvements
-------------------------------------------------------------

This is a minor release that includes a refactoring of the classes and methods that involve the rotamer library builder. Besides, now it is possible to combine parameters from OPLS2005 and OFF. This release also contains a new method to define a molecule through a SMILES tag. It is still a preliminary version of the Open Force Field to PELE package which is under development.

Expand All @@ -26,7 +36,7 @@ Bugfixes
""""""""
- `PR #22 <https://github.com/martimunicoy/offpele/pull/22>`_: Fixes many bugs. For example, the default output name of the solvent parameters template is changed to `ligandParams.txt`, which is the name that PELE expects.
- `PR #32 <https://github.com/martimunicoy/offpele/pull/32>`_: Minor fixes in ToolkitWrapper classes.
- `PR #34 <https://github.com/martimunicoy/offpele/pull/34:>`_: Improves the translation of dihedrals coming from the Open Force Fielf Toolkit and corrects the lack of exclusions in PELE 1-4 list that result from Impact's dihedral definitions.
- `PR #34 <https://github.com/martimunicoy/offpele/pull/34>`_: Improves the translation of dihedrals coming from the Open Force Fielf Toolkit and corrects the lack of exclusions in PELE 1-4 list that result from Impact's dihedral definitions.
- `PR #46 <https://github.com/martimunicoy/offpele/pull/46>`_: Prevents molecule to be untagged when loading it from a SMILES tag.

Tests added
Expand Down
50 changes: 25 additions & 25 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ PDB file
It is a mandatory positional argument that points to the PDB file which
contains ligand to parameterize.

- Flag: PDB FILE
- Type: string
- Flag: ``PDB FILE``
- Type: ``string``
- Example: the code below will run `offpele` to parameterize the ligand at `path/to/my_ligand.pdb`

.. code-block:: bash
Expand All @@ -116,9 +116,9 @@ Force field
-----------
It defines the Open Force Field force field to employ to parameterize the ligand.

- Flag: -f NAME, --forcefield NAME
- Type: string
- Default: 'openff_unconstrained-1.2.0.offxml'
- Flag: ``-f NAME``, ``--forcefield NAME``
- Type: ``string``
- Default: ``openff_unconstrained-1.2.0.offxml``
- Example: the code below will run offpele using the forcefield named as 'openff_unconstrained-1.0.0.offxml'

.. code-block:: bash
Expand All @@ -129,9 +129,9 @@ Rotamer library resolution
--------------------------
It defines the resolution, in degrees, to use in the rotamer library.

- Flag: -r INT, --resolution INT
- Type: int
- Default: 30
- Flag: ``-r INT``, ``--resolution INT``
- Type: ``int``
- Default: ``30``
- Example: the code below will run offpele using a resolution of 60 for the rotamer library

.. code-block:: bash
Expand All @@ -142,9 +142,9 @@ Output path
-----------
It defines the output path where the resulting files will be saved.

- Flag: -o PATH, --output PATH
- Type: string
- Default: '.', the current working directory
- Flag: ``-o PATH``, ``--output PATH``
- Type: ``string``
- Default: ``.``, the current working directory
- Example: the code below will save the results into my_custom_folder/

.. code-block:: bash
Expand All @@ -155,8 +155,8 @@ Include solvent parameters
--------------------------
It also generates the OBC solvent parameters and saves them into the output location.

- Flag: --with_solvent
- Default: False, not include
- Flag: ``--with_solvent``
- Default: ``False``, do not include
- Example: the code below will generate and save the OBC solvent parameters

.. code-block:: bash
Expand All @@ -167,8 +167,8 @@ Save output as DataLocal
------------------------
It saves the output files following the DataLocal hierarchy expected by PELE.

- Flag: --as_DataLocal
- Default: False, not save output files as DataLocal
- Flag: ``--as_DataLocal``
- Default: ``False``, do not save output files as DataLocal
- Example: the code below will generate and save output files following the DataLocal hierarcy of PELE

.. code-block:: bash
Expand All @@ -179,10 +179,10 @@ Charges method
--------------
It sets the method to compute the partial charges.

- Flag: -c NAME, --charges_method NAME
- Type: string
- Choices: one of ['gasteiger', 'am1bcc', 'OPLS']
- Default: 'am1bcc'
- Flag: ``-c NAME``, ``--charges_method NAME``
- Type: ``string``
- Choices: one of [``gasteiger``, ``am1bcc``, ``OPLS``]
- Default: ``am1bcc``
- Example: the code below will calculate partial charges using 'gasteiger' method

.. code-block:: bash
Expand All @@ -193,8 +193,8 @@ Include terminal rotamers
-------------------------
It always includes terminal rotamers, even if they belong to a terminal methyl group whose rotation is trivial in PELE.

- Flag: --include_terminal_rotamers
- Default: False, exclude terminal rotamers
- Flag: ``--include_terminal_rotamers``
- Default: ``False``, exclude terminal rotamers
- Example: the code below will generate a rotamer library including all terminal rotamers

.. code-block:: bash
Expand All @@ -208,8 +208,8 @@ Parameterize non-bonding terms with OPLS2005

It uses `OPLS2005` to parameterize the non-bonding terms of the ligand. It also assigns the atom types according to this force field.

- Flag: --use_OPLS_nonbonding_param
- Default: False, exclude terminal rotamers
- Flag: ``--use_OPLS_nonbonding_param``
- Default: ``False``, exclude terminal rotamers
- Example: the code below will parameterize the non-bonding terms with OPLS2005

.. code-block:: bash
Expand All @@ -223,8 +223,8 @@ Parameterize bonding and angular terms with OPLS2005

It uses `OPLS2005` to parameterize the bonds and angle terms of the ligand.

- Flag: --use_OPLS_bonds_and_angles
- Default: False, exclude terminal rotamers
- Flag: ``--use_OPLS_bonds_and_angles``
- Default: ``False``, exclude terminal rotamers
- Example: the code below will parameterize the non-bonding, bonding and angular terms with OPLS2005

.. code-block:: bash
Expand Down
6 changes: 3 additions & 3 deletions offpele/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,16 @@ def handle_output_paths(molecule, output, as_datalocal):
The output path for the solvent template
"""
from pathlib import Path
name = molecule.name
tag = molecule.tag
output_path = Path(output)
check_if_path_exists(output_path)

rotlib_path = output_path
impact_path = output_path
solvent_path = output_path

rotlib_name = name.upper() + '.rot.assign'
impact_name = name.lower() + 'z'
rotlib_name = tag.upper() + '.rot.assign'
impact_name = tag.lower() + 'z'
solvent_name = 'ligandParams.txt'

if as_datalocal:
Expand Down
88 changes: 87 additions & 1 deletion offpele/tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

import pytest

import os
import tempfile
from offpele.main import run_offpele
from offpele.main import run_offpele, handle_output_paths
from offpele.utils import get_data_file_path, temporary_cd
from offpele.topology import Molecule


FORCEFIELD_NAME = 'openff_unconstrained-1.2.0.offxml'
Expand All @@ -18,6 +20,9 @@ class TestMain(object):
"""

def test_offpele_default_call(self):
"""
It checks the default call of offpele's main function.
"""
LIGAND_PATH = 'ligands/BNZ.pdb'
ligand_path = get_data_file_path(LIGAND_PATH)

Expand All @@ -26,6 +31,9 @@ def test_offpele_default_call(self):
run_offpele(ligand_path, output=tmpdir)

def test_offpele_custom_call(self):
"""
It checks the custom call of offpele's main function.
"""
LIGAND_PATH = 'ligands/BNZ.pdb'
ligand_path = get_data_file_path(LIGAND_PATH)

Expand All @@ -38,3 +46,81 @@ def test_offpele_custom_call(self):
output=tmpdir,
with_solvent=True,
as_datalocal=True)

def test_default_output_paths(self):
"""
It checks the default output paths that are used for each parameter
file from offpele.
"""

def from_PosixPath_to_string(paths):
"""
Convert PosixPaths to strings
"""
return map(str, paths)

molecule = Molecule(smiles='c1ccccc1', name='benzene', tag='BNZ')

rotlib_path, impact_path, solvent_path = \
handle_output_paths(molecule, '', False)

# Convert PosixPaths to strings
rotlib_path, impact_path, solvent_path = map(
str, [rotlib_path, impact_path, solvent_path])

assert rotlib_path == 'BNZ.rot.assign', 'Unexpected default ' \
+ 'rotamer library path'
assert impact_path == 'bnzz', 'Unexpected default Impact ' \
+ 'template path'
assert solvent_path == 'ligandParams.txt', 'Unexpected default ' \
+ 'solvent parameters path'

with tempfile.TemporaryDirectory() as tmpdir:
with temporary_cd(tmpdir):
# To avoid the complain about unexistent folder
os.mkdir('output')
rotlib_path, impact_path, solvent_path = \
handle_output_paths(molecule, 'output', False)

# Convert PosixPaths to strings
rotlib_path, impact_path, solvent_path = map(
str, [rotlib_path, impact_path, solvent_path])

assert rotlib_path == 'output/BNZ.rot.assign', 'Unexpected default ' \
+ 'rotamer library path'
assert impact_path == 'output/bnzz', 'Unexpected default Impact ' \
+ 'template path'
assert solvent_path == 'output/ligandParams.txt', 'Unexpected ' \
+ 'default solvent parameters path'

rotlib_path, impact_path, solvent_path = \
handle_output_paths(molecule, '', True)

# Convert PosixPaths to strings
rotlib_path, impact_path, solvent_path = map(
str, [rotlib_path, impact_path, solvent_path])

assert rotlib_path == 'DataLocal/LigandRotamerLibs/' \
+ 'BNZ.rot.assign', 'Unexpected default rotamer library path'
assert impact_path == 'DataLocal/Templates/OFF/Parsley/' \
+ 'HeteroAtoms/bnzz', 'Unexpected default Impact template'
assert solvent_path == 'DataLocal/OBC/ligandParams.txt', \
'Unexpected default solvent parameters path'

with tempfile.TemporaryDirectory() as tmpdir:
with temporary_cd(tmpdir):
# To avoid the complain about unexistent folder
os.mkdir('output')
rotlib_path, impact_path, solvent_path = \
handle_output_paths(molecule, 'output', True)

# Convert PosixPaths to strings
rotlib_path, impact_path, solvent_path = map(
str, [rotlib_path, impact_path, solvent_path])

assert rotlib_path == 'output/DataLocal/LigandRotamerLibs/' \
+ 'BNZ.rot.assign', 'Unexpected default rotamer library path'
assert impact_path == 'output/DataLocal/Templates/OFF/Parsley/' \
+ 'HeteroAtoms/bnzz', 'Unexpected default Impact template path'
assert solvent_path == 'output/DataLocal/OBC/ligandParams.txt', \
'Unexpected default solvent parameters path'

0 comments on commit f7d5158

Please sign in to comment.