Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/to_mmcif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ void update_mmcif_block(const Structure& st, cif::Block& block, MmcifOutputGroup
}
seq_loop.add_row({std::to_string(++counter2),
std::to_string(counter),
strand_id->second, // pdbx_strand_id
qchain(strand_id->second), // pdbx_strand_id
id,
label_begin.str(),
label_end.str(),
Expand Down
17 changes: 17 additions & 0 deletions tests/test_mol.py
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,23 @@ def test_remove2(self):
ref_seq = doc[0].get_mmcif_category('_struct_ref_seq')
self.assertEqual(ref_seq['pdbx_strand_id'], ['B'])

def test_empty_strand_id_struct_ref_seq(self):
# A blank chain name (e.g. a PDB file with no chain ID) gives an empty
# _struct_ref_seq.pdbx_strand_id. It must be written as a quoted empty
# string (''), not dropped: dropping it leaves the loop row one value
# short, which makes the whole file unreadable.
st = gemmi.read_structure(full_path('1pfe.cif.gz'))
for chain in st[0]:
if chain.name == 'B':
chain.name = ''
doc = st.make_mmcif_document()
strand_ids = doc[0].find_values('_struct_ref_seq.pdbx_strand_id')
self.assertEqual([gemmi.cif.as_string(v) for v in strand_ids], ['A', ''])
# Round-trip: writing then re-reading must not raise on a ragged loop.
reparsed = gemmi.cif.read_string(doc.as_string())
self.assertEqual(reparsed[0].find_values('_struct_ref_seq.pdbx_strand_id')
.str(1), '')

def test_first_conformer(self):
model = gemmi.read_structure(full_path('1pfe.cif.gz'))[0]
b = model['B']
Expand Down
Loading