Line | |
---|
1 | #!@PYTHON@
|
---|
2 | #
|
---|
3 | # Shifts atoms in a given coordination file periodically
|
---|
4 |
|
---|
5 | import sys, string, re, math
|
---|
6 | wrerr = sys.stderr.write
|
---|
7 | wrout = sys.stdout.write
|
---|
8 |
|
---|
9 | if (len(sys.argv) < 10):
|
---|
10 | print "Usage: "+sys.argv[0]+" <xyzfile> <element offset> <xyzoffset> <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
|
---|
15 | elementoffset=int(sys.argv[2])
|
---|
16 | xyzoffset=int(sys.argv[3])
|
---|
17 | box=[float(sys.argv[4]), float(sys.argv[5]),float(sys.argv[6])]
|
---|
18 | shift=[float(sys.argv[7]),float(sys.argv[8]),float(sys.argv[9])]
|
---|
19 |
|
---|
20 | # parse the file and obtain maxid
|
---|
21 | wrerr("Parsing the coordinate file "+sys.argv[1]+".\n")
|
---|
22 | file = open(sys.argv[1], "r")
|
---|
23 | #wrout(file.readline())
|
---|
24 | #wrout(file.readline())
|
---|
25 | atoms = {}
|
---|
26 | maxid=-1
|
---|
27 | nr=0
|
---|
28 | for line in file:
|
---|
29 | # simpy print everything else
|
---|
30 | if not ("END" in line or "CONECT" in line or "MASTER" in line or "#" in line):
|
---|
31 | nr+=1
|
---|
32 | file.close()
|
---|
33 | file = open(sys.argv[1], "r")
|
---|
34 | wrout("%d\n\tShifted by $shift from PDB file.\n" % (nr))
|
---|
35 | for line in file:
|
---|
36 | # simpy print everything else
|
---|
37 | if not ("END" in line or "CONECT" in line or "MASTER" in line or "#" in line):
|
---|
38 | fields=line.split()
|
---|
39 | for i in range(3):
|
---|
40 | value=float(fields[i+xyzoffset])+shift[i]
|
---|
41 | while value > box[i]:
|
---|
42 | value = value - box[i]
|
---|
43 | while value < 0:
|
---|
44 | value = value + box[i]
|
---|
45 | fields[i+xyzoffset] = str(value)
|
---|
46 | wrout("%s\t%lg\t%lg\t%lg" % (fields[elementoffset], float(fields[0+xyzoffset]), float(fields[1+xyzoffset]), float(fields[2+xyzoffset])))
|
---|
47 | wrout("\n")
|
---|
48 |
|
---|
49 | sys.exit(0)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.