source: util/src/ShiftPeriodic.py.in@ 48cd93

Last change on this file since 48cd93 was e1a46d, checked in by Frederik Heber <heber@…>, 16 years ago

All of my python script put into ESPACK and adapted with @PYTHON@ and so on.

  • Property mode set to 100755
File size: 1.1 KB
Line 
1#!@PYTHON@
2#
3# Shifts atoms in a given coordination file periodically
4
5import sys, string, re, math
6wrerr = sys.stderr.write
7wrout = sys.stdout.write
8
9if (len(sys.argv) < 9):
10 print "Usage: "+sys.argv[0]+" <file> <offset> <box x> <box y> <box z> <shift x> <shift y> <shift z>"
11 print "Output goes to STDOUT."
12 sys.exit(1)
13
14# get parameters
15offset=int(sys.argv[2])
16box=[float(sys.argv[3]), float(sys.argv[4]),float(sys.argv[5])]
17shift=[float(sys.argv[6]),float(sys.argv[7]),float(sys.argv[8])]
18
19# parse the file and obtain maxid
20print "Parsing the PDB file "+sys.argv[1]+"."
21file = open(sys.argv[1], "r")
22atoms = {}
23maxid=-1
24for line in file:
25 # simpy print everything else
26 if "END" in line or "CONECT" in line or "MASTER" in line or "#" in line:
27 print line
28 else:
29 fields=line.split()
30 for i in range(3):
31 value=float(fields[i+offset])+shift[i]
32 while value > box[i]:
33 value = value - box[i]
34 while value < 0:
35 value = value + box[i]
36 fields[i+offset] = str(value)
37 for j in range(len(fields)):
38 wrout("%s " % (fields[j]))
39 wrout("\n")
40
41sys.exit(0)
Note: See TracBrowser for help on using the repository browser.