diff --git a/package/CHANGELOG b/package/CHANGELOG index 9ad50f42a0..1bb3abfd04 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -35,7 +35,9 @@ Enhancements `DielectricConstant` (Issue #4262, PR #4263) * Add support for reading chainID info from prmtop amber topologies (PR #4007) * Add support for reading chainID info from GROMACS TPR topologies - (Issue #3994, PR #4281) + (Issue #3994, PR #4281) + * Add support for reading chainID info from Autodock PDBQT files (Issue #4207, + PR #4284) Changes * The `mda-xdrlib` module is now a core dependency of MDAnalysis diff --git a/package/MDAnalysis/topology/PDBQTParser.py b/package/MDAnalysis/topology/PDBQTParser.py index b8a806e0c2..eeebc889e2 100644 --- a/package/MDAnalysis/topology/PDBQTParser.py +++ b/package/MDAnalysis/topology/PDBQTParser.py @@ -75,6 +75,7 @@ Resnums, Resnames, Segids, + ChainIDs, Tempfactors, ) @@ -88,7 +89,7 @@ class PDBQTParser(TopologyReaderBase): - atom names - altLocs - resnames - - chainIDs (becomes segid) + - chainIDs (assigned to segid as well) - resids - record_types (ATOM/HETATM) - icodes @@ -166,6 +167,8 @@ def parse(self, **kwargs): resnames = np.array(resnames, dtype=object) chainids = np.array(chainids, dtype=object) + attrs.append(ChainIDs(chainids)) + residx, (resids, icodes, resnames, chainids) = change_squash( (resids, icodes), (resids, icodes, resnames, chainids)) n_residues = len(resids) diff --git a/testsuite/MDAnalysisTests/coordinates/test_pdbqt.py b/testsuite/MDAnalysisTests/coordinates/test_pdbqt.py index 2c169da988..6b07c4818e 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_pdbqt.py +++ b/testsuite/MDAnalysisTests/coordinates/test_pdbqt.py @@ -39,11 +39,17 @@ def universe(self): return mda.Universe(PDBQT_input) def test_segid(self, universe): - sel = universe.select_atoms('segid A') + sel = universe.select_atoms("segid A") assert_equal(sel.n_atoms, 909, "failed to select segment A") - sel = universe.select_atoms('segid B') + sel = universe.select_atoms("segid B") assert_equal(sel.n_atoms, 896, "failed to select segment B") + def test_chainID(self, universe): + sel = universe.select_atoms("chainID A") + assert_equal(sel.n_atoms, 909, "failed to chainID segment A") + sel = universe.select_atoms("chainID B") + assert_equal(sel.n_atoms, 896, "failed to chainID segment B") + def test_protein(self, universe): sel = universe.select_atoms('protein') assert_equal(sel.n_atoms, 1805, "failed to select protein") diff --git a/testsuite/MDAnalysisTests/topology/test_pdbqt.py b/testsuite/MDAnalysisTests/topology/test_pdbqt.py index 4d2c94b9a7..2127617da0 100644 --- a/testsuite/MDAnalysisTests/topology/test_pdbqt.py +++ b/testsuite/MDAnalysisTests/topology/test_pdbqt.py @@ -32,8 +32,19 @@ class TestPDBQT(ParserBase): parser = mda.topology.PDBQTParser.PDBQTParser ref_filename = PDBQT_input expected_attrs = [ - 'ids', 'names', 'charges', 'types', 'altLocs', 'resids', 'resnames', - 'segids', 'record_types', 'icodes', 'occupancies', 'tempfactors' + "ids", + "names", + "charges", + "types", + "altLocs", + "resids", + "resnames", + "segids", + "chainIDs", + "record_types", + "icodes", + "occupancies", + "tempfactors", ] guessed_attrs = ['masses'] expected_n_atoms = 1805