6.2.1. Ensemble Analysis base class¶
New in version 0.8.0.
The Analysis modules help in the implementation analyses of MDPOW simulations. To simplify the process of analyzing a collection of systems generated by a free energy simulation the objects in Ensemble Objects allow for a molecule directory’s systems to be loaded into MDAnalysis Universes and be analyzed as a group.
EnsembleAnalysis
is a class inspired by the
AnalysisBase
from MDAnalysis which
iterates over the systems in the ensemble and the frames in the systems. It sets up both iterations between
universes and universe frames allowing for analysis to be run on both whole systems and the frames of those
systems. This allows for users to easily run analyses on MDPOW simulations.
-
class
mdpow.analysis.ensemble.
EnsembleAnalysis
(ensemble=None)[source]¶ Base class for running multi-system analyses
The class is designed based on the AnalysisBase class in MDAnalysis and is a template for creating multi-universe multi-frame analyses using the
Ensemble
objectKeywords: - ensemble
- The
Ensemble
being analyzed in the class
Example Analysis
Dihedral Analysis Demonstration:
class DihedralAnalysis(mdpow.ensemble.EnsembleAnalysis): def __init__(self, DihedralEnsembleGroup): super(DihedralAnalysis, self).__init__(DihedralEnsembleGroup.ensemble) self._sel = DihedralEnsembleGroup def _prepare_ensemble(self): self.result_dict = {} for s in ['water', 'octanol']: self.result_dict[s] = {'Coulomb': {}, 'VDW': {}} for key in self._sel.group_keys(): self.result_dict[key[0]][key[1]][key[2]] = None def _prepare_universe(self): self.angle_dict = {'angle': None, 'time': None} self.angles = [] def _single_frame(self): angle = calc_dihedrals(self._sel[self._key].positions[0], self._sel[self._key].positions[1], self._sel[self._key].positions[2], self._sel[self._key].positions[3]) self.angles.append(angle) def _conclude_universe(self): self.angle_dict['time'] = self.times self.angle_dict['angle'] = self.angles self.result_dict[self._key[0]][self._key[1]][self._key[2]] = self.angle_dict def _conclude_ensemble(self): self.results = pd.DataFrame(data=self.result_dict) D = DihedralAnalysis.run(start=0 stop=10, step=1)
-
_prepare_ensemble
()[source]¶ For establishing data structures used in running analysis on the entire ensemble.
Data structures will not be overwritten upon moving to next system in ensemble.
-
_prepare_universe
()[source]¶ For establishing data structures used in running analysis on each trajectory in ensemble
Data structures will be overwritten between upon after each trajectory has been run
-
_single_universe
()[source]¶ Calculations on a single Universe object.
Run on each universe in the ensemble during when self.run in called.
-
_single_frame
()[source]¶ Calculate data from a single frame of trajectory
Called on each frame for universes in the Ensemble.
-
static
check_groups_from_common_ensemble
(groups: List[mdpow.analysis.ensemble.EnsembleAtomGroup])[source]¶ Checks if inputted list of
EnsembleAtomGroup
originate from the sameEnsemble
Checks every
EnsembleAtomGroup
in list to determine if theirensemble()
references the same object in memory. If twoEnsembleAtomGroup
object don’t have a commonEnsemble
ValueError
is raised.