diff --git a/package/CHANGELOG b/package/CHANGELOG index c1a8e12b6f7..aca247fe2e5 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -33,6 +33,8 @@ Changes Deprecations * NCDFWriter `scale_factor` writing will change in version 2.0 to better match AMBER outputs (Issue #2327) + * Deprecated using the last letter of the segid as the + chainID when writing PDB files (Issue #3144) * Deprecated tempfactors and bfactors being separate TopologyAttrs, with a warning (PR #3161) * hbonds.WaterBridgeAnalysis will be removed in 2.0.0 and diff --git a/package/MDAnalysis/coordinates/PDB.py b/package/MDAnalysis/coordinates/PDB.py index 649bde13808..41729102ce8 100644 --- a/package/MDAnalysis/coordinates/PDB.py +++ b/package/MDAnalysis/coordinates/PDB.py @@ -858,6 +858,10 @@ def write(self, obj): The :class:`~MDAnalysis.core.groups.AtomGroup` or :class:`~MDAnalysis.core.universe.Universe` to write. """ + warnings.warn("Using the last letter of the segid for the chainID " + "is now deprecated and will be changed in 2.0. " + "In 2.0, the chainID attribute will be used if it " + "exists, or a placeholder value.", DeprecationWarning) self._update_frame(obj) self._write_pdb_header() diff --git a/testsuite/MDAnalysisTests/coordinates/test_pdb.py b/testsuite/MDAnalysisTests/coordinates/test_pdb.py index 0c20fb59e23..899d3e623d5 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_pdb.py +++ b/testsuite/MDAnalysisTests/coordinates/test_pdb.py @@ -1042,3 +1042,12 @@ def test_cryst_meaningless_select(): u = mda.Universe(PDB_CRYOEM_BOX) cur_sele = u.select_atoms('around 0.1 (resid 4 and name CA and segid A)') assert cur_sele.n_atoms == 0 + + +def test_deprecated_chainid_from_segid(tmpdir): + u = mda.Universe(PDB) + err = ("Using the last letter of the segid for the chainID " + "is now deprecated and will be changed in 2.0. ") + with tmpdir.as_cwd(): + with pytest.warns(DeprecationWarning, match=err): + u.atoms.write("test.pdb")