#!/usr/bin/python # takes the coordinates from the arg specified file # and substitutes them for the coordinates in the # std input pdb file # the results is out via std out as a pdb file # example: # replace_coords.py adjusted.pdb < original.pdb > new.pdb import sys import string adjusted = sys.argv[1] """ 0123456789012345678901234567890123456789012345678901234567890123456 ATOM 1 N SER 1 23.567 14.160 40.755 1.00 0.00 ATOM 2 H1 SER 1 23.583 13.893 41.098 1.00 0.00 ATOM 3 H2 SER 1 23.327 14.269 41.142 1.00 0.00 ATOM 717 CG2 THR A 95 17.091 15.628 45.440 1.00 0.00 """ f = open(adjusted) db = {} # build the database of coords for line in f.readlines(): if line[:4]<>"ATOM": continue if line[17:20]=='SOL': continue atom = line[12:16] if atom==' O1 ': atom = ' O ' # this next one is due to differences between 3.2.1 and 3.3.1 if atom==' CD ': atom = ' CD1' if atom==' O2 ': atom = ' OXT' residueIndex = line[22:26] db[atom+residueIndex] = line[29:66] f.close() lines = sys.stdin.readlines() for line in lines: if line[:4]<>"ATOM": print line, continue atom = line[12:16] if atom==' O1 ': atom = ' O ' # this next one is due to differences between 3.2.1 and 3.3.1 if atom==' CD ': atom = ' CD1' if atom==' O2 ': atom = ' OXT' coords = db[atom+line[22:26]] print line[:29]+coords+line[66:],