简体   繁体   中英

How can I load an array generated by projecting a trajectory on its principal components in MDAnalysis?

I have an array, tpcs, of shape (150017, 5) generated from MDAnalysis.pca.transform(). I am trying to load this as a trajectory to visualize it. I tried:

 u = mda.Universe(trjpath+'md.gro', tpcs)

which returns the error:

ValueError                                Traceback (most recent call last)
<ipython-input-80-ea97f213be3c> in <module>()
----> 1 u = mda.Universe(trjpath+'md.gro', tpcs)
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/core/universe.pyc in __init__(self, *args, **kwargs)
    276             else:
    277                 coordinatefile = args[1:]
--> 278             self.load_new(coordinatefile, **kwargs)
    279 
    280         # Check for guess_bonds
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/core/universe.pyc in load_new(self, filename, format, in_memory, **kwargs)
    424         kwargs['n_atoms'] = self.atoms.n_atoms
    425 
--> 426         self.trajectory = reader(filename, **kwargs)
    427         if self.trajectory.n_atoms != len(self.atoms):
    428             raise ValueError("The topology and {form} trajectory files don't"
/nfs/homes/kreidy/Library/mdanalysis/package/MDAnalysis/coordinates/memory.pyc in __init__(self, coordinate_array, order, dimensions, dt, filename, **kwargs)
    275                                  "does not match the shape of the coordinate "
    276                                  "array ({})"
--> 277                                  .format(provided_n_atoms, self.n_atoms))
    278 
    279         self.ts = self._Timestep(self.n_atoms, **kwargs)
ValueError: The provided value for n_atoms (132506) does not match the shape of the coordinate array (5)

How can I load this array into a trajectory?

You can only store load 3 dimensional data in a gro file. Your PCA space that you use is 5 dimensional. Besides visualizing a PCA space with MDAnalysis won't work. You can use gromacs to show unphysical morphs between states the PCA identifies.

The individual PCA components are collective variables that you can plot with matplotlib. Either individually or in pairs. See this gist for visualization of the PCA space and how you can visualize the states the PCA finds using MDAnalysis and Gromacs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM