Skip to content

Commit

Permalink
formatting fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DomFijan committed Feb 25, 2024
1 parent 0583561 commit 74f3bad
Show file tree
Hide file tree
Showing 28 changed files with 84,678 additions and 84,681 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ updates:
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
open-pull-requests-limit: 10
2 changes: 1 addition & 1 deletion .github/workflows/envs/environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ channels:

dependencies:
- pip:
- -r ../../../requirements/requirements-test.txt
- -r ../../../requirements/requirements-test.txt
3 changes: 1 addition & 2 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}

2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ repos:
args: [ --fix ]
# Run the formatter.
- id: ruff-format
types_or: [ python, pyi, jupyter ]
types_or: [ python, pyi, jupyter ]
8 changes: 4 additions & 4 deletions ConservedWaterSearch/hydrogen_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ def __hydrogen_orient_plots(
__plotreachability(122, orientations, cc, fig=fig, tit=rtit)


def __plot3Dorients(subplot, labels, orientations, tip) -> Figure:
def __plot3Dorients(subplot, labels: int, orientations: np.ndarray, tip: str) -> Figure:
"""Function for plotting 3D orientations.
For debuging only.
Expand All @@ -946,10 +946,10 @@ def __plot3Dorients(subplot, labels, orientations, tip) -> Figure:
except ModuleNotFoundError:
raise Exception("install matplotlib")

fig: Figure = plt.figure()
if type(labels) == int:
fig = plt.figure()
if isinstance(labels, int):
return fig
ax: Axes = fig.add_subplot(subplot, projection="3d")
ax = fig.add_subplot(subplot, projection="3d")
ax.set_title(tip)
for j in np.unique(labels):
jaba = orientations[labels == j]
Expand Down
2 changes: 1 addition & 1 deletion ConservedWaterSearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def _make_water_objects(water_type, waterO, waterH1, waterH2, output_file):
resi=highest_resi + 1,
elem="O",
chain="W",
state=1
state=1,
)
if tip == "O_clust":
cmd.show("spheres", wname)
Expand Down
22 changes: 11 additions & 11 deletions ConservedWaterSearch/water_clustering.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from __future__ import annotations
from shutil import which
from typing import TYPE_CHECKING

import ConservedWaterSearch

try:
from matplotlib.axes import Axes
Expand All @@ -16,7 +14,7 @@
NGLWidget = None

if TYPE_CHECKING:
from io import TextIOWrapper
pass

import os
import warnings
Expand Down Expand Up @@ -785,7 +783,9 @@ def _scan_clustering_params(
# loop over minsamps- from N(snapshots) to 0.75*N(snapshots)
for i in self.min_samples:
if self.clustering_algorithm == "OPTICS":
clust: OPTICS | HDBSCAN = OPTICS(min_samples=int(i), n_jobs=self.njobs) # type: ignore
clust: OPTICS | HDBSCAN = OPTICS(
min_samples=int(i), n_jobs=self.njobs
) # type: ignore
clust.fit(Odata)
# loop over xi
for j in self.xis:
Expand Down Expand Up @@ -1032,9 +1032,9 @@ def _delete_data(
with some rows deleted.
"""
Odata = np.delete(Odata, elements, 0)
if not (H1 is None):
if H1 is not None:
H1 = np.delete(H1, elements, 0)
if not (H2 is None):
if H2 is not None:
H2 = np.delete(H2, elements, 0)
return Odata, H1, H2

Expand All @@ -1045,15 +1045,15 @@ def _check_cls_alg_and_whichH(self):
):
raise Exception("clustering algorithm must be OPTICS or HDBSCAN")
for i in self.water_types_to_find:
if not (i in ["FCW", "HCW", "WCW", "onlyO"]):
if i not in ["FCW", "HCW", "WCW", "onlyO"]:
raise Exception(
"whichH supports onlyO or any combination of FCW, HCW and WCW"
)
if "onlyO" in self.water_types_to_find and len(self.water_types_to_find) > 1:
raise Exception("onlyO cannot be used with other water types")
if self.clustering_algorithm == "OPTICS":
for i in self.xis:
if type(i) is not float:
if not isinstance(i, float):
raise Exception("xis must contain floats")
if i > 1 or i < 0:
raise Exception("xis should be between 0 and 1")
Expand All @@ -1066,13 +1066,13 @@ def _check_cls_alg_and_whichH(self):
def _check_and_setup_single(self, xis, minsamp):
if minsamp is None:
minsamp = int(self.numbpct_oxygen * self.nsnaps)
elif type(minsamp) is not int:
elif not isinstance(minsamp, int):
raise Exception("minsamp must be an int")
elif minsamp > self.nsnaps or minsamp <= 0:
raise Exception("minsamp must be between 0 and nsnaps")
if xis is None:
xis = 0.05
elif type(xis) is not float:
elif not isinstance(xis, float):
raise Exception("xi must be a float")
elif xis < 0 or xis > 1:
raise Exception("xis should be between 0 and 1")
Expand All @@ -1081,7 +1081,7 @@ def _check_and_setup_single(self, xis, minsamp):
def _check_and_setup_MSRC(self, lower_minsamp_pct, every_minsamp):
if lower_minsamp_pct > 1.0000001 or lower_minsamp_pct < 0:
raise Exception("lower_misamp_pct must be between 0 and 1")
if type(every_minsamp) is not int:
if not isinstance(every_minsamp, int):
raise Exception("every_minsamp must be integer")
if every_minsamp <= 0 or every_minsamp > self.nsnaps:
raise Exception("every_minsamp must be 0<every_minsamp<=nsnaps")
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ only using :code:`conda` or from source. PyMOL is not available via PyPI
already installed in your current ``python`` environment it can be used
with CWS. If not, the free (open-source) version can be installed from
`conda-forge <https://conda-forge.org/>`_ via :code:`conda` (or
:code:`mamba`):
:code:`mamba`):

