Skip to content

Commit

Permalink
Handle unnamed components
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Sep 15, 2023
1 parent 35fead7 commit 6bbfeae
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion modules/mmcif/pyext/src/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 5 additions & 1 deletion modules/mmcif/test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down

0 comments on commit 6bbfeae

Please sign in to comment.