Skip to content

Commit

Permalink
Merge pull request #700 from kain88-de/pdb-charge-alignment
Browse files Browse the repository at this point in the history
PDB charges are not written anymore.
  • Loading branch information
orbeckst committed Feb 8, 2016
2 parents 8bd70bf + b9d2e14 commit 41c86ed
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Changes
* Short TRZ titles are striped from trailing spaces. A friendlier error
message is raised when the TRZ writer is asked to write a title longer
than 80 characters. (Issue #689)
* PDB doesn't save charge information anymore

Fixes

Expand Down
27 changes: 8 additions & 19 deletions package/MDAnalysis/coordinates/PDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,33 +672,23 @@ class PrimitivePDBWriter(base.Writer):
Initial support for multi-frame PDB files.
.. versionchanged:: 0.7.6
The *multiframe* keyword was added to select the writing mode. The writing
of bond information (CONECT_ records) is now disabled by default but can be
enabled with the *bonds* keyword.
The *multiframe* keyword was added to select the writing mode. The
writing of bond information (CONECT_ records) is now disabled by default
but can be enabled with the *bonds* keyword.
.. versionchanged:: 0.11.0
Frames now 0-based instead of 1-based
.. versionchanged:: 0.14.0
PDB doesn't save charge information
"""
# 1 2 3 4 5 6 7 8
# 123456789.123456789.123456789.123456789.123456789.123456789.123456789.123456789.
# ATOM__seria nameAres CressI xxxxxxxxyyyyyyyyzzzzzzzzOCCUPAtempft elCH
# ATOM %5d %-4s %-3s %4d %1s %8.3f %8.3f %8.3f %6.2f %6.2f %2s
# %1s %1s %2d
# = = === ==========
# ATOM %5d %-4s%1s%-3s %1s%4d%1s %8.3f%8.3f%8.3f%6.2f%6.2f %2s%2d
# ATOM %(serial)5d %(name)-4s%(altLoc)1s%(resName)-3s %(chainID)1s%(resSeq)4d%(iCode)1s %(x)8.3f%(y)8.3f%(
# z)8.3f%(occupancy)6.2f%(tempFactor)6.2f %(element)2s%(charge)2d

# Strict PDB format:
#fmt = {'ATOM': "ATOM %(serial)5d %(name)-4s%(altLoc)1s%(resName)-3s %(chainID)1s%(resSeq)4d%(iCode)1s %(
# x)8.3f%(y)8.3f%(z)8.3f%(occupancy)6.2f%(tempFactor)6.2f %(element)2s%(charge)2d\n",
# PDB format as used by NAMD/CHARMM: 4-letter resnames and segID, altLoc ignored
fmt = {
'ATOM': (
"ATOM {serial:5d} {name:<4s}{altLoc:<1s}{resName:<4s}"
"{chainID:1s}{resSeq:4d}{iCode:1s}"
" {pos[0]:8.3f}{pos[1]:8.3f}{pos[2]:8.3f}{occupancy:6.2f}"
"{tempFactor:6.2f} {segID:<4s}{element:>2s}{charge:.2f}\n"),
"{tempFactor:6.2f} {segID:<4s}{element:>2s}\n"),
'REMARK': "REMARK {0}\n",
'COMPND': "COMPND {0}\n",
'HEADER': "HEADER {0}\n",
Expand Down Expand Up @@ -1130,7 +1120,6 @@ def _write_timestep(self, ts, multiframe=False):
vals['tempFactor'] = temp if temp is not None else 0.0
vals['segID'] = segid[:4]
vals['element'] = guess_atom_element(atom.name.strip())[:2]
vals['charge'] = 0

# .. _ATOM: http://www.wwpdb.org/documentation/format32/sect9.html
self.pdbfile.write(self.fmt['ATOM'].format(**vals))
Expand Down
4 changes: 2 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -739,5 +739,5 @@ def test_atomname_alignment(self):

def test_atomtype_alignment(self):
result_line = ("ATOM 1 H5T GUA R 1 7.974 6.430 9.561"
" 1.00 0.00 RNAA H0.00\n")
assert_equal(result_line, self.writtenstuff[4])
" 1.00 0.00 RNAA H\n")
assert_equal(self.writtenstuff[4], result_line)

0 comments on commit 41c86ed

Please sign in to comment.