Skip to content

Commit

Permalink
Rename IMP.mmcif.Convert to IMP.mmcif.Writer
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Dec 15, 2023
1 parent b0a95f5 commit 5dec78e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion modules/mmcif/pyext/src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __getitem__(self, ind):
return "".join(reversed(ids))


class Convert(object):
class Writer(object):
"""Convert one or more IMP Models and/or RMF frames to mmCIF
or BinaryCIF.
Expand Down
2 changes: 1 addition & 1 deletion modules/mmcif/test/standards_exceptions
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
value_object_exceptions=[]
function_name_exceptions=['System.report', 'Convert.report']
function_name_exceptions=['System.report', 'Writer.report']
show_exceptions=[]
spelling_exceptions=['rmf']
50 changes: 25 additions & 25 deletions modules/mmcif/test/test_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_parse_sel_tuple(self):
m = IMP.Model()
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])

all_foo = c._parse_sel_tuple("foo")
Expand All @@ -93,7 +93,7 @@ def test_no_chains(self):
"""Trying to add a Hierarchy with no chains should give an error"""
m = IMP.Model()
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
self.assertIsNone(c.system.title)
self.assertRaises(ValueError, c.add_model, [top], [])

Expand All @@ -103,7 +103,7 @@ def test_no_state_node(self):
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
top.set_name("Top node")
self.add_chains(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
self.assertEqual([x.description for x in c.system.entities],
['foo', 'baz'])
Expand Down Expand Up @@ -131,7 +131,7 @@ def test_dna_rna(self):
chain1 = top.get_child(1).get_child(0)
self.assertTrue(IMP.atom.Chain.get_is_setup(chain1))
IMP.atom.Chain(chain1).set_chain_type(IMP.atom.DNA)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
self.assertIsInstance(c.system.entities[0].sequence[0],
ihm.RNAChemComp)
Expand All @@ -145,7 +145,7 @@ def test_duplicate_chain_ids(self):
top.set_name("Top node")
self.add_chains(m, top,
chains = (('foo', 'ACGT', 'X'), ('baz', 'ACCT', 'X')))
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
self.assertEqual([x.id for x in c.system.asym_units],
['A', 'B'])
Expand All @@ -158,7 +158,7 @@ def test_duplicate_molecule_names(self):
self.add_chains(m, top,
chains = (('foo', 'ACGT', 'X'), ('foo', 'ACCT', 'Y'),
('foo', 'ACGT', 'Z')))
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
self.assertEqual([x.id for x in c.system.asym_units],
['X', 'Y', 'Z'])
Expand Down Expand Up @@ -188,7 +188,7 @@ def make_rmf(fname):
fname = self.get_tmp_file_name("test_add_rmf.rmf3")
make_rmf(fname)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_rmf(fname)
self.assertEqual(len(c.system.entities), 2)
self.assertEqual(len(c.system.asym_units), 3)
Expand All @@ -203,7 +203,7 @@ def test_two_states(self):
self.add_chains(m, state0)
state1 = self.add_state(m, top, 1, "State_1")
self.add_chains(m, state1)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
# Entities/asyms should not be duplicated
self.assertEqual([x.description for x in c.system.entities],
Expand All @@ -229,16 +229,16 @@ def test_filter_states(self):
self.add_chains(m, state1)

# No filtering -> two states
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
self.assertEqual(len(c.system.state_groups[0]), 2)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [], states=["State_0"])
self.assertEqual(len(c.system.state_groups[0]), 1)

# No states selected (and so no groups either)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [], states=["State_99"])
self.assertEqual(len(c.system.state_groups), 0)

Expand All @@ -248,24 +248,24 @@ def test_group_ensembles(self):
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
c.add_model([top], [])
# No grouping -> ensemble for each model
self.assertEqual(len(c.system.ensembles), 2)

# Group into single ensemble
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
ens = c.add_model([top], [])
c.add_model([top], [], ensembles=ens)
self.assertEqual(len(c.system.ensembles), 1)

def test_write(self):
"""Test Convert.write() method"""
"""Test Writer.write() method"""
m = IMP.Model()
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
fname = 'test_write.cif'
c.write(fname)
Expand All @@ -276,12 +276,12 @@ def test_write(self):
os.unlink(fname)

def test_report(self):
"""Test Convert.report() method"""
"""Test Writer.report() method"""
sio = StringIO()
m = IMP.Model()
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
c.report(sio)

Expand All @@ -307,7 +307,7 @@ def test_sampcon_ensemble(self):
self.add_protocol(m, state0, sampcon=True)

for top in (top1, top2, top3):
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])

e, = c.system.ensembles
Expand Down Expand Up @@ -350,7 +350,7 @@ def add_software(m, top):
add_software(m, state0)

for top in (top1, top2, top3):
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])

soft, = c.system.software
Expand Down Expand Up @@ -385,7 +385,7 @@ def add_script(m, top):
add_script(m, state0)

for top in (top1, top2, top3):
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])

loc, = c.system.locations
Expand All @@ -400,7 +400,7 @@ def test_same_assembly(self):
top2 = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top2)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top1, top2], [])
self.assertEqual(len(c.system.orphan_assemblies), 1)
self.assertEqual(len(c.system.orphan_assemblies[0]), 3)
Expand All @@ -415,7 +415,7 @@ def test_different_assembly(self):
self.add_chains(m, top2,
chains = (('foo', 'ACGT', 'X'), ('bar', 'ACGT', 'Y')))

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top1, top2], [])
self.assertEqual(len(c.system.orphan_assemblies), 2)
self.assertEqual(len(c.system.orphan_assemblies[0]), 3)
Expand All @@ -426,7 +426,7 @@ def test_model_creation(self):
m = IMP.Model()
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
chain0 = top.get_child(0).get_child(0)
self.assertTrue(IMP.atom.Chain.get_is_setup(chain0))
# Test that IMP residue numbering (11-14) maps to IHM (1-4)
Expand Down Expand Up @@ -510,7 +510,7 @@ def test_starting_models(self):
frag.add_child(residue)
chain1.add_child(frag)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])
# Both models should have same representation, with same starting model
state0_model, = c.system.state_groups[0][0][0]
Expand All @@ -525,7 +525,7 @@ def test_em3d_restraint(self):
top = IMP.atom.Hierarchy.setup_particle(IMP.Particle(m))
self.add_chains(m, top)
self.add_protocol(m, top)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
chain0 = top.get_child(0).get_child(0)
r1 = self.add_structured_residue(m, chain0, 1)
self.add_structured_residue(m, chain0, 2)
Expand Down
26 changes: 13 additions & 13 deletions modules/mmcif/test/test_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_software_dumper(self):
m = IMP.Model()
h = self.make_model(m)
IMP.core.add_imp_provenance(h)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [], name="model1")

# Assign ID to IMP citation
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_assembly_all_modeled(self):
self.add_structured_residue(m, chain2, 3)
self.add_structured_residue(m, chain3, 1)
self.add_structured_residue(m, chain3, 2)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [])

foo, bar, baz = c.system.asym_units
Expand Down Expand Up @@ -235,7 +235,7 @@ def test_model_representation_dumper(self):
frag1 = IMP.atom.Fragment.setup_particle(IMP.Particle(m), [3, 4])
self.add_structure(frag1)
chain.add_child(frag1)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [])

self._assign_entity_ids(c)
Expand Down Expand Up @@ -336,7 +336,7 @@ def _internal_test_starting_model_dumper(self, cif):
h2 = self._make_residue_chain('Nup85', 'B', m)
state2h.add_child(h2)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([top], [])

self._assign_entity_ids(c)
Expand Down Expand Up @@ -413,7 +413,7 @@ def test_workflow(self):
prov = IMP.core.ScriptProvenance.setup_particle(m, IMP.Particle(m),
__file__)
IMP.core.add_provenance(m, h, prov)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [], name="model1")

root = os.path.dirname(__file__)
Expand Down Expand Up @@ -451,7 +451,7 @@ def test_modeling_protocol(self):
"""Test ProtocolDumper"""
m = IMP.Model()
h = self.make_model_with_protocol(m)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [], name="model1")

self._assign_entity_ids(c)
Expand Down Expand Up @@ -498,7 +498,7 @@ def test_post_process(self):
"""Test PostProcessDumper"""
m = IMP.Model()
h = self.make_model_with_protocol(m)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [], name="model1")

self._assign_entity_ids(c)
Expand Down Expand Up @@ -534,7 +534,7 @@ def test_ensemble_info(self):
"""Test EnsembleDumper"""
m = IMP.Model()
h = self.make_model(m)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
ens = c.add_model([h], [], name="model1")
ens[None].name = 'cluster 1'

Expand Down Expand Up @@ -567,7 +567,7 @@ def test_model_list(self):
"""Test ModelListDumper"""
m = IMP.Model()
h = self.make_model(m)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
ens = c.add_model([h], [], name="model1")
ens[None].model_group.name = 'cluster 1'
c.add_model([h], [], name="model2", ensembles=ens)
Expand Down Expand Up @@ -615,7 +615,7 @@ def test_em3d_dumper(self):
em_filename = self.get_input_file_name('test.gmm.txt')
r = MockGaussianEMRestraint(m, em_filename, [res1.get_particle()])
r.set_was_used(True)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [r], name="model1")

# Assign dataset ID (=2 since the gmm is derived from an MRC)
Expand Down Expand Up @@ -668,7 +668,7 @@ def test_site_dumper_spheres_only(self):
xyzr.set_radius(9.2)
chains[1].add_child(pfrag)

c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
ens = c.add_model([h], [], name="model1")
ens[None].model_group.name = 'cluster 1'

Expand Down Expand Up @@ -725,7 +725,7 @@ def test_no_localization_densities(self):
"""Test DensityDumper with no density information"""
m = IMP.Model()
h = self.make_model_with_protocol(m)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
c.add_model([h], [], name="model1")

dumper = ihm.dumper._DensityDumper()
Expand All @@ -737,7 +737,7 @@ def test_sampcon_localization_densities(self):
"""Test DensityDumper with IMP.sampcon output"""
m = IMP.Model()
h = self.make_model_with_protocol(m, sampcon=True)
c = IMP.mmcif.Convert()
c = IMP.mmcif.Writer()
ens = c.add_model([h], [], name="model1")
e = ens[None]

Expand Down
2 changes: 1 addition & 1 deletion modules/mmcif/test/test_restraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def test_all_restraints_saxs(self):

def test_all_restraints_cross_link(self):
"""Test _AllRestraints with cross-link restraint"""
conv = IMP.mmcif.Convert()
conv = IMP.mmcif.Writer()
m = IMP.Model()
h = make_model(m, chains=[("Rpb1", "AMT", "X"),
("Rpb2", "ACC", "Z")])
Expand Down

0 comments on commit 5dec78e

Please sign in to comment.