Unverified Commit 4d4e349b authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2423 from JoaoRodrigues/fix_pdbx_writer_inscode

Fixes writing PDBx/mmCIF files with blank residue insertion codes.
parents df12b67a 25ff85b7
...@@ -397,7 +397,7 @@ class PDBxFile(object): ...@@ -397,7 +397,7 @@ class PDBxFile(object):
for (resIndex, res) in enumerate(residues): for (resIndex, res) in enumerate(residues):
if keepIds: if keepIds:
resId = res.id resId = res.id
resIC = (res.insertionCode if len(res.insertionCode) > 0 else '.') resIC = (res.insertionCode if res.insertionCode.strip() else '.')
else: else:
resId = resIndex + 1 resId = resIndex + 1
resIC = '.' resIC = '.'
......
...@@ -12,6 +12,28 @@ else: ...@@ -12,6 +12,28 @@ else:
class TestPdbxFile(unittest.TestCase): class TestPdbxFile(unittest.TestCase):
"""Test the PDBx/mmCIF file parser""" """Test the PDBx/mmCIF file parser"""
def test_FormatConversion(self):
"""Test conversion from PDB to PDBx"""
mol = PDBFile('systems/ala_ala_ala.pdb')
# Write to 'file'
output = StringIO()
PDBxFile.writeFile(mol.topology, mol.positions, output,
keepIds=True)
# Read from 'file'
input = StringIO(output.getvalue())
try:
pdbx = PDBxFile(input)
except Exception:
self.fail('Parser failed to read PDBx/mmCIF file')
# Close file handles
output.close()
input.close()
def test_Triclinic(self): def test_Triclinic(self):
"""Test parsing a file that describes a triclinic box.""" """Test parsing a file that describes a triclinic box."""
pdb = PDBxFile('systems/triclinic.pdbx') pdb = PDBxFile('systems/triclinic.pdbx')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment