rmsd and align on different chain in protein-protein #4925
Answered
by
orbeckst
aspitaleri
asked this question in
Q&A
-
Hi all, import MDAnalysis as mda
from MDAnalysis.analysis import align, rms
from natsort import natsorted
import numpy as np
import pandas as pd
import glob
import sys
# Read reference structure and sorted PDB files
pdbref = "reference.pdb"
pdb_files = glob.glob("top_*.pdb")
pdb_files_sorted = natsorted(pdb_files)
print("Loading reference and trajectory files...")
ref = mda.Universe(pdbref)
u = mda.Universe(*pdb_files_sorted, all_coordinates=True)
# Select Chain A for alignment and Chain B for RMSD calculation
mobile_chainB = u.select_atoms("chainID B and backbone")
reference_chainB = ref.select_atoms("chainID B and backbone")
# **Align trajectory on Chain A (Cα atoms)**
print("Aligning trajectory on Chain A...")
aligner = align.AlignTraj(u, ref, select="chainID A and backbone", in_memory=True)
aligner.run()
# **Compute RMSD on Chain B** AFTER alignment (manual calculation)
rmsd_values = []
for ts in u.trajectory:
rmsd_value = rms.rmsd(mobile_chainB.positions, reference_chainB.positions, center=False, superposition=False)
rmsd_values.append([ts.frame, ts.time, rmsd_value])
# Save RMSD results
df = pd.DataFrame(rmsd_values, columns=["Frame", "Time", "RMSD_ChainB"])
df.to_csv("rmsd_chainB.csv", index=False) is that correct approach? |
Beta Was this translation helpful? Give feedback.
Answered by
orbeckst
Feb 25, 2025
Replies: 1 comment
-
Assuming that all your You can use |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
aspitaleri
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Assuming that all your
pdb_files = glob.glob("top_*.pdb")
are the same number of atoms then you can read them as a trajectory.You can use
Aligner
andrmsd
manually but most people would likely just use rms.RMSD (see also the User Guide example on RMSD.