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

Read chainID from PDBQT #4284

Merged
merged 5 commits into from
Sep 16, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 3 additions & 1 deletion package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion package/MDAnalysis/topology/PDBQTParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
Resnums,
Resnames,
Segids,
ChainIDs,
Tempfactors,
)

Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 8 additions & 2 deletions testsuite/MDAnalysisTests/coordinates/test_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 13 additions & 2 deletions testsuite/MDAnalysisTests/topology/test_pdbqt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading