Acellera / htmd

HTMD: Programming Environment for Molecular Discovery
https://software.acellera.com/docs/latest/htmd/index.html
Other
261 stars 59 forks source link

model.createCoreSetModel failing #952

Closed PabloHNieto closed 4 years ago

PabloHNieto commented 4 years ago

Hello, I recap here our discussion about createCoreSetModel

When I try it I get this error.

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-11-043676cab89d> in <module>
----> 1 cs = nm.createCoreSetModel()
/shared/pablo/github/htmd/htmd/model.py in createCoreSetModel(self, threshold)
    851         St, newdata.K, newdata.N, frames = coreDtraj(self.data.St, self.micro_ofcluster, coreset)
    852         for i, s in enumerate(St):
--> 853             newdata.trajectories[i].cluster = s
    854 
    855         logger.info('Kept {} microstates from each macrostate.'.format([len(x) for x in coreset]))
/shared/pablo/github/htmd/htmd/metricdata.py in cluster(self, value)
     52     @cluster.setter
     53     def cluster(self, value):
---> 54         self._checkframes((self.projection, self.reference, value))
     55         self._cluster = value
     56 
/shared/pablo/github/htmd/htmd/metricdata.py in _checkframes(self, args)
     68     def _checkframes(self, args):
     69         if len(self._numframes(args)) > 1:
---> 70             raise RuntimeError('projection, reference and cluster must have same lengths')
     71 
     72     def dropFrames(self, frames):
RuntimeError: projection, reference and cluster must have same lengths

I seems that here https://github.com/Acellera/htmd/blob/5aad0b5ca8b593bbef297afbdfde80919a983a5b/htmd/model.py#L840-L841 trajectories' St are filtered from the original data to match selected frames, but they are used to update the original data (without applying that very same selection, thus creating the mismatching shapes problem). By moving these two lines to the bottom of the function (after trimming trajectories) it seems to work.

Could you verify this?

Thanks, Pablo

stefdoerr commented 4 years ago

fixed