-
Notifications
You must be signed in to change notification settings - Fork 119
coordinates.load loading wrong shape from GROMACS .xtc #1513
Comments
There is something about your traceback that I don't understand. According to your code, you are not adding any features - that should default to xyz coordinates, if I'm not mistaken. However, the error occurs in a function called |
Here is that function I wrote:
I am trying to return the distance from residue center of mass of index 15 and 70. I saw a similar custom thread here and I'm trying to adopt it to just return the scalar distance between the center of mass of two residues: |
Hi @germanbarcenas, this is because XYZ does not have the proper shape! If you want to compute the distance between two (trajectories of) centers... centers4 = c4.transform(traj) # yields (n_frames, 1, 3) ndarray
centers5 = c5.transform(traj) # yields (n_frames, 1, 3) ndarray
xyz = np.hstack((centers4, centers5))
traj = mdtraj.Trajectory(xyz.reshape(-1, 2, 3), topology=pdb)
distances = mdtraj.compute_distances(traj, distance_indices=[[0, 1]], periodic=True)
return distances Note that this is untested code but in general it should help to print the intermediate shapes or step through the code with an actual debugger. |
It works now! So I see I was not understanding the shape criteria. Here is my final code:
|
I'd like to point out some errors I encounted as I was debugging:
I had to take out compute_distances() got an unexpected keyword argument 'distance_indices' and then I changed AttributeError: 'str' object has no attribute '_numAtoms' |
Great that this works for you! Beware of periodic boundary conditions when evaluating distances though. You will need the topology (pdb) for this. |
Hello,
I am trying to load in a .xtc file generated from GROMACS. Right now I'm mostly following the workflow from the posted tutorials, except I want to use my own data. I just have 1 .xtc file to load and analyze. I'm trying to cluster and look for features like in notebook 2:
http://emma-project.org/latest/tutorials/notebooks/02-dimension-reduction-and-discretization.html
When I try actually process the data, I see some errors associated with the shape of my trajectory array, that should be T,d, where T is timesteps, and d is the number of features, according to the coordinates.load documentation. I can confirm I have 2 features, but something is off on my trajectory shape. The .xtc is very large, so I don't think I can share it directly, However, this is how the code generally flows:
PyEMMA v2.5.9
Here is the error
Traceback (most recent call last):
The text was updated successfully, but these errors were encountered: