Skip to content

Commit

Permalink
Merge pull request #3 from JecaTosovic/RefactoringForBetaAndPort
Browse files Browse the repository at this point in the history
Refactoring for beta and port
  • Loading branch information
JecaTosovic authored Jan 3, 2023
2 parents c1c3124 + 64fd052 commit 946bfbf
Show file tree
Hide file tree
Showing 25 changed files with 1,454 additions and 1,802 deletions.
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/"
schedule:
interval: "monthly"
open-pull-requests-limit: 10
31 changes: 20 additions & 11 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,38 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10"]
python-version: ["3.11"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install package
run: |
pip install -e .
- name: Create Python Environment
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
environment-file: .github/workflows/envs/environment.yml
channels: conda-forge
activate-environment: test
show-channel-urls: true
miniforge-variant: Mambaforge
use-mamba: true
- name: Lint with flake8
run: |
pip install flake8
which python
python -m pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings.
flake8 . --count --exit-zero --max-complexity=20 --max-line-length=100 --statistics
- name: Install package
shell: bash -l {0}
run: |
pip install -e .
- name: Test with pytest
shell: bash -l {0}
run: |
pip install pytest
pytest
python -m pip install pytest
pytest
9 changes: 9 additions & 0 deletions .github/workflows/envs/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: test
channels:
- conda-forge

dependencies:
- pymol-open-source
- pip
- pip:
- -r ../../../requirements.txt
112 changes: 65 additions & 47 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
WaterNetworkAnalysis
==============================
====================
.. image:: https://readthedocs.org/projects/waternetworkanalysis/badge/?version=latest
:target: https://waternetworkanalysis.readthedocs.io/en/latest/?badge=latest
.. image:: https://badge.fury.io/py/WaterNetworkAnalysis.svg
:target: https://badge.fury.io/py/WaterNetworkAnalysis

The WaterNetworkAnalysis (WNA) Python package serves as a set of tools for input preparation for `ConservedWaterSearch <https://github.com/JecaTosovic/ConservedWaterSearch>`_ python package from MD trajectories and their analysis.
Using the ConservedWaterSearch package the conserved water molecules can be further classified into 3 distinct conserved water types based on their hydrogen orientation: Fully Conserved Waters (FCW), Half Conserved Waters (HCW) and Weakly conserved waters (WCW) - see figure below for examples.
WNA can be used to create PyMol or nglview visualisations of conserved water networks for drug discovery or materials science purposes.

.. image:: figs/WaterTypes.png
The WaterNetworkAnalysis (WNA) Python package serves as a set of tools for input preparation and further analysis for `ConservedWaterSearch <https://github.com/JecaTosovic/ConservedWaterSearch>`_ python package which identifies conserved water molecules from Molecular Dynamics (MD) trajectories.

.. image:: docs/source/figs/Scheme.png
:width: 600

Important links
=================
===============
- `Documentation <https://waternetworkanalysis.readthedocs.io/en/latest/>`_: hosted on Read The Docs
- `GitHub repository <https://github.com/JecaTosovic/WaterNetworkAnalysis>`_: source code/contribute code
- `Issue tracker <https://github.com/JecaTosovic/WaterNetworkAnalysis/issues>`_: Report issues/ request features

Related Tools
=================
- `ConservedWaterSearch <https://github.com/JecaTosovic/ConservedWaterSearch>`_: prepare trajectories and analyse results for/from conservedwatersearch
=============
- `ConservedWaterSearch <https://github.com/JecaTosovic/ConservedWaterSearch>`_: Analysis of conserved waters from simulation trajectories. For docs see `here <https://conservedwatersearch.readthedocs.io/en/latest/>`_.

Citation
===============
Coming soon.
========
For citations and more infromation see `ConservedWaterSearch citation <https://conservedwatersearch.readthedocs.io/en/latest/citing.html>`_.

Installation
===============
============
The easiest ways to install **WaterNetworkAnalysis** is using pip:

.. code:: bash
Expand All @@ -36,49 +35,68 @@ The easiest ways to install **WaterNetworkAnalysis** is using pip:
Conda builds will be available soon.

WNA depends on ConservedWaterSearch (CWS). To utilize full visualisation capabilities of CWS, `pymol <https://pymol.org/2/>`_ should be installed. Easiest way to install pymol is via ``conda``:

.. code:: bash
conda install -c conda-forge pymol-open-source
For more information see `CWS installation guide <https://conservedwatersearch.readthedocs.io/en/latest/installation.html>`_.

Example
===============
=======
The following example shows how to use **WaterNetworkAnalysis** to prepare a MD trajectory and analyse the results for determination of conserved water networks.

.. code:: python
from WaterNetworkAnalysis import WaterNetworkAnalysis as WNA
import os
from WaterNetworkAnalysis import align_trajectory
from WaterNetworkAnalysis import get_center_of_selection
from WaterNetworkAnalysis import get_selection_string_from_resnums
from WaterNetworkAnalysis import extract_waters_from_trajectory
from ConservedWaterSearch.water_clustering import WaterClustering
from ConservedWaterSearch.utils import get_orientations_from_positions
# MD trajectory filename
trajectory="md_pl.xtc"
trajectory="md.xtc"
# topology filename
topology="md_pl.gro"
# ligand name
ligand = 'SLB'
topology="md.gro"
# aligned trajectory filename
alignedtrj = "aligned_trj.xtc"
# aligned snapshot filename
aligned_snap = "aligned.pdb"
# distance to select water molecules around
distance = 15.0
distance = 12.0
# align the trajectory and save the alignment reference configuration
align_trajectory(
trajectory=trajectory,
topology=topology,
align_target_file_name=aligned_snap,
output_trj_file=alignedtrj,
)
# define active site by aminoacid residue numbers
active_site_aminoacids = [10,11,124,127,147,149,150,151,153,154,168,169,17,170,173,187,188,191,197,212,214,49,65,66,67,69,70,72]
analysis=WNA(aminoacids_in_activesite=active_site_aminoacids)
# if trajectory is not aligned align it and extract water molecules inside 15 A around active site
if not os.isfile('aligned_trajectory.xtc'):
analysis.align_trajectory(trajectory, topology,every=10)
analysis.extract_waters_from_trajectory(topologyology=topology, dist=distance)
elif not os.isfile('water_coordinates.dat'):
analysis.extract_waters_from_trajectory(traj='aligned_trajectory.xtc',topologyology=topology, dist=distance)
else:
analysis.load_H2O(fname='water_coordinates.dat')
# If the procedure hasn't started start it, else restart it or if finished load results
if not os.isfile('Clustering_results.dat'):
if not os.isfile('Clustering_results_temp.dat'):
analysis.cluster()
else:
analysis.restart_cluster()
else:
analysis.read_results()
# Make results in pdb file
analysis.make_results_pdb("aligned.pdb",ligand,mode="cathegorise")
analysis.make_results_pdb("aligned.pdb",ligand)
# create a PyMol visualisation session
analysis.visualise_pymol()
.. image:: figs/Results.png
:width: 600
active_site_resnums = [111, 112, 113, 122, 133, 138, 139, 142, 143, 157, 166, 167, 169, 170, 203, 231, 232, 238]
# find centre of the active site in aligned trajectory
selection_centre = get_center_of_selection(
get_selection_string_from_resnums(active_site_resnums),
trajectory=alignedtrj,
topology=topology,
)
# extract water coordinates of interest around selection centre
coordO, coordH = extract_waters_from_trajectory(
trajectory=alignedtrj,
topology=topology,
selection_center=selection_centre,
dist=distance
)
# start the clustering procedure
Nsnaps = 200
WC=WaterClustering(nsnaps= Nsnaps)
# perform multi stage reclustering
WC.multi_stage_reclustering(*get_orientations_from_positions(coordO,coordH))
# visualise results with pymol
WC.visualise_pymol(aligned_snap, active_site_ids=active_site_resnums, dist=distance)
.. image:: docs/source/figs/Results.png
:width: 600
Loading

0 comments on commit 946bfbf

Please sign in to comment.