diff --git a/modules/mmcif/pyext/src/data.py b/modules/mmcif/pyext/src/data.py index e0f325f3ea..6634708b6b 100644 --- a/modules/mmcif/pyext/src/data.py +++ b/modules/mmcif/pyext/src/data.py @@ -594,15 +594,16 @@ def __init__(self, system): def _add_protocol(self, prot): self.system.orphan_protocols.append(prot) + return prot - def _add_hierarchy(self, h, modeled_assembly, all_software): + def _add_hierarchy(self, h, top_h, modeled_assembly, all_software): num_models = 0 # assume we always start with no models prot_types = (IMP.core.SampleProvenance, IMP.core.CombineProvenance) pp_types = (IMP.core.FilterProvenance, IMP.core.ClusterProvenance) in_postproc = False prot = _Protocol() - for p in reversed(list(IMP.core.get_all_provenance( - h, types=prot_types + pp_types))): + for p in reversed(list(_get_all_state_provenance( + h, top_h, types=prot_types + pp_types))): if isinstance(p, pp_types): num_models = prot.add_postproc(p, num_models, modeled_assembly) in_postproc = True @@ -615,7 +616,7 @@ def _add_hierarchy(self, h, modeled_assembly, all_software): all_software) in_postproc = False if len(prot.steps) > 0: - self._add_protocol(prot) + return self._add_protocol(prot) class _CoordinateHandler(object): diff --git a/modules/mmcif/pyext/src/util.py b/modules/mmcif/pyext/src/util.py index 60b03ba0ac..8bf4df4483 100644 --- a/modules/mmcif/pyext/src/util.py +++ b/modules/mmcif/pyext/src/util.py @@ -177,7 +177,7 @@ def _add_hierarchy(self, h, state): if num_state_reps == 1: self.representation.extend(state.repsegments[component]) self._software.add_hierarchy(h) - self.protocols._add_hierarchy(h, state.modeled_assembly, + self.protocols._add_hierarchy(h, None, state.modeled_assembly, self._software) self._external_files.add_hierarchy(h) @@ -421,6 +421,7 @@ def __init__(self): self._external_files = IMP.mmcif.data._ExternalFiles(self.system) self._model_assemblies = IMP.mmcif.data._ModelAssemblies(self.system) self._representations = IMP.mmcif.data._Representations(self.system) + self._protocols = IMP.mmcif.data._Protocols(self.system) def add_model(self, hiers, restraints, name=None, states=None, ensembles=None): @@ -457,11 +458,17 @@ def _add_hierarchy(self, h, top_h, state, name, ensemble): comp = self._add_chain(c) asyms.append(comp.asym_unit) ch.add_chain(c, comp.asym_unit) - self._representations.add(ch._representation) - self._model_assemblies.add(asyms) + representation = self._representations.add(ch._representation) + assembly = self._model_assemblies.add(asyms) self._add_hierarchy_ensemble_info(h, top_h, ensemble) self._software.add_hierarchy(h, top_h) + protocol = self._protocols._add_hierarchy(h, top_h, assembly, + self._software) self._external_files.add_hierarchy(h, top_h) + model = ihm.model.Model(assembly=assembly, protocol=protocol, + representation=representation) + ensemble.model_group.append(model) + ensemble.num_models += 1 return ensemble def _add_hierarchy_ensemble_info(self, h, top_h, ensemble): diff --git a/modules/mmcif/test/test_data.py b/modules/mmcif/test/test_data.py index 907acee060..d1641b4fe3 100644 --- a/modules/mmcif/test/test_data.py +++ b/modules/mmcif/test/test_data.py @@ -201,7 +201,7 @@ def test_protocols_add_hierarchy(self): prov = IMP.core.SampleProvenance.setup_particle( IMP.Particle(m), "Monte Carlo", 100, 10, 1) IMP.core.add_provenance(m, top, prov) - protocols._add_hierarchy(top, None, software) + protocols._add_hierarchy(top, None, None, software) protocol, = s.orphan_protocols step, = protocol.steps self.assertEqual(step.num_models_begin, 0)