try pytraj
online:
# It's not uncommon to use a similiar package to load data to pytraj.
# In this tutorial, we will show how to convert mdtraj's Trajectory to pytraj's Trajectory
# Why? for example, you want to load '.xtc' file extension that is not supported in pytraj/cpptraj
# load pytraj
import pytraj as pt
# load mdtraj
import mdtraj as md
from mdtraj.testing import get_fn
# load h5 file
filename, topology_name = get_fn('monolayer.xtc'), get_fn('monolayer.pdb')
pt.load(filename, topology_name)
# if you can see, load xtc file extension results 0 frame because pytraj/cpptraj does not know how to read it.
# try mdtraj
m_traj = md.load(filename, top=topology_name)
m_traj
# convert mdtraj.Trajectory to pytraj.Trajectory
# need to provide topology_name (a pdb file)
# and convert m_traj's dtype of float32 to float64
traj = pt.Trajectory(xyz=m_traj.xyz.astype('f8'), top=topology_name)
traj
# compare mdtraj's m_traj and pytraj' s traj
(m_traj.xyz - traj.xyz)[:2]
# perfom some calculation with pytraj
pt.rmsd(traj, ref=0)
# mdtraj
print(set(atom.name for atom in m_traj.top.atoms))
# pytraj
print(set(atom.name for atom in traj.top.atoms))