Giter Club home page Giter Club logo

waternetworkanalysis's People

Contributors

dependabot[bot] avatar domfijan avatar jecatosovic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

waternetworkanalysis's Issues

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'hoh.cif'

Hi,

when I run the script below I receive follwoing error message:

FileNotFoundError: [WindError 2] The system cannot fine the file specified: 'hoh.cif'

This is the script I use:

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="1md_all_skip5_nojump_mol_fit_waters_ordered_whole.xtc"
# topology filename
topology="1md_all_skip5_nojump_mol_fit_waters_ordered_whole.gro"
# aligned trajectory filename
alignedtrj = "1md_all_skip5_nojump_mol_fit_waters_ordered_whole.xtc"
# aligned snapshot filename
aligned_snap = "1md_all_skip5_nojump_mol_fit_waters_ordered_whole.pdb"
# distance to select water molecules around
distance = 2.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_resnums = [293]
# 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 = 2
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)

This is the output:

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
Cell In[3], line 46
     44 WC.multi_stage_reclustering(*get_orientations_from_positions(coordO,coordH))
     45 # visualise results with pymol
---> 46 WC.visualise_pymol(aligned_snap, active_site_ids=active_site_resnums, dist=distance)

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\ConservedWaterSearch\water_clustering.py:1024, in WaterClustering.visualise_pymol(self, aligned_protein, output_file, active_site_ids, crystal_waters, ligand_resname, dist, density_map)
    993 def visualise_pymol(
    994     self,
    995     aligned_protein: str = "aligned.pdb",
   (...)
   1001     density_map: str | None = None,
   1002 ) -> None:
   1003     """Visualise results using `pymol <[https://pymol.org/>`__](https://pymol.org/%3E%60__).
   1004 
   1005     Args:
   (...)
   1022             visualisation session (usually .dx file). Defaults to None.
   1023     """
-> 1024     visualise_pymol(
   1025         self._water_type,
   1026         self._waterO,
   1027         self._waterH1,
   1028         self._waterH2,
   1029         aligned_protein=aligned_protein,
   1030         output_file=output_file,
   1031         active_site_ids=active_site_ids,
   1032         crystal_waters=crystal_waters,
   1033         ligand_resname=ligand_resname,
   1034         dist=dist,
   1035         density_map=density_map,
   1036     )

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\ConservedWaterSearch\utils.py:356, in visualise_pymol(water_type, waterO, waterH1, waterH2, aligned_protein, output_file, active_site_ids, crystal_waters, ligand_resname, dist, density_map)
    354 if active_site_ids is not None:
    355     cmd.center(active_site_center)
--> 356 os.remove("hoh.cif")
    357 # save
    358 cmd.save(output_file)

FileNotFoundError: [WinError 2] The system cannot find the file specified: 'hoh.cif'

AttributeError: 'super' object has no attribute '_ipython_display_' and Jupyter Notebook

Hi,

when I tried to run WaterNetworkAnalysis in a Jupyter Notebook I encountered the error below.

This was descriebed here Exception with ipywidgets 8 - AttributeError: 'super' object has no attribute 'ipython_display' #18.

Just install ipywidgets with

pip install ipywidgets==7.6.0

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[1], line 1
----> 1 from WaterNetworkAnalysis import align_and_extract_waters, get_center_of_selection,get_selection_string_from_resnums
      2 # MD trajectory filename
      3 trajectory="1md_all_skip5_nojump_mol_fit_waters_ordered_whole.xtc"

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\WaterNetworkAnalysis\__init__.py:6
      1 """
      2 WaterNetworkAnalysis
      3 Module for preparation of raw trajectories for analysis of conserved waters for ConservedWaterSearch
      4 """
----> 6 from .WaterNetworkAnalysis import (
      7     align_and_extract_waters,
      8     align_trajectory,
      9     calculate_oxygen_density_map,
     10     extract_waters_from_trajectory,
     11     get_center_of_selection,
     12     get_selection_string_from_resnums,
     13     make_results_pdb_MDA,
     14     read_results_and_make_pdb,
     15 )

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\WaterNetworkAnalysis\WaterNetworkAnalysis.py:10
      7 import MDAnalysis as mda
      8 import numpy as np
---> 10 from ConservedWaterSearch.utils import (
     11     get_orientations_from_positions,
     12     read_results,
     13 )
     16 def get_selection_string_from_resnums(
     17     resids: list[int], selection_type: str = "MDA"
     18 ) -> str:
     19     """Returns selection string for given residue ids.
     20 
     21     Returns the selection command string for different programs based on
   (...)
     38         "PYMOL")
     39     """

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\ConservedWaterSearch\utils.py:6
      3 import os
      4 import platform
