Skip to content

Commit e6ddb85

Browse files
csbiypeterjc
authored andcommitted
Silence PDBConstructionWarning in test_PDB_StructureAlignment
Wrap PDB structure parsing calls with warnings.catch_warnings() to suppress PDBConstructionWarning messages during test execution. This follows the same pattern used in other test files such as test_PDB_MMCIFParser.py, test_mmtf_online.py, and test_RCSBFormats.py. Fixes #1877
1 parent d952922 commit e6ddb85

1 file changed

Lines changed: 18 additions & 8 deletions

File tree

Tests/test_PDB_StructureAlignment.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import os
1313
import unittest
14+
import warnings
1415

1516
from Bio import Align
1617
from Bio import AlignIO
@@ -19,6 +20,7 @@
1920
from Bio.Data import PDBData
2021
from Bio.PDB import PDBParser
2122
from Bio.PDB import StructureAlignment
23+
from Bio.PDB.PDBExceptions import PDBConstructionWarning
2224
from Bio.PDB.Selection import unfold_entities
2325
from Bio.PDB.Polypeptide import is_aa
2426
from Bio.Seq import Seq
@@ -42,8 +44,10 @@ def test_StructAlign(self):
4244
with open(al_file) as handle:
4345
alignment = Align.read(handle, "fasta")
4446

45-
s1 = p.get_structure("1", "PDB/2XHE.pdb")
46-
s2 = p.get_structure("2", "PDB/1A8O.pdb")
47+
with warnings.catch_warnings():
48+
warnings.simplefilter("ignore", PDBConstructionWarning)
49+
s1 = p.get_structure("1", "PDB/2XHE.pdb")
50+
s2 = p.get_structure("2", "PDB/1A8O.pdb")
4751
m1 = s1[0]
4852
m2 = s2[0]
4953

@@ -70,8 +74,10 @@ def test_msa_vs_alignment_objects(self):
7074
"""
7175
p = PDBParser(QUIET=1)
7276

73-
s1 = p.get_structure("1", "PDB/2XHE.pdb")
74-
s2 = p.get_structure("2", "PDB/1A8O.pdb")
77+
with warnings.catch_warnings():
78+
warnings.simplefilter("ignore", PDBConstructionWarning)
79+
s1 = p.get_structure("1", "PDB/2XHE.pdb")
80+
s2 = p.get_structure("2", "PDB/1A8O.pdb")
7581
m1 = s1[0]
7682
m2 = s2[0]
7783

@@ -122,8 +128,10 @@ def test_custom_vs_automatic_alignment(self):
122128

123129
p = PDBParser(QUIET=1)
124130

125-
s1 = p.get_structure("1", "PDB/2XHE.pdb")
126-
s2 = p.get_structure("2", "PDB/1A8O.pdb")
131+
with warnings.catch_warnings():
132+
warnings.simplefilter("ignore", PDBConstructionWarning)
133+
s1 = p.get_structure("1", "PDB/2XHE.pdb")
134+
s2 = p.get_structure("2", "PDB/1A8O.pdb")
127135
m1 = s1[0]
128136
m2 = s2[0]
129137

@@ -192,8 +200,10 @@ def test_automatic_alignment_generation(self):
192200
"""
193201
p = PDBParser(QUIET=1)
194202

195-
s1 = p.get_structure("1", "PDB/2XHE.pdb")
196-
s2 = p.get_structure("2", "PDB/1A8O.pdb")
203+
with warnings.catch_warnings():
204+
warnings.simplefilter("ignore", PDBConstructionWarning)
205+
s1 = p.get_structure("1", "PDB/2XHE.pdb")
206+
s2 = p.get_structure("2", "PDB/1A8O.pdb")
197207
m1 = s1[0]
198208
m2 = s2[0]
199209

0 commit comments

Comments
 (0)