Skip to content

Commit

Permalink
Deprecates using segid for chainid (#3173)
Browse files Browse the repository at this point in the history
Towards #3144 

# Work done in this PR
- Deprecates the use of segid as the input for chain ID in the PDB writer.
  • Loading branch information
lilyminium authored Mar 22, 2021
1 parent eb73468 commit 9a03aec
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 @@ -31,6 +31,8 @@ Changes
* Maximum pinned versions in setup.py removed for python 3.6+ (PR #3139)

Deprecations
* 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 9a03aec

Please sign in to comment.