----> 6 import nglview as ngl
      7 import numpy as np
      8 from nglview import NGLWidget

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\__init__.py:4
      1 import warnings
      3 # for doc
----> 4 from . import adaptor, datafiles, show, widget
      5 from ._version import get_versions
      6 from .adaptor import *

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\show.py:13
      3 from . import datafiles
      4 from .adaptor import (ASEStructure, ASETrajectory, BiopythonStructure,
      5                       FileStructure, HTMDTrajectory, IODataStructure,
      6                       IOTBXStructure, MDAnalysisTrajectory, MDTrajTrajectory,
   (...)
     11                       RdkitStructure,
     12                       TextStructure)
---> 13 from .widget import NGLWidget
     15 __all__ = [
     16     'demo',
     17     'show_pdbid',
   (...)
     40     'show_biopython',
     41 ]
     44 def show_pdbid(pdbid, **kwargs):

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\widget.py:19
     15 from traitlets import (Bool, CaselessStrEnum, Dict, Instance, Int, Integer,
     16                        List, Unicode, observe, validate)
     17 import traitlets
---> 19 from . import color, interpolate
     20 from .adaptor import Structure, Trajectory
     21 from .component import ComponentViewer

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\color.py:114
    110         else:
    111             raise ValueError(f"{obj} must be either list of list or string")
--> 114 ColormakerRegistry = _ColormakerRegistry()

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\base.py:10, in _singleton.<locals>.getinstance()
      8 def getinstance():
      9     if cls not in instances:
---> 10         instances[cls] = cls()
     11     return instances[cls]

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\color.py:47, in _ColormakerRegistry.__init__(self, *args, **kwargs)
     45 try:
     46     get_ipython() # only display in notebook
---> 47     self._ipython_display_()
     48 except NameError:
     49     pass

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\nglview\color.py:54, in _ColormakerRegistry._ipython_display_(self, **kwargs)
     52 if self._ready:
     53     return
---> 54 super()._ipython_display_(**kwargs)

AttributeError: 'super' object has no attribute '_ipython_display_'

Error running test example

Hello

thanks for sharing this tool. I'm trying to run the example shown using testtopgrams.tpr and testtrjgromacs.xtc.
I've managed to run the notebook but at the last set of instructions I get this error:

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)

WCW1
ExecutiveLoad-Detail: Detected chem_comp CIF (.pdbx_model_Cartn_{x,y,z}ideal)
WCW2
ExecutiveLoad-Detail: Detected chem_comp CIF (.pdbx_model_Cartn
{x,y,z}_ideal)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 7
      5 WC.multi_stage_reclustering(*get_orientations_from_positions(coordO,coordH))
      6 # visualise results with pymol
----> 7 WC.visualise_pymol(aligned_snap, active_site_ids=active_site_resnums, dist=distance)

File ~/opt/miniconda3/envs/WaterNetworkAnalysis/lib/python3.11/site-packages/ConservedWaterSearch/water_clustering.py:1068, in WaterClustering.visualise_pymol(self, aligned_protein, output_file, active_site_ids, crystal_waters, ligand_resname, dist, density_map)
   1037 def visualise_pymol(
   1038     self,
   1039     aligned_protein: str = "aligned.pdb",
   (...)
   1045     density_map: str | None = None,
   1046 ) -> None:
   1047     """Visualise results using `pymol <[https://pymol.org/>`__](https://pymol.org/%3E%60__).
   1048 
   1049     Args:
   (...)
   1066             visualisation session (usually .dx file). Defaults to None.
   1067     """
-> 1068     visualise_pymol(
   1069         self._water_type,
   1070         self._waterO,
   1071         self._waterH1,
   1072         self._waterH2,
   1073         aligned_protein=aligned_protein,
   1074         output_file=output_file,
   1075         active_site_ids=active_site_ids,
   1076         crystal_waters=crystal_waters,
   1077         ligand_resname=ligand_resname,
   1078         dist=dist,
   1079         density_map=density_map,
   1080     )

File ~/opt/miniconda3/envs/WaterNetworkAnalysis/lib/python3.11/site-packages/ConservedWaterSearch/utils.py:352, in visualise_pymol(water_type, waterO, waterH1, waterH2, aligned_protein, output_file, active_site_ids, crystal_waters, ligand_resname, dist, density_map)
    350     os.remove("hoh.cif")
    351 # save
