Closed lilyminium closed 3 years ago
Thanks @lilyminium. What's the best way to share the initial AnalysisBase? Should I submit a PR or leave it here as a comment?
As a PR would be easier to comment line-by-line, but if you don't have any code yet then you could just comment your ideas here.
@ojeda-e could you please start putting your thoughts here on how you want the AnalysisBase refactor to go?
In general, AnalysisBase classes will have four methods defined:
__init__
this receives arguments. Usually an AtomGroup or Universe is provided here to operate over, and user-arguments such asn_cell
._prepare
this typically sets up containers for the data to be collected in_single_frame
, and maybe performs some pre-emptive computation._single_frame
this is the bulk of the class: the functionality that you want to operate over every frame of the trajectory. For example, you could be collecting lipid positions._conclude
this does the final computation with the data collected from_single_frame
. Sometimes it's very short (e.g. https://github.com/MDAnalysis/mdanalysis/blob/64840d5df32ecb73ceadcc022dc4b71738537404/package/MDAnalysis/analysis/rms.py#L864-L870). Sometimes it's where the bulk of the computation is (e.g. https://github.com/MDAnalysis/mdanalysis/blob/64840d5df32ecb73ceadcc022dc4b71738537404/package/MDAnalysis/analysis/pca.py#L315-L322). For example, the calculation of mean and gaussian curvature could go here.run()
but only when they ask for it, you can add post-run methods instead, e.g. https://github.com/MDAnalysis/mdanalysis/blob/64840d5df32ecb73ceadcc022dc4b71738537404/package/MDAnalysis/analysis/pca.py#L431-L476