Skip to content

Commit

Permalink
Fix charge reading from PDBQTParser
Browse files Browse the repository at this point in the history
  • Loading branch information
pgbarletta committed Sep 21, 2023
1 parent 0b9bfd5 commit f783ed0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Fixes
* Fixes a case where qcprot.CalcRMSDRotationalMatrix would return a
RMSD of None
* Fixes hydrogenbonds tutorial path to point to hbonds (Issue #4285, PR #4286)
* Fix atom charge reading in PDBQT parser (Issue #4282, PR #4283)

Enhancements
* Updated lib.qcprot.CalcRMSDRotationalMatrix to accept either float32 or float64
Expand Down
3 changes: 2 additions & 1 deletion package/MDAnalysis/coordinates/PDBQT.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ class PDBQTReader(base.SingleFrameReaderBase):
47 - 54 Real(8.3) z Orthogonal coordinates for Z in Angstroms.
55 - 60 Real(6.2) occupancy Occupancy.
61 - 66 Real(6.2) tempFactor Temperature factor.
67 - 76 Real(10.4) partialChrg Gasteiger PEOE partial charge *q*.
67 - 70 LString(4) footnote Usually blank. IGNORED.
71 - 76 Real(6.4) partialChrg Gasteiger PEOE partial charge *q*.
79 - 80 LString(2) atomType AutoDOCK atom type *t*.
============= ============ =========== =============================================
Expand Down
8 changes: 6 additions & 2 deletions package/MDAnalysis/topology/PDBQTParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ class PDBQTParser(TopologyReaderBase):
- charges
Guesses the following:
- elements
- masses
.. versionchanged:: 0.18.0
Added parsing of Record types
.. versionchanged:: 2.7.0
Columns 67 - 70 in ATOM records, corresponding to the field *footnote*,
are now ignored. See Autodock's `reference`_.
.. _reference: https://autodock.scripps.edu/wp-content/uploads/sites/56/2021/10/AutoDock4.2.6_UserGuide.pdf
"""
format = 'PDBQT'

Expand Down Expand Up @@ -141,7 +145,7 @@ def parse(self, **kwargs):
icodes.append(line[26:27].strip())
occupancies.append(float(line[54:60]))
tempfactors.append(float(line[60:66]))
charges.append(float(line[66:76]))
charges.append(float(line[70:76]))
atomtypes.append(line[77:80].strip())

n_atoms = len(serials)
Expand Down
Binary file added testsuite/MDAnalysisTests/data/tyrosol.pdbqt.bz2
Binary file not shown.
2 changes: 2 additions & 0 deletions testsuite/MDAnalysisTests/datafiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"PQR_icodes", # PQR v2 with icodes
"PDBQT_input", # PDBQT
"PDBQT_querypdb",
"PDBQT_tyrosol",
"PDB_multipole",
"FASTA", # sequence alignment, Issue 112 + 113
"HELANAL_BENDING_MATRIX", # HELANAL test (from PSF+DCD (AdK) helix 8)
Expand Down Expand Up @@ -476,6 +477,7 @@

PDBQT_input = (_data_ref / 'pdbqt_inputpdbqt.pdbqt').as_posix()
PDBQT_querypdb = (_data_ref / 'pdbqt_querypdb.pdb').as_posix()
PDBQT_tyrosol = (_data_ref / 'tyrosol.pdbqt.bz2').as_posix()

FASTA = (_data_ref / 'test.fasta').as_posix()
HELANAL_BENDING_MATRIX = (_data_ref / 'helanal_bending_matrix_AdK_DIMS_H8.dat').as_posix()
Expand Down
7 changes: 7 additions & 0 deletions testsuite/MDAnalysisTests/topology/test_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from MDAnalysisTests.topology.base import ParserBase
from MDAnalysisTests.datafiles import (
PDBQT_input, # pdbqt_inputpdbqt.pdbqt
PDBQT_tyrosol, # tyrosol.pdbqt.bz2
)


Expand All @@ -50,3 +51,9 @@ class TestPDBQT(ParserBase):
expected_n_atoms = 1805
expected_n_residues = 199 # resids go 2-102 then 2-99
expected_n_segments = 2 # res2-102 are A, 2-99 are B

def test_footnote():
"""just test that the Universe is built even in the presence of a
footnote before the charges.
"""
mda.Universe(PDBQT_tyrosol)

0 comments on commit f783ed0

Please sign in to comment.