how to convert from dcd file to xtc file

40 views
Skip to first unread message

imren bayıl

unread,
Dec 25, 2022, 1:20:11 PM12/25/22
to MDnalysis discussion
Hi everyone,I am new user for mdanalysis.I have finished my md simulation using namd package.so my output file is dcd extension.But  I want to convert to dcd file to xtc file inorder to use gromacs for analysis.
so my code
import MDAnalysis as mda

import numpy as np
import pandas as pd

import matplotlib.pyplot as plt
import seaborn as sns
import nglview as nv

from MDAnalysisTests.datafiles import PSF, DCD
u = mda.Universe(PSF, DCD)
mda.Writer("new.xtc", n_atoms=u.atoms.n_atoms)
< XTCWriter 'new.xtc' for 3341 atoms > The problem is that the occuring "new.xtc" file is empty. I dont why,Could anybody help me please

Hugo Macdermott-Opeskin

unread,
Jan 3, 2023, 5:19:00 PM1/3/23
to MDnalysis discussion
Hi and welcome, 

Firstly, you will need to load your actual system rather than the test files, 


```
import MDAnalysis as mda

u = mda.Universe("my_psf.psf", "my_dcd.dcd")

```

Then you will need to actually iterate through the trajectory to write it using the writer. 

```
with mda.Writer("my_new_traj.xtc", u.n_atoms) as w:
    for ts in u.trajectory:
          w.write(u.atoms)
```

Let me know how that goes. 

Cheers, 

Hugo
Reply all
Reply to author
Forward
0 new messages