Exemplo n.º 1
0
def _processSimOld(obj, i, updList, uniqueMol, uqMol, skip, deleteSims, metrics, ref, fstep):
    pieces = updList[i].trajectory
    try:
        if uniqueMol:
            mol = uqMol.copy()
        else:
            mol = Molecule(updList[i].molfile)
        logger.debug(pieces[0])
        mol._readTraj(pieces, skip=skip)
    except Exception as e:
        logger.warning('Error in simulation with id: ' + str(updList[i].simid) + ' ' + e.__str__())
        #deleteSims[i] = True
        return None, None, None, True, i
    #fstep[i] = mol.fstep
    #metrics[i] = obj._processTraj(mol)
    #ref[i] = obj._calcRef(pieces, mol.fileloc)
    return obj._processTraj(mol), obj._calcRef(pieces, mol.fileloc), mol.fstep, False, i
Exemplo n.º 2
0
    def viewStates(self, protein=None, ligand=None, nsamples=20):
        from htmd.projections.metric import _singleMolfile
        from htmd.molecule.molecule import Molecule
        from htmd.vmdviewer import getCurrentViewer
        (single, molfile) = _singleMolfile(self.data.simlist)
        if not single:
            raise RuntimeError('Can'
                               't visualize states without unique molfile')

        viewer = getCurrentViewer()
        colors = [0, 1, 3, 4, 5, 6, 7, 9]

        print('Active set includes macrostates: {}'.format(
            self.hmm.active_set))

        # dtraj = np.vstack(self.hmm.discrete_trajectories_full)
        res = self.hmm.sample_by_observation_probabilities(nsamples)
        refmol = Molecule(molfile)

        for i, s in enumerate(self.hmm.active_set):
            mol = Molecule(molfile)
            mol.coords = []
            mol.box = []
            # idx = np.where(dtraj == i)[0]
            # samples = np.random.choice(idx, 20)
            # frames = self.data.abs2sim(samples)

            frames = self.data.rel2sim(res[i])
            for f in frames:
                mol._readTraj(f.sim.trajectory[f.piece],
                              frames=[f.frame],
                              append=True)
            mol.wrap('protein')
            mol.align('protein', refmol=refmol)
            viewer.loadMol(mol, name='hmm macro ' + str(s))
            if ligand is not None:
                viewer.rep('ligand',
                           sel=ligand,
                           color=colors[np.mod(i, len(colors))])
            if protein is not None:
                viewer.rep('protein')
            viewer.send('start_sscache')
Exemplo n.º 3
0
def _processSimOld(obj, i, updList, uniqueMol, uqMol, skip, deleteSims,
                   metrics, ref, fstep):
    pieces = updList[i].trajectory
    try:
        if uniqueMol:
            mol = uqMol.copy()
        else:
            mol = Molecule(updList[i].molfile)
        logger.debug(pieces[0])
        mol._readTraj(pieces, skip=skip)
    except Exception as e:
        logger.warning('Error in simulation with id: ' +
                       str(updList[i].simid) + ' ' + e.__str__())
        #deleteSims[i] = True
        return None, None, None, True, i
    #fstep[i] = mol.fstep
    #metrics[i] = obj._processTraj(mol)
    #ref[i] = obj._calcRef(pieces, mol.fileloc)
    return obj._processTraj(mol), obj._calcRef(
        pieces, mol.fileloc), mol.fstep, False, i
Exemplo n.º 4
0
def _processSim(sim, projectionlist, uqmol, skip):
    pieces = sim.trajectory
    try:
        if uqmol is not None:
            mol = uqmol.copy()
        else:
            mol = Molecule(sim.molfile)
        logger.debug(pieces[0])
        mol._readTraj(pieces, skip=skip)
    except Exception as e:
        logger.warning('Error in simulation with id: ' + str(sim.simid) + ' ' +
                       e.__str__())
        return None, None, None, True

    data = []
    for p in projectionlist:
        data.append(p.project(mol))
    data = np.hstack(data)

    return data, _calcRef(pieces, mol.fileloc), mol.fstep, False
Exemplo n.º 5
0
def _processSim(sim, projectionlist, uqmol, skip):
    pieces = sim.trajectory
    try:
        if uqmol is not None:
            mol = uqmol.copy()
        else:
            mol = Molecule(sim.molfile)
        logger.debug(pieces[0])
        mol._readTraj(pieces, skip=skip)

        data = []
        for p in projectionlist:
            pj=p.project(mol)
            if pj.ndim==1:
                pj=np.atleast_2d(pj).T
            data.append(pj)
        data = np.hstack(data)
    except Exception as e:
        logger.warning('Error in simulation with id: ' + str(sim.simid) + ' ' + e.__str__())
        return None, None, None, True

    return data, _calcRef(pieces, mol.fileloc), mol.fstep, False
Exemplo n.º 6
0
    def viewStates(self, protein=None, ligand=None, nsamples=20):
        from htmd.projections.metric import _singleMolfile
        from htmd.molecule.molecule import Molecule
        from htmd.vmdviewer import getCurrentViewer
        (single, molfile) = _singleMolfile(self.data.simlist)
        if not single:
            raise RuntimeError('Can''t visualize states without unique molfile')

        viewer = getCurrentViewer()
        colors = [0, 1, 3, 4, 5, 6, 7, 9]

        print('Active set includes macrostates: {}'.format(self.hmm.active_set))

        # dtraj = np.vstack(self.hmm.discrete_trajectories_full)
        res = self.hmm.sample_by_observation_probabilities(nsamples)
        refmol = Molecule(molfile)

        for i, s in enumerate(self.hmm.active_set):
            mol = Molecule(molfile)
            mol.coords = []
            mol.box = []
            # idx = np.where(dtraj == i)[0]
            # samples = np.random.choice(idx, 20)
            # frames = self.data.abs2sim(samples)

            frames = self.data.rel2sim(res[i])
            for f in frames:
                mol._readTraj(f.sim.trajectory[f.piece], frames=[f.frame], append=True)
            mol.wrap('protein')
            mol.align('protein', refmol=refmol)
            viewer.loadMol(mol, name='hmm macro ' + str(s))
            if ligand is not None:
                viewer.rep('ligand', sel=ligand, color=colors[np.mod(i, len(colors))])
            if protein is not None:
                viewer.rep('protein')
            viewer.send('start_sscache')