| 1 | import sys
|
|---|
| 2 | try:
|
|---|
| 3 | scriptName, pqrFileName = sys.argv
|
|---|
| 4 | except ValueError:
|
|---|
| 5 | raise ValueError("Must supply one argument to script: PQR file name")
|
|---|
| 6 |
|
|---|
| 7 | f = open(pqrFileName, "r")
|
|---|
| 8 | pdbOut = open("chimera.pdb", "w")
|
|---|
| 9 | defattrOut = open("chimera.defattr", "w")
|
|---|
| 10 | print>>defattrOut, "attribute: charge"
|
|---|
| 11 | print>>defattrOut, "recipient: atoms"
|
|---|
| 12 | for 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())
|
|---|
| 18 | f.close()
|
|---|
| 19 | pdbOut.close()
|
|---|
| 20 | defattrOut.close()
|
|---|