Commit 4412e203 authored by cmaffeo2's avatar cmaffeo2
Browse files

Fixed PDB writer to correctly include system dimensions and to write the segname to the pdb

parent 05f1c184
......@@ -442,14 +442,17 @@ class PdbModel(Transformable, Parent):
self._updateParticleOrder()
with open(filename,'w') as fh:
## Write header
fh.write("CRYST1 {:>5f} {:>5f} {:>5f} 90.00 90.00 90.00 P 1 1\n".format( *self.dimensions ))
fh.write("CRYST1{:>9.3f}{:>9.3f}{:>9.3f} 90.00 90.00 90.00 P 1 1\n".format( *self.dimensions ))
## Write coordinates
# formatString = "ATOM {:>5d} {:^4.4s}{:1.1s}{:3.3s} {:1.1s}{:>5.5s} {:8.3f}{:8.3f}{:8.3f}{:6.2f}{:6.2f}{:2.2s}{:2f}\n"
formatString = "ATOM {:>6.6s} {:^4.4s}{:1.1s}{:3.3s} {:1.1s}{:>5.5s} {:8.8s}{:8.8s}{:8.8s}{:6.2f}{:6.2f}{:2.2s}{:2f}\n"
formatString = "ATOM {:>6.6s} {:^4.4s}{:1.1s}{:3.3s} {:1.1s}{:>5.5s} {:8.8s}{:8.8s}{:8.8s}{:6.2f}{:6.2f}{:2.2s}{:2d}{:>6s}\n"
for p in self.particles:
## http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM
idx = p.idx+1
try:
segname = p.segname
except:
segname = "A"
try:
resname = p.resname
except:
......@@ -484,7 +487,7 @@ class PdbModel(Transformable, Parent):
resid = "{:<4d}".format(resid)
fh.write( formatString.format(
idx, name, "", resname, chain, resid, x, y, z, occ, beta, "", charge ))
idx, name, "", resname, chain, resid, x, y, z, occ, beta, "", charge, segname ))
return
def writePsf(self, filename):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment