From f783ed0df373804a7c0122b18452e1499ca122aa Mon Sep 17 00:00:00 2001 From: pgbarletta Date: Wed, 20 Sep 2023 21:00:52 -0300 Subject: [PATCH] Fix charge reading from PDBQTParser --- package/CHANGELOG | 1 + package/MDAnalysis/coordinates/PDBQT.py | 3 ++- package/MDAnalysis/topology/PDBQTParser.py | 8 ++++++-- testsuite/MDAnalysisTests/data/tyrosol.pdbqt.bz2 | Bin 0 -> 590 bytes testsuite/MDAnalysisTests/datafiles.py | 2 ++ testsuite/MDAnalysisTests/topology/test_pdbqt.py | 7 +++++++ 6 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 testsuite/MDAnalysisTests/data/tyrosol.pdbqt.bz2 diff --git a/package/CHANGELOG b/package/CHANGELOG index 1bb3abfd047..ffddbb0df54 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -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 diff --git a/package/MDAnalysis/coordinates/PDBQT.py b/package/MDAnalysis/coordinates/PDBQT.py index c2523618b9a..41c1e97fc93 100644 --- a/package/MDAnalysis/coordinates/PDBQT.py +++ b/package/MDAnalysis/coordinates/PDBQT.py @@ -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*. ============= ============ =========== ============================================= diff --git a/package/MDAnalysis/topology/PDBQTParser.py b/package/MDAnalysis/topology/PDBQTParser.py index eeebc889e2b..81a902fdcd8 100644 --- a/package/MDAnalysis/topology/PDBQTParser.py +++ b/package/MDAnalysis/topology/PDBQTParser.py @@ -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' @@ -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) diff --git a/testsuite/MDAnalysisTests/data/tyrosol.pdbqt.bz2 b/testsuite/MDAnalysisTests/data/tyrosol.pdbqt.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..7a900995bb75d745b5128fd3177f3a013692bbb0 GIT binary patch literal 590 zcmV-U0XTi3jxZ%?w6rlLM-qgi zN{lj}d%(D?!yz;ngf_v-a-%R@y` ciqGXxMAij4>`o1pUf<&GNT&)C8ZW)ZfSJ7mq5uE@ literal 0 HcmV?d00001 diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 25e85618afe..9a0c03561d4 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -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) @@ -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() diff --git a/testsuite/MDAnalysisTests/topology/test_pdbqt.py b/testsuite/MDAnalysisTests/topology/test_pdbqt.py index 2127617da05..f603400d9bc 100644 --- a/testsuite/MDAnalysisTests/topology/test_pdbqt.py +++ b/testsuite/MDAnalysisTests/topology/test_pdbqt.py @@ -25,6 +25,7 @@ from MDAnalysisTests.topology.base import ParserBase from MDAnalysisTests.datafiles import ( PDBQT_input, # pdbqt_inputpdbqt.pdbqt + PDBQT_tyrosol, # tyrosol.pdbqt.bz2 ) @@ -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) \ No newline at end of file