Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix charge reading from PDBQTParser #4283

Merged
merged 3 commits into from
Oct 15, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 7 additions & 2 deletions package/MDAnalysis/topology/PDBQTParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,16 @@ 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
orbeckst marked this conversation as resolved.
Show resolved Hide resolved
"""
format = 'PDBQT'

Expand Down Expand Up @@ -141,7 +146,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.
6 changes: 4 additions & 2 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 @@ -474,8 +475,9 @@
PQR = (_data_ref / 'adk_open.pqr').as_posix()
PQR_icodes = (_data_ref / '1A2C.pqr').as_posix()

PDBQT_input = (_data_ref / 'pdbqt_inputpdbqt.pdbqt').as_posix()
PDBQT_querypdb = (_data_ref / 'pdbqt_querypdb.pdb').as_posix()
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
8 changes: 8 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,10 @@ 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)