.. code:: bash
conda install -c conda-forge pymol-open-source
and paid (licensed version) from schrodinger channel (see `here
<https://PyMOL.org/conda/>`_ for more details) via :code:`conda` (or
:code:`mamba`):
:code:`mamba`):

.. code:: bash
Expand All @@ -76,7 +76,7 @@ and paid (licensed version) from schrodinger channel (see `here
Matplotlib is only required for analyzing of clustering and is useful
if default values of clustering parameters need to be fine-tuned (which
should be relatively rarely). You can install it from :code:`pip` or :code:`conda` or
when installing CWS through :code:`pip` by using :code:`pip install ConservedWaterSearch[matplotlib]`.
when installing CWS through :code:`pip` by using :code:`pip install ConservedWaterSearch[matplotlib]`.
Both mpl and nglveiw can be installed when installing CWS by using:

.. code:: bash
Expand Down
2 changes: 0 additions & 2 deletions docs/source/HydrogenOrientationAnalysis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,3 @@ Analysis of hydrogen orientations is used to classify conserved waters into 3 di
:member-order: bysource
:synopsis: Classification of conserved water molecules based on hydrogen orientation.
:members: hydrogen_orientation_analysis, find_fully_conserved_orientations, find_half_conserved_orientations, find_weakly_conserved_orientations


8 changes: 4 additions & 4 deletions docs/source/conservedwaters.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ Types of Conserved Waters in Our Approach
Conserved waters are categorized into three main types based on hydrogen atom orientations:

- **Fully Conserved Water (FCW)**: Both hydrogen atoms exhibit a unique preferred orientation.

- **Half Conserved Water (HCW)**: One hydrogen atom has a unique preferred orientation, while the other hydrogen atom can have multiple orientations. HCWs are further divided into two subtypes:

- **HCW-I**: One hydrogen is strongly oriented toward one acceptor, while the other switches between two different acceptors.
- **HCW-II**: One hydrogen maintains a strong orientation toward a single acceptor, while the other moves in a circle, maintaining an optimal water angle.

- **Weakly Conserved Water (WCW)**: Hydrogen atoms can have several sets of preferred orientations without a single dominant one. WCWs can have different configurations, such as doublets (WCW-I), triplet (WCW-II), or a circular orientation (WCW-III).


Expand All @@ -46,4 +46,4 @@ Furthermore, the flexible orientation criteria for WCW molecules make them prone


.. rubric:: References:
.. bibliography:: references/references.bib
.. bibliography:: references/references.bib
6 changes: 3 additions & 3 deletions docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ Examples
Identification of conserved waters from molecular dynamics trajectories
-----------------------------------------------------------------------

The most freqeunt use case is one where a molecular dynamics (MD) trajectory is analysed for identification of conserved waters.
The most freqeunt use case is one where a molecular dynamics (MD) trajectory is analysed for identification of conserved waters.

Preprocessing of trajectories using WaterNetworkAnalysis
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The first step is to align the trajectory on to the desired snapshot. If this is done by user, one should make sure to save the snapshot onto which the trajectory was aligned to for visualisation of results.

Since clustering procedure does not employ periodic boundary conditions, the simulation box should be centered in such a way that the center of the region within which conserved water molecules are studied is in the centere of the simulation box. Alternatively, users should ensure that the region of interest does not span across periodic images and belongs to a single periodic image and does not cross the periodic boundary.
Since clustering procedure does not employ periodic boundary conditions, the simulation box should be centered in such a way that the center of the region within which conserved water molecules are studied is in the centere of the simulation box. Alternatively, users should ensure that the region of interest does not span across periodic images and belongs to a single periodic image and does not cross the periodic boundary.

Next, water atom coordinates in specific simulation region should be extracted.The arrays containing this data must be set up in specific way. Each atom type in water molecule needs to be represented in a single numpy array or a list (3 in total - one for oxygen and two hydrogen arrays containing three dimensional coordiantes). Each row in each of these arrays has to belong to the same water molecule. Oxygen array should contain xyz coordinates, while hydrogen arrays should contain orientations from central oxygen atom instead. One can convert from an oxygen coordinates array and a hydrogen coordinates array using :py:meth:`ConservedWaterSearch.utils.get_orientations_from_positions`. Hydrogen array should contain hydrogen coordinates of the same water molecule one after another in the same order as in oxygen coordinates array.

We host a seperate package which serves this purpose called `WaterNetworkAnalysis (WNA) <https://github.com/JecaTosovic/WaterNetworkAnalysis>`_. Since WNA uses `MDAnalysis <https://www.mdanalysis.org/>`_ most file types can be read in for analysis. For more information on preprocessing trajectory data, please refer to the `WaterNetworkAnalysis documentation <https://github.com/JecaTosovic/WaterNetworkAnalysis>`_.
We host a seperate package which serves this purpose called `WaterNetworkAnalysis (WNA) <https://github.com/JecaTosovic/WaterNetworkAnalysis>`_. Since WNA uses `MDAnalysis <https://www.mdanalysis.org/>`_ most file types can be read in for analysis. For more information on preprocessing trajectory data, please refer to the `WaterNetworkAnalysis documentation <https://github.com/JecaTosovic/WaterNetworkAnalysis>`_.

Identification of conserved waters using only oxygen data
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Table of Contents
:caption: API

modules

.. toctree::
:maxdepth: 2
:caption: Reference
Expand Down
6 changes: 3 additions & 3 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Installation
============

The default installations from PyPI and conda-forge don't include any of the optional dependencies required for visualization (see below). This is done to avoid potential conflicts with user defined PyMOL installations.
The default installations from PyPI and conda-forge don't include any of the optional dependencies required for visualization (see below). This is done to avoid potential conflicts with user defined PyMOL installations.

Installation via conda
Installation via conda
======================

ConservedWaterSearch is available through `conda-forge <https://conda-forge.org/>`_ using :code:`conda` (or :code:`mamba`) and this is the recommended way to install it:
Expand Down Expand Up @@ -60,7 +60,7 @@ Known Issues
============

:code:`AttributeError: 'super' object has no attribute '_ipython_display_'`
Some versions of Jupyter notebook are incpompatible with ipython (`see here <https://stackoverflow.com/questions/74279848/nglview-installed-but-will-not-import-inside-juypter-notebook-via-anaconda-navig>`_). To resolve install version of :code:`ipywidgets<8` using :code:`conda`:
Some versions of Jupyter notebook are incpompatible with ipython (`see here <https://stackoverflow.com/questions/74279848/nglview-installed-but-will-not-import-inside-juypter-notebook-via-anaconda-navig>`_). To resolve install version of :code:`ipywidgets<8` using :code:`conda`:

.. code:: bash
Expand Down
2 changes: 1 addition & 1 deletion docs/source/references/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,4 @@ @article{Darby2019
pages = {15818-15826},
year = {2019},
doi = {10.1021/jacs.9b06275},
}
}
4 changes: 2 additions & 2 deletions requirements/requirements-RTD.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
sphinxcontrib-bibtex
sphinx_rtd_theme
jupyter_packaging
matplotlib
nglview
scikit-learn>=1.3
sphinx_rtd_theme
sphinxcontrib-bibtex
2 changes: 1 addition & 1 deletion requirements/requirements-debug.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
matplotlib>=3.4
matplotlib>=3.4
2 changes: 1 addition & 1 deletion requirements/requirements-nglview.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nglview>3.0.0
nglview>3.0.0
4 changes: 2 additions & 2 deletions requirements/requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
numpy==1.26.3
matplotlib==3.8.2
nglview==3.1.1
numpy==1.26.3
scikit-learn==1.4.0
nglview==3.1.1
Empty file modified tests/__init__.py
100755 → 100644
Empty file.
2 changes: 1 addition & 1 deletion tests/data/MSR_HDBSCAN.dat
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ FCW 5.500089362997096387e+00 5.562155414724275992e+00 -5.208729348610494636e-01
FCW -4.544625230315505249e+00 -4.453028252254847885e+00 7.498561411074871508e+00 -5.200478314718946393e+00 -4.695359390725722726e+00 8.213496618632802893e+00 -4.113210955539726932e+00 -3.582027089276281107e+00 7.733590553118308009e+00
FCW -5.507157227188521631e+00 -8.418221767198199146e+00 8.527310827415895744e+00 -4.736139251040263787e+00 -8.446700391005077080e+00 7.891134555898079661e+00 -5.367733680580771605e+00 -7.685140550147956162e+00 9.193008209008651122e+00
FCW -6.474455637652772211e+00 -6.519911182381460613e+00 2.585713585893975264e+00 -7.079312235054134206e+00 -5.890779578388698035e+00 2.097510839652681813e+00 -6.087608474587293372e+00 -6.065286049614869057e+00 3.388001103611376408e+00
FCW -2.511673849483608389e+00 -8.464165067307856560e+00 2.502162354527246890e+00 -3.055126910919260474e+00 -7.755860515002319211e+00 2.952676983811879374e+00 -1.537750352487160743e+00 -8.253181568484063035e+00 2.585582886905556155e+00
FCW -2.511673849483608389e+00 -8.464165067307856560e+00 2.502162354527246890e+00 -3.055126910919260474e+00 -7.755860515002319211e+00 2.952676983811879374e+00 -1.537750352487160743e+00 -8.253181568484063035e+00 2.585582886905556155e+00
2 changes: 1 addition & 1 deletion tests/data/MSR_OPTICS.dat
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ FCW 3.472742363725650705e+00 -7.449520282528586890e+00 -7.474351907336426848e+00
FCW 5.500089362997096387e+00 5.562155414724275992e+00 -5.208729348610494636e-01 5.586713315035725991e+00 6.159483923816351236e+00 -1.318177734269059487e+00 5.886181840584908009e+00 6.008163832494724410e+00 2.865978633898879080e-01
FCW 8.513333704286045744e+00 -8.526539267155134993e+00 -7.512774589746430642e+00 9.411342086383843508e+00 -8.751911572494558200e+00 -7.890647941106498031e+00 8.573672087498025007e+00 -7.680481470045918968e+00 -6.983109144902173604e+00
FCW -5.507157227188521631e+00 -8.418221767198199146e+00 8.527310827415895744e+00 -4.736139251040263787e+00 -8.446700391005077080e+00 7.891134555898079661e+00 -5.367733680580771605e+00 -7.685140550147956162e+00 9.193008209008651122e+00
FCW -8.597124299106214451e+00 7.501303535744298756e+00 7.512953505893619877e+00 -9.121378543530241245e+00 8.325649863143603113e+00 7.299387076634076266e+00 -7.829818854495326441e+00 7.741727861970533198e+00 8.107460442799446554e+00
FCW -8.597124299106214451e+00 7.501303535744298756e+00 7.512953505893619877e+00 -9.121378543530241245e+00 8.325649863143603113e+00 7.299387076634076266e+00 -7.829818854495326441e+00 7.741727861970533198e+00 8.107460442799446554e+00
2 changes: 1 addition & 1 deletion tests/data/Single_HDBSCAN.dat
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ FCW 7.518988005655890206e+00 7.498856767571687953e+00 7.448652942034158286e+00 8
FCW -6.474455637652772211e+00 -6.519911182381460613e+00 2.585713585893975264e+00 -7.079312235054134206e+00 -5.890779578388698035e+00 2.097510839652681813e+00 -6.087608474587293372e+00 -6.065286049614869057e+00 3.388001103611376408e+00
FCW -2.512515614829113453e+00 -8.474934359123839300e+00 2.520568620363011991e+00 -3.051511190651422734e+00 -7.765095190212607967e+00 2.974013350758447860e+00 -1.538019914651154174e+00 -8.266635016774934286e+00 2.604052237388647661e+00
FCW -4.544625230315505249e+00 -4.453028252254847885e+00 7.498561411074871508e+00 -5.200478314718946393e+00 -4.695359390725722726e+00 8.213496618632802893e+00 -4.113210955539726932e+00 -3.582027089276281107e+00 7.733590553118308009e+00
FCW -5.507157227188521631e+00 -8.418221767198199146e+00 8.527310827415895744e+00 -4.736139251040263787e+00 -8.446700391005077080e+00 7.891134555898079661e+00 -5.367733680580771605e+00 -7.685140550147956162e+00 9.193008209008651122e+00
FCW -5.507157227188521631e+00 -8.418221767198199146e+00 8.527310827415895744e+00 -4.736139251040263787e+00 -8.446700391005077080e+00 7.891134555898079661e+00 -5.367733680580771605e+00 -7.685140550147956162e+00 9.193008209008651122e+00
2 changes: 1 addition & 1 deletion tests/data/Single_OPTICS.dat
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ FCW 8.513333704286045744e+00 -8.526539267155134993e+00 -7.512774589746430642e+00
FCW 3.472742363725650705e+00 -7.449520282528586890e+00 -7.474351907336426848e+00 3.823028136021713763e+00 -7.013850670273924948e+00 -8.303503200337180701e+00 4.025409863622924078e+00 -7.162793173624140586e+00 -6.691826380866782387e+00
FCW -2.455104904583980119e+00 8.501529758335443887e+00 8.559075260696285881e+00 -2.627923154312342469e+00 9.397656066142600295e+00 8.150306997475253112e+00 -1.581361548065868039e+00 8.523009125551473275e+00 9.044987993318576613e+00
FCW -8.597124299106214451e+00 7.501303535744298756e+00 7.512953505893619877e+00 -9.121378543530241245e+00 8.325649863143603113e+00 7.299387076634076266e+00 -7.829818854495326441e+00 7.741727861970533198e+00 8.107460442799446554e+00
FCW 8.527958041838523684e+00 8.528630034018087613e+00 -8.516263471246558581e+00 8.758354543493849675e+00 8.089051488327120509e+00 -9.384415620465347274e+00 9.356736886611903614e+00 8.868086799988160962e+00 -8.071409865558976549e+00
FCW 8.527958041838523684e+00 8.528630034018087613e+00 -8.516263471246558581e+00 8.758354543493849675e+00 8.089051488327120509e+00 -9.384415620465347274e+00 9.356736886611903614e+00 8.868086799988160962e+00 -8.071409865558976549e+00
Loading

0 comments on commit 74f3bad

Please sign in to comment.