diff --git a/modelcif/__init__.py b/modelcif/__init__.py index 533a64f..6258518 100644 --- a/modelcif/__init__.py +++ b/modelcif/__init__.py @@ -76,7 +76,6 @@ def __init__(self, title=None, id='model', database=None, self.entities = [] self.asym_units = [] - self.target_entities = [] self.templates = [] self.template_segments = [] self.template_transformations = [] @@ -109,8 +108,6 @@ def _before_write(self): self.entities = list(_remove_identical(self._all_entities())) self.template_transformations = list(_remove_identical( self._all_template_transformations())) - self.target_entities = list(_remove_identical( - self._all_target_entities())) self.data_groups = list(_remove_identical( self._all_data_groups())) self.data = list(_remove_identical( @@ -124,7 +121,7 @@ def _before_write(self): def _add_missing_reference_sequence(self): """If any TargetReference has no sequence, use that of the Entity""" - for e in self.entities + self.target_entities: + for e in self.entities: for r in e.references: if r.sequence is None: r.sequence = "".join(comp.code_canonical @@ -160,13 +157,6 @@ def _all_citations(self): (software.citation for software in self._all_software() if software.citation))) - def _all_target_entities(self): - """Iterate over all Entities that are used for targets rather than - templates.""" - return (itertools.chain( - self.target_entities, - (asym.entity for asmb in self.assemblies for asym in asmb))) - def _all_software(self): """Utility method used by ihm.dumper to get all Software. To initially populate this list from all Software referenced in the system, @@ -223,7 +213,6 @@ def _all_asym_in_assemblies(): self.asym_units, _all_asym_in_assemblies()) def _all_entities(self): - # Note that template entities are not included by default return itertools.chain( self.entities, (asym.entity for asym in self.asym_units)) @@ -250,7 +239,7 @@ def _all_data_in_files(): return itertools.chain( self.data, self.templates, - self.target_entities, + self.entities, self.alignments, (model for group, model in self._all_models()), _all_data_in_groups(), diff --git a/modelcif/dumper.py b/modelcif/dumper.py index 6395f54..ffde320 100644 --- a/modelcif/dumper.py +++ b/modelcif/dumper.py @@ -103,10 +103,6 @@ def dump(self, system, writer): class _TargetRefDBDumper(Dumper): def dump(self, system, writer): - # Since target_entities is a *subset* of all entities, they may not - # be ordered by ID. Sort them so the output is prettier. - entities = sorted(system.target_entities, - key=operator.attrgetter('_id')) with writer.loop( "_ma_target_ref_db_details", ["target_entity_id", "db_name", "db_name_other_details", @@ -115,7 +111,7 @@ def dump(self, system, writer): "ncbi_taxonomy_id", "organism_scientific", "seq_db_sequence_version_date", "seq_db_sequence_checksum"]) as lp: - for e in entities: + for e in system.entities: for r in e.references: if r.align_begin is None: db_begin = min(a.db_begin for a in r._get_alignments()) @@ -167,12 +163,10 @@ def dump(self, system, writer): class _TargetEntityDumper(Dumper): def dump(self, system, writer): - entities = sorted(system.target_entities, - key=operator.attrgetter('_id')) with writer.loop( "_ma_target_entity", ["entity_id", "data_id", "origin"]) as lp: - for e in entities: + for e in system.entities: lp.write(entity_id=e._id, data_id=e._data_id, origin="reference database" if e.references else "designed") diff --git a/test/test_dumper.py b/test/test_dumper.py index 4325a22..189e700 100644 --- a/test/test_dumper.py +++ b/test/test_dumper.py @@ -173,7 +173,7 @@ def test_data_dumper(self): """Test DataDumper""" system = modelcif.System() entity = modelcif.Entity("DMA", description='test entity') - system.target_entities.append(entity) + system.entities.append(entity) # Template and target use same entity here (but different data IDs) template = modelcif.Template( entity, asym_id="A", model_num=1, name="test template", @@ -206,7 +206,7 @@ def test_data_group_dumper(self): tgt_e1._data_id = 1 tgt_e2._data_id = 2 tgt_e3._data_id = 3 - system.target_entities.extend((tgt_e1, tgt_e2, tgt_e3)) + system.entities.extend((tgt_e1, tgt_e2, tgt_e3)) dg12 = modelcif.data.DataGroup((tgt_e1, tgt_e2)) p = modelcif.protocol.Protocol() p.steps.append(modelcif.protocol.ModelingStep( @@ -516,7 +516,7 @@ class CustomRef(modelcif.reference.TargetReference): e1 = modelcif.Entity('ACGT', references=[ref1, ref2, ref3, ref4, ref5]) e1._id = 1 - system.target_entities.append(e1) + system.entities.append(e1) dumper = modelcif.dumper._TargetRefDBDumper() dumper.finalize(system) @@ -844,7 +844,7 @@ def test_target_entity_dumper(self): e1 = modelcif.Entity("D") e1._id = 42 e1._data_id = 99 - system.target_entities.append(e1) + system.entities.append(e1) a1 = modelcif.AsymUnit(e1, 'foo') a1._id = 'X' diff --git a/test/test_main.py b/test/test_main.py index d0d1670..3eb6a50 100644 --- a/test/test_main.py +++ b/test/test_main.py @@ -17,7 +17,7 @@ def test_all_data(self): s = modelcif.System() e1 = modelcif.Entity("D") e2 = modelcif.Entity("M") - s.target_entities.extend((e1, e2)) + s.entities.extend((e1, e2)) e3 = modelcif.Entity("A") s.data.extend((e1, e3)) @@ -86,24 +86,6 @@ def test_all_data_groups(self): d = s._all_data_groups() self.assertEqual(list(d), [e1, e1, e2]) - def test_all_target_entities(self): - """Test _all_target_entities() method""" - s = modelcif.System() - e1 = modelcif.Entity("D") - e2 = modelcif.Entity("M") - s.target_entities.extend((e1, e2)) - - template_e = modelcif.Entity("M") - s.entities.extend((e1, e2, template_e)) - - asym = modelcif.AsymUnit(e1, 'foo') - s.asym_units.append(asym) - s.assemblies.append(modelcif.Assembly((asym,))) - - te = s._all_target_entities() - # List may contain duplicates, but no template entities - self.assertEqual(list(te), [e1, e2, e1]) - def test_all_template_transformations(self): """Test _all_template_transformations() method""" s = modelcif.System()