Python Examples

Project class

[ ]:
import os
from mddb_workflow.mwf import Project, MD
from mddb_workflow.mwf import project_requestables, md_requestables
[2]:
# Load the Project main class
os.makedirs('test_data', exist_ok=True)
project = Project(directory='test_data', accession='A01IP', sample_trajectory=10)
md: MD = project.mds[0]
project_requestables.keys(), md_requestables.keys()
[2]:
(dict_keys(['itopology', 'inputs', 'populations', 'transitions', 'topology', 'stopology', 'pdbs', 'mapping', 'ligands', 'lipids', 'screenshot', 'pmeta', 'chains', 'membranes']),
 dict_keys(['istructure', 'itrajectory', 'structure', 'trajectory', 'clusters', 'dist', 'energies', 'hbonds', 'helical', 'markov', 'pca', 'pockets', 'rgyr', 'rmsds', 'perres', 'pairwise', 'rmsf', 'sas', 'tmscore', 'density', 'thickness', 'apl', 'lorder', 'linter', 'dihedrals', 'interactions', 'mdmeta']))
[4]:
# Run a specific task from md_requestables
md_task = 'rmsds'
md.overwritables = {md_task}
md_requestables[md_task](md)
-> Running RMSDs analysis
 Reference: firstframe, Selection: protein, mass weighted
 Reference: firstframe, Selection: ligand 13885838, mass weighted
 Reference: average, Selection: protein, mass weighted
 Reference: average, Selection: ligand 13885838, mass weighted

Structure class

[ ]:
# Load any pdb file as a Structure object
from mddb_workflow.utils.structures import Structure

pdb_path = md_requestables['istructure'](md).path
mwf_stc  = Structure.from_file(pdb_path)
mwf_stc
<Structure (95368 atoms)>
[8]:
# Use a selection
mwf_stc.select('protein')
[8]:
<Selection (14484 atoms)>

Standard Topology

[ ]:
from mddb_workflow.utils.mda_spells import to_MDAnalysis_topology
import MDAnalysis as mda
u = mda.Universe(to_MDAnalysis_topology('topology.json'), pdb_path)