Changeset c03ca6
- Timestamp:
- Sep 28, 2009, 6:35:27 PM (16 years ago)
- Children:
- 6f1551
- Parents:
- f2dfc5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
util/src/ShiftPeriodic.py.in
rf2dfc5 rc03ca6 7 7 wrout = sys.stdout.write 8 8 9 if (len(sys.argv) < 9):10 print "Usage: "+sys.argv[0]+" < file> <offset> <box x> <box y> <box z> <shift x> <shift y> <shift z>"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 11 print "Output goes to STDOUT." 12 12 sys.exit(1) 13 13 14 14 # get parameters 15 offset=int(sys.argv[2]) 16 box=[float(sys.argv[3]), float(sys.argv[4]),float(sys.argv[5])] 17 shift=[float(sys.argv[6]),float(sys.argv[7]),float(sys.argv[8])] 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])] 18 19 19 20 # parse the file and obtain maxid 20 print "Parsing the PDB file "+sys.argv[1]+"." 21 wrerr("Parsing the coordinate file "+sys.argv[1]+".\n") 21 22 file = open(sys.argv[1], "r") 23 #wrout(file.readline()) 24 #wrout(file.readline()) 22 25 atoms = {} 23 26 maxid=-1 27 nr=0 24 28 for line in file: 25 29 # 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: 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): 29 38 fields=line.split() 30 39 for i in range(3): 31 value=float(fields[i+ offset])+shift[i]40 value=float(fields[i+xyzoffset])+shift[i] 32 41 while value > box[i]: 33 42 value = value - box[i] 34 43 while value < 0: 35 44 value = value + box[i] 36 fields[i+offset] = str(value) 37 for j in range(len(fields)): 38 wrout("%s " % (fields[j])) 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]))) 39 47 wrout("\n") 40 48
Note:
See TracChangeset
for help on using the changeset viewer.