1 | #!@PYTHON@
|
---|
2 | #
|
---|
3 | # Re-creates neighbours in .data file for water molecules OH2, H1, H2 being consecutive
|
---|
4 |
|
---|
5 | import sys, math
|
---|
6 |
|
---|
7 | if len(sys.argv) < 3:
|
---|
8 | print "Usage: "+sys.argv[0]+" <file> <output>"
|
---|
9 | sys.exit(1)
|
---|
10 |
|
---|
11 | input=open(sys.argv[1],"r")
|
---|
12 | output=open(sys.argv[2],"w")
|
---|
13 | outputXYZ=open(sys.argv[2]+".xyz","w")
|
---|
14 | outputXYZ.write("1734\n # test\n")
|
---|
15 | x=[0,0,0]
|
---|
16 | for line in input:
|
---|
17 | if "#" in line:
|
---|
18 | output.write(line)
|
---|
19 | continue
|
---|
20 | if " OH2" in line:
|
---|
21 | entries=line.split()
|
---|
22 | entries[0]=str(int(entries[0])-1)
|
---|
23 | entries[5]=str(int(entries[5])+0)
|
---|
24 | entries[6]=str(int(entries[6])+1)
|
---|
25 | output.write("%s\tOT\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (entries[0], entries[2], entries[3], entries[4], entries[5], entries[6], entries[7], entries[8]))
|
---|
26 | outputXYZ.write("O\t%s\t%s\t%s\n" % (entries[2], entries[3], entries[4]))
|
---|
27 | continue
|
---|
28 | if " H1" in line:
|
---|
29 | entries=line.split()
|
---|
30 | entries[0]=str(int(entries[0])-1)
|
---|
31 | entries[5]=str(int(entries[5])-2)
|
---|
32 | output.write("%s\tHT\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (entries[0], entries[2], entries[3], entries[4], entries[5], entries[6], entries[7], entries[8]))
|
---|
33 | outputXYZ.write("H\t%s\t%s\t%s\n" % (entries[2], entries[3], entries[4]))
|
---|
34 | continue
|
---|
35 | if " H2" in line:
|
---|
36 | entries=line.split()
|
---|
37 | entries[0]=str(int(entries[0])-1)
|
---|
38 | entries[5]=str(int(entries[5])-3)
|
---|
39 | output.write("%s\tHT\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (entries[0], entries[2], entries[3], entries[4], entries[5], entries[6], entries[7], entries[8]))
|
---|
40 | outputXYZ.write("H\t%s\t%s\t%s\n" % (entries[2], entries[3], entries[4]))
|
---|
41 | continue
|
---|
42 | entries=line.split()
|
---|
43 | x[2]=str(float(entries[2]))
|
---|
44 | x[1]=str(float(entries[3]))
|
---|
45 | x[0]=str(float(entries[4]))
|
---|
46 | for n in range(3):
|
---|
47 | entries[2+n]=x[n]
|
---|
48 | output.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (entries[0], entries[1], entries[2], entries[3], entries[4], entries[5], entries[6], entries[7], entries[8]))
|
---|
49 | outputXYZ.write("%s\t%s\t%s\t%s\n" % (entries[1], entries[2], entries[3], entries[4]))
|
---|
50 |
|
---|
51 | sys.exit(0)
|
---|