Skip to content

Commit

Permalink
Merge branch 'master' into issue-2327-warn
Browse files Browse the repository at this point in the history
  • Loading branch information
IAlibay authored Mar 24, 2021
2 parents 915e354 + 9a03aec commit 9151cd3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions package/MDAnalysis/coordinates/PDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
9 changes: 9 additions & 0 deletions testsuite/MDAnalysisTests/coordinates/test_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

0 comments on commit 9151cd3

Please sign in to comment.