Scripts: pqr2chimera.py

File pqr2chimera.py, 577 bytes (added by pett, 17 years ago)
Line 
1import sys
2try:
3 scriptName, pqrFileName = sys.argv
4except ValueError:
5 raise ValueError("Must supply one argument to script: PQR file name")
6
7f = open(pqrFileName, "r")
8pdbOut = open("chimera.pdb", "w")
9defattrOut = open("chimera.defattr", "w")
10print>>defattrOut, "attribute: charge"
11print>>defattrOut, "recipient: atoms"
12for line in f:
13 if not (line.startswith("ATOM ") or line.startswith("HETATM")):
14 continue
15 print>>pdbOut, line[:54]
16
17 print>>defattrOut, "\t@/serialNumber=%s\t%s" % (line[6:11].strip(), line[55:62].strip())
18f.close()
19pdbOut.close()
20defattrOut.close()