def _prepare(self): n_dim = self._n_atoms * 3 self.cov = np.zeros((n_dim, n_dim)) self._ref_atom_positions = self._reference.positions self._ref_cog = self._reference.center_of_geometry() self._ref_atom_positions -= self._ref_cog if self._calc_mean: interval = int(self.n_frames // 100) interval = interval if interval > 0 else 1 format = ("Mean Calculation Step" "%(step)5d/%(numsteps)d [%(percentage)5.1f%%]\r") mean_pm = ProgressMeter(self.n_frames if self.n_frames else 1, interval=interval, verbose=self._verbose, format=format) for i, ts in enumerate( self._u.trajectory[self.start:self.stop:self.step]): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) else: self.mean += self._atoms.positions.ravel() mean_pm.echo(i) self.mean /= self.n_frames self.mean_atoms = self._atoms self.mean_atoms.positions = self._atoms.positions
def _prepare(self): n_dim = self._n_atoms * 3 self.cov = np.zeros((n_dim, n_dim)) self._ref_atom_positions = self._reference.positions self._ref_cog = self._reference.center_of_geometry() self._ref_atom_positions -= self._ref_cog if self._calc_mean: interval = int(self.n_frames // 100) interval = interval if interval > 0 else 1 format = ("Mean Calculation Step" "%(step)5d/%(numsteps)d [%(percentage)5.1f%%]\r") mean_pm = ProgressMeter(self.n_frames if self.n_frames else 1, interval=interval, verbose=self._verbose, format=format) for i, ts in enumerate(self._u.trajectory[self.start:self.stop: self.step]): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) else: self.mean += self._atoms.positions.ravel() mean_pm.echo(i) self.mean /= self.n_frames self.mean_atoms = self._atoms self.mean_atoms.positions = self._atoms.positions
def _single_frame(self): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) # now all structures are aligned to reference x = mobile_atoms.positions.ravel() else: x = self._atoms.positions.ravel() x -= self.mean self.cov += np.dot(x[:, np.newaxis], x[:, np.newaxis].T)
def _single_frame(self): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) # now all structures are aligned to reference x = mobile_atoms.positions.ravel() else: x = self._atoms.positions.ravel() x -= self.mean self.cov += np.dot(x[:, np.newaxis], x[:, np.newaxis].T)
def _prepare(self): # access start index self._u.trajectory[self.start] # reference will be start index self._reference = self._u.select_atoms(self._select) self._atoms = self._u.select_atoms(self._select) self._n_atoms = self._atoms.n_atoms if self._mean is None: self.mean = np.zeros(self._n_atoms * 3) self._calc_mean = True else: self.mean = self._mean.positions self._calc_mean = False if self.n_frames == 1: raise ValueError('No covariance information can be gathered from a' 'single trajectory frame.\n') n_dim = self._n_atoms * 3 self.cov = np.zeros((n_dim, n_dim)) self._ref_atom_positions = self._reference.positions self._ref_cog = self._reference.center_of_geometry() self._ref_atom_positions -= self._ref_cog if self._calc_mean: interval = int(self.n_frames // 100) interval = interval if interval > 0 else 1 format = ("Mean Calculation Step" "%(step)5d/%(numsteps)d [%(percentage)5.1f%%]") mean_pm = ProgressMeter(self.n_frames if self.n_frames else 1, interval=interval, verbose=self._verbose, format=format) for i, ts in enumerate( self._u.trajectory[self.start:self.stop:self.step]): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) else: self.mean += self._atoms.positions.ravel() mean_pm.echo(i) self.mean /= self.n_frames self.mean_atoms = self._atoms self.mean_atoms.positions = self._atoms.positions
def _prepare(self): # access start index self._u.trajectory[self.start] # reference will be start index self._reference = self._u.select_atoms(self._select) self._atoms = self._u.select_atoms(self._select) self._n_atoms = self._atoms.n_atoms if self._mean is None: self.mean = np.zeros(self._n_atoms*3) self._calc_mean = True else: self.mean = self._mean.positions self._calc_mean = False if self.n_frames == 1: raise ValueError('No covariance information can be gathered from a' 'single trajectory frame.\n') n_dim = self._n_atoms * 3 self.cov = np.zeros((n_dim, n_dim)) self._ref_atom_positions = self._reference.positions self._ref_cog = self._reference.center_of_geometry() self._ref_atom_positions -= self._ref_cog if self._calc_mean: for ts in ProgressBar(self._u.trajectory[self.start:self.stop:self.step], verbose=self._verbose, desc="Mean Calculation"): if self.align: mobile_cog = self._atoms.center_of_geometry() mobile_atoms, old_rmsd = _fit_to(self._atoms.positions - mobile_cog, self._ref_atom_positions, self._atoms, mobile_com=mobile_cog, ref_com=self._ref_cog) self.mean += self._atoms.positions.ravel() self.mean /= self.n_frames self.mean_atoms = self._atoms self.mean_atoms.positions = self._atoms.positions