**30**wrote:

I have a trajectory file from simulation of 20,000 frames with 5 ps time in between every frame, what I want to do is to calculate diffusion in 2 dimension (x and y axis). but to calculate diffusion in 2D, first I have to calculate Mean square displacement of the selected atom from the trajectory. would also like to calculate MSD and diffusion for all atom. MSD calculates the average time taken by molecule to explore the system.

The formula for MSD would be

I am very new to python programming and I would really want some help to get started this problem and to solve this problem. Hope to get positive response.

I can use the following approach to calculate MSD

```
import numpy as np
r = np.sqrt(xdata**2 + ydata**2)
diff = np.diff(r) #this calculates r(t + dt) - r(t)
diff_sq = diff**2
MSD = np.mean(diff_sq)
```

I cannot figure it out how can I make the whole script which adds and take sqroot of position of atoms in x y and z at particular time interval here in the code it is:

`r = np.sqrt(xdata**2 + ydata**2)`

How can I select the atomic positions (which I have already obtained coordinates in .xyz file from .DCD file using Catdcd.) .xyz file contain x y and z coordiantes from .DCD file and I need to calculate diffusion across x and Y plane. Now how can I calculate MSD from the positions? Can anyone help me with the coding in python. I will be really grateful.

`. `

**20**• written 5.7 years ago by contact.lifesciences.inc •

**30**

~~Hello contact.lifesciences.inc!~~~~We believe that this post does not fit the main topic of this site.~~~~Not a bioinformatics question~~~~For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.~~~~If you disagree please tell us why in a reply below, we'll be happy to talk about it.~~~~Cheers!~~32kI have re-opened the question because I think that molecular dynamics simulations is very much on topic. Indeed, I feel it would be a very narrow perspective if computational biology and bioinformatics were restricted to NGS and sequence analysis only.

48kLooks like I was mistaken. I closed it because I saw nothing bio related - I certainly don't think NGS is the only part of bioinformatics. Thank you for clarifying the MD part.

32kSir

This is purely a bioinformatics question, you are mistaken. This lipid diffusion is a very important property which needs to be calculated. it gets calculated by analyzing large data files which are trajectory file. Bioinformatics does not only deals with pdb files. I asked a question related to trajectory file which got data and which is analyzed by making small python scripts.

30Yes, I was mistaken. I saw nothing biology related and that's why I closed the question. I apologize.

32kKindly make my question live so that I can get answers for my research related problem...

30