water dynamics

151 views
Skip to first unread message

saikat pal

unread,
May 30, 2021, 11:07:21 AM5/30/21
to MDnalysis discussion
Dear all,

I am  new to MDanalysis and I am trying to calculate the water orientation using amber prmtop and nc trajectory file. Here, I am attached the code :

import MDAnalysis

from MDAnalysis.analysis.waterdynamics import WaterOrientationalRelaxation as WOR



u = MDAnalysis.Universe(2000-TIP3P-oct.prmtop, cum_md1_25.nc)

select = "resname WAT"

WOR_analysis = WOR(universe, select, 0, 1000, 20)

WOR_analysis.run()

time = 0

#now we print the data ready to plot. The first two columns are WOR_OH vs t plot,

#the second two columns are WOR_HH vs t graph and the third two columns are WOR_dip vs t graph

for WOR_OH, WOR_HH, WOR_dip in WOR_analysis.timeseries:

      print("{time} {WOR_OH} {time} {WOR_HH} {time} {WOR_dip}".format(time=time, WOR_OH=WOR_OH, WOR_HH=WOR_HH,WOR_dip=WOR_dip))

      time += 1



#now, if we want, we can plot our data

plt.figure(1,figsize=(18, 6))



#WOR OH

plt.subplot(131)

plt.xlabel('time')

plt.ylabel('WOR')

plt.title('WOR OH')

plt.plot(range(0,time),[column[0] for column in WOR_analysis.timeseries])



#WOR HH

plt.subplot(132)

plt.xlabel('time')

plt.ylabel('WOR')

plt.title('WOR HH')

plt.plot(range(0,time),[column[1] for column in WOR_analysis.timeseries])



#WOR dip

plt.subplot(133)

plt.xlabel('time')

plt.ylabel('WOR')

plt.title('WOR dip')

plt.plot(range(0,time),[column[2] for column in WOR_analysis.timeseries])



plt.show()

#######

It shows multiple error. Please correct me 

Tamas Hegedus

unread,
May 30, 2021, 2:56:11 PM5/30/21
to mdnalysis-...@googlegroups.com
Hi,

Please, first, try to analyze the error yourself. E.g. Based on your script, the error stopping the execution is most likely the missing quotation marks around the file names in u = MDAnalysis.Universe(2000-TIP3P-oct.prmtop, cum_md1_25.nc)

Second, ask about a specific error and do not ask to debug your full script. You can not expect that (e.g. we do not have the input files).

Third, if you have the error, than post the error and the trace.

Bests,
Tamas
--
You received this message because you are subscribed to the Google Groups "MDnalysis discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mdnalysis-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mdnalysis-discussion/2927ebb6-057c-4c98-99d0-c85e8401a35en%40googlegroups.com.

saikat pal

unread,
May 31, 2021, 9:12:08 AM5/31/21
to MDnalysis discussion
Dear Tamas,

I want to perform WaterOrientationalRelaxation https://docs.mdanalysis.org/2.0.0-dev0/documentation_pages/analysis/waterdynamics.html. So I have run the following script:
import MDAnalysis

from MDAnalysis.analysis.waterdynamics import WaterOrientationalRelaxation as WOR

u = MDAnalysis.universe("2000-TIP3P-oct.prmtop", "cum_md1_25.mdcrd")

select = "resname WAT and name O"

WOR_analysis = WOR(universe, select, 0, 100, 2)
WOR_analysis.run()
time = 0
#now we print the data ready to plot. The first two columns are WOR_OH vs t plot,
#the second two columns are WOR_HH vs t graph and the third two columns are WOR_dip vs t graph
for WOR_OH, WOR_HH, WOR_dip in WOR_analysis.timeseries:
      print("{time} {WOR_OH} {time} {WOR_HH} {time} {WOR_dip}".format(time=time, WOR_OH=WOR_OH, WOR_HH=WOR_HH,WOR_dip=WOR_dip))
      time += 1

##############

It shows error:

