PDBextract

From p3d
Jump to: navigation, search

Very small script that prints parts of a pdbfile. Selection is done using the query functions (see p3d.parser).

PDBextract.py

usage

PDBextract.py <pdb file> <"querystring">

The output is e.g.

$ ./PDBextract.py ../pdbs/1MZ4.pdb "protein and within 3 of resname HEM" 
ATOM    735  CD2 HIS A  92      41.042  21.305  -4.966  1.00 15.98
ATOM    320  NE2 HIS A  41      36.874  20.006  -2.858  1.00 13.75
ATOM    399  O   ASP A  53      34.438  13.992  -6.080  1.00 15.94
ATOM    292  CB  CYS A  37      37.449  20.443   2.760  1.00 13.54
ATOM    736  CE1 HIS A  92      41.792  20.783  -2.972  1.00 14.29
ATOM    293  SG  CYS A  37      39.054  19.849   3.366  1.00 14.59
ATOM    309  CB  CYS A  40      34.903  24.376  -2.222  1.00 22.32
ATOM    737  NE2 HIS A  92      40.744  20.693  -3.771  1.00 15.35
ATOM    310  SG  CYS A  40      35.711  25.983  -2.119  1.00 21.54
ATOM    318  CD2 HIS A  41      36.374  20.190  -1.593  1.00 17.25

or

$ ./PDBextract.py ../pdbs/1MZ4.pdb "protein and within 3.5 of (resname HEM and oxygen)"
ATOM    445  CG2 THR A  58      34.001  11.873  -9.265  1.00 18.55
ATOM    399  O   ASP A  53      34.438  13.992  -6.080  1.00 15.94
ATOM    638  CE1 TYR A  82      37.679  12.158 -11.216  1.00 20.57
ATOM    394  CD1 LEU A  52      36.842  17.997 -11.920  1.00 24.92
ATOM    636  CD1 TYR A  82      38.475  13.232 -11.631  1.00 19.65

code

#!/usr/bin/env python
'''Extracts part of a PDB file using p3d query methods by Ch. Fufezan 2009

usage: PDBextract.py <pdb file> <"querystring">
e.g.   PDBextract.py pdb.pdb "residue 1 and backbone"

see online documentation for the syntax of the query string
'''
import sys, p3d.protein

if (__name__ == '__main__'):
	if (len(sys.argv) != 3):
		print (__doc__)
		sys.exit(1)
	atomSet = p3d.protein.Protein(sys.argv[1]).query(sys.argv[2])
	for atom in atomSet:
		print(atom.output())