diff --git a/modules/mmcif/pyext/src/data.py b/modules/mmcif/pyext/src/data.py index 53b8fbfac0..688496fc8c 100644 --- a/modules/mmcif/pyext/src/data.py +++ b/modules/mmcif/pyext/src/data.py @@ -199,7 +199,9 @@ def add(self, chain, entity): self._used_entities.add(entity) # Assign entity name from the component; strip out anything # after a @ or . - entity.description = component.name.split("@")[0].split(".")[0] + if component.name: + entity.description = \ + component.name.split("@")[0].split(".")[0] self._all_components.append(component) if modeled: asym = ihm.AsymUnit(entity, name, id=asym_id) diff --git a/modules/mmcif/test/test_data.py b/modules/mmcif/test/test_data.py index 2104e85c73..94764a85fe 100644 --- a/modules/mmcif/test/test_data.py +++ b/modules/mmcif/test/test_data.py @@ -98,13 +98,17 @@ def test_entity_naming(self): system = ihm.System() cm = IMP.mmcif.data._ComponentMapper(system) entity1 = ihm.Entity("ANC") + entity2 = ihm.Entity("AC") chain1 = MockChain("A.1@12") chain2 = MockChain("A.2@12") + chain3 = MockChain(None) comp1 = cm.add(chain1, entity1) comp2 = cm.add(chain2, entity1) + comp3 = cm.add(chain3, entity2) self.assertEqual(chain1.name, "A.1@12") self.assertEqual(chain2.name, "A.2@12") - self.assertEqual(entity1.description, 'A') + self.assertIsNone(chain3.name) + self.assertIsNone(entity2.description) def test_component_mapper_same_id_chain(self): """Test ComponentMapper given two chains with same ID"""