#!@PYTHON@ # # Shifts atoms in a given coordination file periodically import sys, string, re, math wrerr = sys.stderr.write wrout = sys.stdout.write if (len(sys.argv) < 10): print "Usage: "+sys.argv[0]+" " print "Output goes to STDOUT." sys.exit(1) # get parameters elementoffset=int(sys.argv[2]) xyzoffset=int(sys.argv[3]) box=[float(sys.argv[4]), float(sys.argv[5]),float(sys.argv[6])] shift=[float(sys.argv[7]),float(sys.argv[8]),float(sys.argv[9])] # parse the file and obtain maxid wrerr("Parsing the coordinate file "+sys.argv[1]+".\n") file = open(sys.argv[1], "r") #wrout(file.readline()) #wrout(file.readline()) atoms = {} maxid=-1 nr=0 for line in file: # simpy print everything else if not ("END" in line or "CONECT" in line or "MASTER" in line or "#" in line): nr+=1 file.close() file = open(sys.argv[1], "r") wrout("%d\n\tShifted by $shift from PDB file.\n" % (nr)) for line in file: # simpy print everything else if not ("END" in line or "CONECT" in line or "MASTER" in line or "#" in line): fields=line.split() for i in range(3): value=float(fields[i+xyzoffset])+shift[i] while value > box[i]: value = value - box[i] while value < 0: value = value + box[i] fields[i+xyzoffset] = str(value) wrout("%s\t%lg\t%lg\t%lg" % (fields[elementoffset], float(fields[0+xyzoffset]), float(fields[1+xyzoffset]), float(fields[2+xyzoffset]))) wrout("\n") sys.exit(0)