#!/usr/bin/env pyXplor import re import sys write = sys.stdout.write xplor.parseArguments() # check for typos on the command-line infile=sys.argv[1] motionScale={} for line in open("bax_scale.tbl").readlines(): if line.startswith('#'): continue (resid,factor) = line.split() motionScale[ int(resid) ] = float(factor) pass lines = open(infile).readlines() cnt=0 while 1: try: if lines[cnt].startswith("assign"): resid= int( lines[cnt+4].split()[2] ) d = float( lines[cnt+5].split()[7] ) try: d *= motionScale[resid] lines[cnt+5] = \ re.sub(r"(\s+\(.*\))\s+[0-9.]+", r"\1 %7.3f" % d, lines[cnt+5]) for line in lines[cnt:cnt+6]: write( line) pass pass except KeyError: print ( "! resid %d not in scale table" % resid) pass cnt += 6 continue pass write( lines[cnt] ) cnt += 1 except IndexError: break pass