Last active
August 29, 2015 13:56
-
-
Save JoaoRodrigues/9095892 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Example to align two equivalent protein structures. | |
""" | |
from Bio.PDB import PDBParser, Superimposer | |
parser = PDBParser(QUIET=1) | |
protA = parser.get_structure('protA', 'pdb_xyzA.pdb') | |
protB = parser.get_structure('protB', 'pdb_xyzB.pdb') | |
equivalent_atoms = [] | |
for resA in protA.get_residues(): | |
for chain in protB.get_chains(): | |
if resA.id in chain: | |
# Align only CA-atoms | |
if 'CA' in resA: | |
ca_pair = (resA['CA'], chain[resA.id]['CA']) | |
equivalent_atoms.append(ca_pair) | |
super_imposer = Superimposer() | |
ref_atoms, mobi_atoms = zip(*equivalent_atoms) | |
super_imposer.set_atoms(ref_atoms, mobi_atoms) | |
print "RMS = {0:.2f}".format(super_imposer.rms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment