Rev | Line | |
---|
[e1a46d] | 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 |
|
---|
[c03ca6] | 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>"
|
---|
[e1a46d] | 11 | print "Output goes to STDOUT."
|
---|
| 12 | sys.exit(1)
|
---|
| 13 |
|
---|
| 14 | # get parameters
|
---|
[c03ca6] | 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])]
|
---|
[e1a46d] | 19 |
|
---|
| 20 | # parse the file and obtain maxid
|
---|
[c03ca6] | 21 | wrerr("Parsing the coordinate file "+sys.argv[1]+".\n")
|
---|
[e1a46d] | 22 | file = open(sys.argv[1], "r")
|
---|
[c03ca6] | 23 | #wrout(file.readline())
|
---|
| 24 | #wrout(file.readline())
|
---|
[e1a46d] | 25 | atoms = {}
|
---|
| 26 | maxid=-1
|
---|
[c03ca6] | 27 | nr=0
|
---|
[e1a46d] | 28 | for line in file:
|
---|
| 29 | # simpy print everything else
|
---|
[c03ca6] | 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):
|
---|
[e1a46d] | 38 | fields=line.split()
|
---|
| 39 | for i in range(3):
|
---|
[c03ca6] | 40 | value=float(fields[i+xyzoffset])+shift[i]
|
---|
[e1a46d] | 41 | while value > box[i]:
|
---|
| 42 | value = value - box[i]
|
---|
| 43 | while value < 0:
|
---|
| 44 | value = value + box[i]
|
---|
[c03ca6] | 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])))
|
---|
[e1a46d] | 47 | wrout("\n")
|
---|
| 48 |
|
---|
| 49 | sys.exit(0)
|
---|
Note:
See
TracBrowser
for help on using the repository browser.