From p3d
Jump to: navigation, search

This small script illustrates how the TransformationMatrix class can be used to align two structures using three source and three target vectors. The TransformationMatrix is part of the p3d.geo_module.

usage <source-pdb> <ATP resid> <target-pdb> <ATP resid>

The output is the transformed source pdb




#!/usr/bin/env python2.6
'''Aligns two pdbs by their ATPs by M. Specht & Ch. Fufezan 2009

usage: <source-pdb> <ATP resid> <target-pdb> <ATP resid>
e.g. 2FXU.pdb 401 1RDQ.pdb 600
       aligns source-pdb onto the ATP of target-pdb by using the 'N1','C5' and 'N3' atoms

import sys
import p3d.protein
import p3d.geo

if (__name__ == '__main__'):
	if (len(sys.argv) != 5):
		print (__doc__)
	pdb1 = p3d.protein.Protein(sys.argv[1])
	residOfSourceATP = sys.argv[2]
	pdb2 = p3d.protein.Protein(sys.argv[3])
	residOfTargetATP = sys.argv[4]
	alignAtoms = ['N1','C5','N3']
	sourceAtoms = []
	targetAtoms = []
	for atom in alignAtoms:
		sourceAtoms.append(pdb1.lookUpAtom('resname ATP and resid ',residOfSourceATP,' and atom type',atom))
		targetAtoms.append(pdb2.lookUpAtom('resname ATP and resid ',residOfTargetATP,' and atom type',atom))
	tm = p3d.geo.TransformationMatrix(sourceAtoms,targetAtoms)
	for atom in pdb1.atoms:
		print (tm*atom).output()