--> 352 cmd.save(output_file)
    353 cmd.reinitialize()

File ~/opt/miniconda3/envs/WaterNetworkAnalysis/lib/python3.11/site-packages/pymol/exporting.py:834, in save(filename, selection, state, format, ref, ref_state, quiet, partial, _self)
    832 # analyze filename
    833 from pymol.importing import filename_to_format, _eval_func
--> 834 _, _, format_guessed, zipped = filename_to_format(filename)
    835 filename = _self.exp_path(filename)
    837 # file format

File ~/opt/miniconda3/envs/WaterNetworkAnalysis/lib/python3.11/site-packages/pymol/importing.py:42, in filename_to_format(filename)
     41 def filename_to_format(filename):
---> 42     filename = os.path.basename(filename)
     43     pre, delim, ext = filename.rpartition('.')
     45     if ext in ('gz', 'bz2',):

File <frozen posixpath>:142, in basename(p)

TypeError: expected str, bytes or os.PathLike object, not NoneType

I'm working on intel Mac and I have installed the tool using conda in a new env.

Many thanks

Exception: cannot center the protein

Hi,

I tried to run the script below with my own files and got this error message:

Exception: cannot center the protein

The funny thing is that my pdb, gro file and the trajectory are all aligned already.

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
Cell In[2], line 19
     17 distance = 2.0
     18 # align the trajectory and save the alignment reference configuration
---> 19 align_trajectory(
     20     trajectory=trajectory,
     21     topology=topology,
     22     align_target_file_name=aligned_snap,
     23     output_trj_file=alignedtrj,
     24 )
     25 # define active site by aminoacid residue numbers
     26 active_site_resnums = [293]

File ~\anaconda3\envs\ConservedWaterSearch\lib\site-packages\WaterNetworkAnalysis\WaterNetworkAnalysis.py:649, in align_trajectory(trajectory, output_trj_file, align_target_file_name, topology, every, align_mode, align_target, align_selection, probis_exec)
    647     mob.trajectory.add_transformations(*transforms2)
    648 else:
--> 649     raise Exception("cannot center the protein")
    650 ref.select_atoms(align_selection).segments.segids = "A"
    651 ref.add_TopologyAttr("chainIDs")

Exception: cannot center the protein

Clustering waters trouble

I'd like to use your code to cluster the waters of my Monte Carlo trajectory of a solvated protein. It is in DCD format, and the topology is PSF. I have attached a minimum example. The error message is shown below. My goal is the use this tool to cluster the waters within a certain distance of the protein. Is there any way to do so? I know the extract_waters_from_trajectory method is written to extract waters in an active site. In my scenario, I am interested in all the waters near/internal to the protein.

I am able to get to the clustering stage, but it is complaining that certain waters have too many hydrogens.

also the get selection center method fails when the list of residues is large (>500). I used the mdanalysis get geometric center method to bypass this.

Thank you,

Gregory Schwing
minReproducibleExample.zip



  File "/home/greg/Desktop/wolf/WNA.py", line 43, in <module>
    coordO, coordH =  extract_waters_from_trajectory(
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greg/mambaforge/envs/WNA/lib/python3.11/site-packages/WaterNetworkAnalysis/WaterNetworkAnalysis.py", line 401, in extract_waters_from_trajectory
    Opos, H1, H2 = get_orientations_from_positions(Odata, coordsH)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/greg/mambaforge/envs/WNA/lib/python3.11/site-packages/ConservedWaterSearch/utils.py", line 101, in get_orientations_from_positions
    raise ValueError(
ValueError: ('bad input HO bonds in water longer than 1.2A; value:', 0.8907369, 79.257034)

calculate_oxygen_density_map functions needs to be importet for the example

Hi,

I noticed a very small issue in the documentations. In the example for the Calculation of oxygen water density maps is not importet:

from WaterNetworkAnalysis import align_and_extract_waters, get_center_of_selection,get_selection_string_from_resnums
# MD trajectory filename
trajectory="md.xtc"
# topology filename
topology="md.gro"
# aligned trajectory filename
alignedtrj = "aligned_trj.xtc"
# aligned snapshot filename
aligned_snap = "aligned.pdb"
# distance to select water molecules around
distance = 12.0
# name of water density map file
watdens_fname = 'water.dx'
# define active site by aminoacid residue numbers
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,
)
calculate_oxygen_density_map(
    selection_center=selection_centre,
    trajectory=alignedtrj,
    topology=topology,
    dist=distance,
    output_name=watdens_fname,
)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.