Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slow performance of atom selection with MDAnalysis #47

Open
dominiquesydow opened this issue Sep 28, 2020 · 0 comments
Open

Slow performance of atom selection with MDAnalysis #47

dominiquesydow opened this issue Sep 28, 2020 · 0 comments
Labels
module-structure-superposition Concerns opencadd.structure.superposition module

Comments

@dominiquesydow
Copy link
Contributor

We are using the opencadd.structure.superposition module in TeachOpenCADD talktorial 010 and observed that selecting atoms with MDAnalysis (used in that module) is slow.

See PR: volkamerlab/teachopencadd#44

cProfile / snakeviz

Profiled code

import pandas as pd

from MDAnalysis.analysis import rms

from opencadd.structure.core import Structure
from opencadd.structure.superposition.engines.mda import MDAnalysisAligner


def calc_rmsd(A, B):
    """
    Calculate RMSD between two structures.
    
    Parameters
    ----------
    A : opencadd.structure.core.Structure
        Structure A.
    B : opencadd.structure.core.Structure
        Structure B.
        
    Returns
    -------
    float
        RMSD value.
    """
    aligner = MDAnalysisAligner()
    selection, _ = aligner.matching_selection(A, B)
    A = A.select_atoms(selection['reference'])
    B = B.select_atoms(selection['mobile'])
    return rms.rmsd(A.positions, B.positions, superposition=False)

structures = [Structure.from_pdbid(pdb_id) for pdb_id in ["3w2s", "3poz"]]
proteins = [Structure.from_atomgroup(s.select_atoms("protein")) for s in structures]
calc_rmsd(proteins[0], proteins[1])

Profile

image

In MDAnalysis.core.selection, the fnmatch package is used to look up the atoms (for atoms selection). Find out if we can cache the atom selection for superposition to be a fit faster.

@dominiquesydow dominiquesydow added the module-structure-superposition Concerns opencadd.structure.superposition module label Sep 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module-structure-superposition Concerns opencadd.structure.superposition module
Projects
None yet
Development

No branches or pull requests

1 participant