PDB Beta Factor Helper
GitHub Link to Code.
PDB beta factor helper for structure visualization.
This module provides utilities for extracting trajectory frames and creating PDB files with custom beta factors for visualization purposes.
- class mdxplain.structure_visualization.helper.pdb_beta_factor_helper.PdbBetaFactorHelper
Helper for creating PDB files with custom beta factors.
Provides methods for extracting frames from trajectories and saving them as PDB files with custom beta factors for visualization in PyMOL.
Examples
>>> # Extract frame as PDB with beta factors >>> beta_factors = np.array([0.0, 50.0, 100.0, ...]) # Per-atom >>> pdb_path = PdbBetaFactorHelper.create_pdb_with_beta_factors( ... pipeline_data, traj_idx=0, frame_idx=100, ... beta_factors=beta_factors, output_path="output.pdb" ... )
- static create_pdb_with_beta_factors(pipeline_data: PipelineData, traj_idx: int, frame_idx: int, beta_factors: np.ndarray, output_path: str) str
Create PDB with custom beta factors.
Extracts a frame and saves it with custom beta factors for each atom. Beta factors are used for coloring in PyMOL.
Parameters
- pipeline_dataPipelineData
Pipeline data object
- traj_idxint
Trajectory index
- frame_idxint
Frame index within trajectory
- beta_factorsnp.ndarray
Beta factors for all atoms, shape (n_atoms,)
- output_pathstr
Path where to save the PDB file
Returns
- str
Path to created PDB file
Raises
- ValueError
If beta_factors shape doesn’t match number of atoms
Examples
>>> # Create PDB with importance-based beta factors >>> topology = pipeline.data.trajectory_data.trajectories[0].topology >>> beta_factors = np.zeros(topology.n_atoms) >>> # Set beta factors based on residue importance... >>> pdb_path = PdbBetaFactorHelper.create_pdb_with_beta_factors( ... pipeline_data, 0, 100, beta_factors, "output.pdb" ... )
Notes
Beta factors should be in range 0-100 for optimal PyMOL visualization
All atoms in the frame receive the provided beta factors
Memmap-safe: only loads one frame
- static get_topology(pipeline_data: PipelineData, traj_idx: int = 0) md.Topology
Get topology from a trajectory.
Convenience method to access topology for residue information.
Parameters
- pipeline_dataPipelineData
Pipeline data object
- traj_idxint, default=0
Trajectory index to get topology from
Returns
- mdtraj.Topology
Topology object
Examples
>>> topology = PdbBetaFactorHelper.get_topology(pipeline_data, 0) >>> print(f"Number of residues: {topology.n_residues}")