Skip to content

Commit

Permalink
Merge pull request #178 from martimunicoy/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
martimunicoy committed May 8, 2023
2 parents 9a5d88c + c0ae464 commit d952ec0
Show file tree
Hide file tree
Showing 9 changed files with 168 additions and 84 deletions.
21 changes: 21 additions & 0 deletions docs/releasehistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ Releases follow the ``major.minor.micro`` scheme recommended by `PEP440 <https:/
* ``micro`` increments represent bugfix releases or improvements in documentation


1.4.4 - Corrections for alchemistry and new charge calculator
-------------------------------------------------------------

This is a micro release of peleffy that contains corrections for alchemistry module. A new charge calculator
called Mulliken is also available.

New features
""""""""""""
- `PR #174 <https://github.com/martimunicoy/peleffy/pull/174>`_: minor fix in the logger to prevent conflicts with external loggers
- `PR #176 <https://github.com/martimunicoy/peleffy/pull/176>`_: new charge calculator called Mulliken
- `PR #177 <https://github.com/martimunicoy/peleffy/pull/177>`_: new method to save alchemical mapping as a PNG file

Bugfixes
""""""""
- `PR #177 <https://github.com/martimunicoy/peleffy/pull/177>`_: bug fixes for alchemical solvent templates and affected tests

Tests added
"""""""""""
- `PR #176 <https://github.com/martimunicoy/peleffy/pull/176>`_: new tests to validate the new charge calculator


1.4.3 - Minor improvements for CLI arguments and ffld_server
------------------------------------------------------------

Expand Down
76 changes: 43 additions & 33 deletions examples/alchemistry/ethylene_to_chlorofom.ipynb

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions peleffy/data/tests/alchemical_ligandParams_0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,47 +85,47 @@
"scale": 0.85
},
"_C6_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_C7_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_C8_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_C9_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"C10_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"C11_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"H12_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H13_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H14_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H15_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H16_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
}
}
Expand Down
48 changes: 24 additions & 24 deletions peleffy/data/tests/alchemical_ligandParams_1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
"scale": 0.755
},
"_C3_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_C4_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_C5_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_O1_": {
"radius": 0.75,
"radius": 1.5,
"scale": 0.425
},
"_O2_": {
"radius": 0.75,
"radius": 1.5,
"scale": 0.425
},
"_H1_": {
Expand All @@ -49,83 +49,83 @@
"scale": 0.85
},
"_H3_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_H4_": {
"radius": 1.25,
"scale": 0.85
},
"_H5_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_H6_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_H7_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_H8_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_H9_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H10_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H11_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"_C6_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_C7_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_C8_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"_C9_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"C10_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"C11_": {
"radius": 0.85,
"radius": 1.7,
"scale": 0.36
},
"H12_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H13_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H14_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H15_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
},
"H16_": {
"radius": 0.6,
"radius": 1.2,
"scale": 0.425
}
}
Expand Down
26 changes: 13 additions & 13 deletions peleffy/data/tests/alchemical_ligandParams_2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,23 @@
"scale": 0.79
},
"_C3_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_C4_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_C5_": {
"radius": 0.0,
"radius": 1.7,
"scale": 0.0
},
"_O1_": {
"radius": 0.0,
"radius": 1.5,
"scale": 0.0
},
"_O2_": {
"radius": 0.0,
"radius": 1.5,
"scale": 0.0
},
"_H1_": {
Expand All @@ -49,39 +49,39 @@
"scale": 0.85
},
"_H3_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_H4_": {
"radius": 1.3,
"scale": 0.85
},
"_H5_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_H6_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_H7_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_H8_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_H9_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H10_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"H11_": {
"radius": 0.0,
"radius": 1.2,
"scale": 0.0
},
"_C6_": {
Expand Down
25 changes: 23 additions & 2 deletions peleffy/topology/alchemistry.py
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,12 @@ def obc_parameters_to_file(self, path, fep_lambda=None,
of the OBC parameters of both molecules, to the path that
is supplied.
Note that OBC radii are never shrinked to 0.0 for exclusive
and non native atoms to avoid problems with the equation
that places this parameter as the denominator of a fraction.
Instead the scale factor is changed according to the
value of the lambda.
Parameters
----------
path : str
Expand Down Expand Up @@ -1071,14 +1077,14 @@ def obc_parameters_to_file(self, path, fep_lambda=None,
for atom_idx, atom in enumerate(self._joint_topology.atoms):
if atom_idx in self._exclusive_atoms:
lambda_value = 1.0 - lambda_set.get_lambda_for_coulomb1()
radius = radii1[(atom_idx, )] * lambda_value
radius = radii1[(atom_idx, )] # Do not change it
scale = scales1[(atom_idx, )] * lambda_value

elif atom_idx in self._non_native_atoms:
for mol2_index, alc_index in self._mol2_to_alc_map.items():
if alc_index == atom_idx:
lambda_value = lambda_set.get_lambda_for_coulomb2()
radius = radii2[(mol2_index, )] * lambda_value
radius = radii2[(mol2_index, )] # Do not change it
scale = scales2[(mol2_index, )] * lambda_value
break
else:
Expand Down Expand Up @@ -1106,6 +1112,21 @@ def obc_parameters_to_file(self, path, fep_lambda=None,

logger.set_level(log_level)

def to_png(self, output_png):
"""
It generates a PNG image representing the resulting alchemical
mapping.
Parameters
----------
output_png : str
Path to the output PNG file to write
"""
import os
from peleffy.utils.toolkits import RDKitToolkitWrapper

self._mapper.to_png(output_png)

def _ipython_display_(self):
"""
It returns a representation of the alchemical mapping.
Expand Down
30 changes: 30 additions & 0 deletions peleffy/topology/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,36 @@ def molecule2(self):
"""
return self._molecule2

def to_png(self, output_png):
"""
It generates a PNG image representing the resulting alchemical
mapping.
Parameters
----------
output_png : str
Path to the output PNG file to write
"""
import os
from peleffy.utils.toolkits import RDKitToolkitWrapper

extension = os.path.splitext(output_png)[1]

if extension != ".png":
raise ValueError("Invalid extension for a PNG file")


rdkit_toolkit = RDKitToolkitWrapper()

mcs_mol = rdkit_toolkit.get_mcs(self.molecule1, self.molecule2,
self._include_hydrogens,
self._TIMEOUT)

image = rdkit_toolkit.draw_mapping(self.molecule1, self.molecule2,
mcs_mol, self._include_hydrogens)

image.save(output_png)

def _ipython_display_(self):
"""
It returns a representation of the mapping.
Expand Down
1 change: 1 addition & 0 deletions peleffy/topology/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,3 +428,4 @@ def impropers(self):
The list of impropers of this Topology object.
"""
return self._impropers

Loading

0 comments on commit d952ec0

Please sign in to comment.