/home/ritu/anaconda3/envs/mdaenv/lib/python3.6/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:346: DeprecationWarning: This module is deprecated as of MDAnalysis version 1.0.It will be removed in MDAnalysis version 2.0Please use MDAnalysis.analysis.hydrogenbonds.hbond_analysis instead.
  category=DeprecationWarning
/home/ritu/anaconda3/envs/mdaenv/lib/python3.6/site-packages/MDAnalysis/analysis/hbonds/wbridge_analysis.py:33: DeprecationWarning: This module has been moved to MDAnalysis.analysis.hydrogenbonds.wbridge_analysis It will be removed in release 2.0
  category=DeprecationWarning)
Traceback (most recent call last):
  File "water-dynamics.py", line 5, in <module>
    u = MDAnalysis.universe("2000-TIP3P-oct.prmtop", "cum_md1_25.mdcrd")
AttributeError: module 'MDAnalysis' has no attribute 'universe'


#########

So which module should I use for this calculation?

Irfan Alibay

unread,
May 31, 2021, 9:18:29 AM5/31/21
to MDnalysis discussion
Hi,

>  AttributeError: module 'MDAnalysis' has no attribute 'universe'

This is the issue you're facing here.

The line you should be using is:

u = MDAnalysis.Universe("2000-TIP3P-oct.prmtop", "cum_md1_25.mdcrd")

(MDAnalysis follows PEP8 for class naming so all classes start with a capital letter).

With regards to the warnings, this is because waterdynamics in MDAnalysis 1.x uses the deprecated MDAnalysis.analysis.hbonds.
It doesn't affect the validity of your analysis. The warnings are mainly there to tell folks to use MDAnalysis.analysis.hydrogen_bonds in MDAnalysis 2.0+ (which waterdynamics does).

Best regards,

Irfan

saikat pal

unread,
Jun 1, 2021, 11:47:15 AM6/1/21
to MDnalysis discussion
Dear Tamas,

I want to perform WaterOrientationalRelaxation https://docs.mdanalysis.org/2.0.0-dev0/documentation_pages/analysis/waterdynamics.html. So I have run the following script:
import MDAnalysis

from MDAnalysis.analysis.waterdynamics import WaterOrientationalRelaxation as WOR

u = MDAnalysis.universe("2000-TIP3P-oct.prmtop", "cum_md1_25.mdcrd")

select = "resname WAT and name O"

WOR_analysis = WOR(universe, select, 0, 100, 2)
WOR_analysis.run()
time = 0
#now we print the data ready to plot. The first two columns are WOR_OH vs t plot,
#the second two columns are WOR_HH vs t graph and the third two columns are WOR_dip vs t graph
for WOR_OH, WOR_HH, WOR_dip in WOR_analysis.timeseries:
      print("{time} {WOR_OH} {time} {WOR_HH} {time} {WOR_dip}".format(time=time, WOR_OH=WOR_OH, WOR_HH=WOR_HH,WOR_dip=WOR_dip))
      time += 1

#######################

However, it shows the following error:

/home/ritu/anaconda3/envs/mdaenv/lib/python3.6/site-packages/MDAnalysis/analysis/hbonds/hbond_analysis.py:346: DeprecationWarning: This module is deprecated as of MDAnalysis version 1.0.It will be removed in MDAnalysis version 2.0Please use MDAnalysis.analysis.hydrogenbonds.hbond_analysis instead.
  category=DeprecationWarning
/home/ritu/anaconda3/envs/mdaenv/lib/python3.6/site-packages/MDAnalysis/analysis/hbonds/wbridge_analysis.py:33: DeprecationWarning: This module has been moved to MDAnalysis.analysis.hydrogenbonds.wbridge_analysis It will be removed in release 2.0
  category=DeprecationWarning)
Traceback (most recent call last):
  File "water-dynamics.py", line 5, in <module>
    u = MDAnalysis.universe("2000-TIP3P-oct.prmtop", "cum_md1_25.mdcrd")
AttributeError: module 'MDAnalysis' has no attribute 'universe'

########




On Monday, May 31, 2021 at 12:26:11 AM UTC+5:30 biohe...@gmail.com wrote:
Reply all
Reply to author
Forward
0 new messages