Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions benchmarks/benchmarks/analysis/bench_align.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# bench_align.py
# Benchmarks for MDAnalysis.analysis.align
# No benchmarks existed for this module before this file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think any of the comments above are needed/useful.


import MDAnalysis as mda
from MDAnalysis.analysis import align
from MDAnalysis.tests.datafiles import PSF, DCD, PDB_small


class AlignBenchmark:
"""
Benchmarks for MDAnalysis.analysis.align module.
Tests alignto() and AlignTraj() which are the two
most commonly used functions in this module.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How were they determined to be the "most commonly used?" Not sure this content is needed in any case.

"""

def setup(self):
# setup() runs ONCE before any timing starts
# load data here — never in time_ methods
# PSF = protein structure file (topology)
# DCD = trajectory file (coordinates over time)
# PDB_small = single reference structure
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kind of verbose/not needed I think

self.mobile = mda.Universe(PSF, DCD)
self.reference = mda.Universe(PSF, PDB_small)

def time_alignto_all_atoms(self):
"""Time aligning all atoms of a single frame"""
align.alignto(
self.mobile,
self.reference,
select="all"
)

def time_alignto_backbone(self):
"""Time aligning backbone atoms only (common in research)"""
align.alignto(
self.mobile,
self.reference,
select="backbone"
)

def time_alignto_mass_weighted(self):
"""Time aligning with mass weighting"""
align.alignto(
self.mobile,
self.reference,
select="backbone",
weights="mass"
)

def time_aligntraj_all_frames(self):
"""Time aligning entire trajectory — most expensive operation"""
alignment = align.AlignTraj(
self.mobile,
self.reference,
select="backbone",
in_memory=True # avoids writing to disk during benchmark
)
alignment.run()

def time_average_structure(self):
"""Time computing average structure across trajectory"""
avg = align.AverageStructure(
self.mobile,
self.reference,
select="backbone"
)
avg.run()
Loading