PyLOOS has undergone some substantial changes in LOOS 2.3.0. The top-level module/namespace remains "loos", and it includes everything imported from the core of LOOS. We have added a new "pyloos" module under "loos" that now holds Python-specific code, such as the new trajectories classes.
One of the biggest changes in PyLOOS is the introduction of three new trajectory classes. These classes ultimately wrap loos Trajectory objects but provide more python-like interfaces. The first class is loos.pyloos.Trajectory. You can specify a stride and the number of frames to skip from the start of the trajectory. The trajectory object can then be used like a python iterator,
You can also use the trajectory like an array,
There is often a need to know what frame number a frame corresponds to. If you are using the trajectory as in iterator, then the realIndex() function will return the frame number,
Since you can specify a skip and a stride, an array index does not necessarily give you the real frame number. Instead, use the frameNumber() member function. For example,
Another thing to be careful of is the linkage between groups through the shared atoms. By default, the frame returned will share atoms with whatever group was used to instantiate the trajectory. If you need to decouple the trajectory from the model, pass a copy to the constructor,
The other two trajectory classes, VirtualTrajectory and AlignedVirtualTrajectory let you combine multiple pyloos trajectory objects to make one big "virtual" trajectory. The latter supports the LOOS iterative alignment method and will return the aligned frames. Note that this does require reading in the alignment subset and aligning it at the first access to a frame, so there may be memory and performance penalties. The cached frames are discarded after the alignment however. Also, the AlignedVirtualTrajectory can be used with a single loos.pyloos.Trajectory to align it.
All of these classes have rich support for accessing the underlying components and getting information about what frame is being used, among others. For more information, see the above links, use the search bar, or see the documentation for pyloos under the Namespace tab.
In addition to the new trajectories, pyloos now sports several utility functions related to ensembles: loos.pyloos.averageStructure(), loos.pyloos.extractCoords(), and loos.pyloos.svd(), all of which use the new Trajectory classes. We have also added loos.pyloos.subspaceOverlap(), and loos.pyloos.covarianceOverlap().
The iterative alignment functions have also changed. There is now a loos.pyloos.iterativeAlignment() function that will take a loos.pyloos.Trajectory and align it (or a list/vector of loos::AtomicGroup). The loos-style interface is now available through loos.pyloos.iterativeAlignTrajectory(). You can optionally pass a list of frame indices to use. Both functions now return a Python tuple containing the results.
Finally, AtomicGroup now has support for NumPy with the AtomicGroup::getCoords() and AtomicGroup::setCoords() functions, which will return (or set) the coordinates of all atoms in the group. For example, calculating an average set of coordinates can be implemented this way: