def _do_test_round_trip(self, g): gg= IMP.display.create_geometry(g) nm=self.get_tmp_file_name("round_trip_g.rmf") rmf= RMF.create_rmf_file(nm) IMP.rmf.add_geometries(rmf.get_root_node(), [gg]) IMP.rmf.save_frame(rmf, 0) del rmf rmf=RMF.open_rmf_file_read_only(nm) ggb= IMP.rmf.create_geometries(rmf) IMP.rmf.load_frame(rmf, 0) ggbt= gg.get_from(gg) self.assertEqual(type(ggbt.get_geometry()), type(g))
def _do_test_round_trip(self, g, suffix): gg = IMP.display.create_geometry(g) nm = self.get_tmp_file_name("round_trip_g" + suffix) print(nm) rmf = RMF.create_rmf_file(nm) IMP.rmf.add_geometries(rmf.get_root_node(), [gg]) IMP.rmf.save_frame(rmf, "zero") del rmf rmf = RMF.open_rmf_file_read_only(nm) ggb = IMP.rmf.create_geometries(rmf) IMP.rmf.load_frame(rmf, RMF.FrameID(0)) ggbt = gg.get_from(gg) self.assertEqual(type(ggbt.get_geometry()), type(g))
def test_round_trip(self): """Test that restraints with a zillion terms are squashed""" for suffix in RMF.suffixes: m= IMP.Model() l0= IMP.atom.read_pdb(self.get_input_file_name("simple.pdb"), m) l1= IMP.atom.read_pdb(self.get_input_file_name("simple.pdb"), m) cpc= IMP.container.CloseBipartitePairContainer(IMP.atom.get_leaves(l0), IMP.atom.get_leaves(l1), 15, 1) r= IMP.container.PairsRestraint(IMP.core.HarmonicDistancePairScore(10, 10), cpc) rmf= RMF.create_rmf_file(self.get_tmp_file_name("zillion."+suffix)) IMP.rmf.add_hierarchies(rmf, [l0, l1]) IMP.rmf.add_restraints(rmf, [r]) IMP.rmf.set_maximum_number_of_terms(rmf, 10) IMP.rmf.save_frame(rmf, 0) num_nodes= self._get_num_nodes(rmf.get_root_node()) print num_nodes self.assertEqual(num_nodes, m.get_number_of_particles()+1+1+2*len(IMP.atom.get_leaves(l0)))
def test_round_trip(self): """Test that restraints with a zillion terms are squashed""" for suffix in IMP.rmf.suffixes: m = IMP.Model() l0 = IMP.atom.read_pdb(self.get_input_file_name("simple.pdb"), m) l1 = IMP.atom.read_pdb(self.get_input_file_name("simple.pdb"), m) cpc = IMP.container.CloseBipartitePairContainer( IMP.atom.get_leaves(l0), IMP.atom.get_leaves(l1), 15, 1) r = IMP.container.PairsRestraint( IMP.core.HarmonicDistancePairScore(10, 10), cpc) rmf = RMF.create_rmf_file( self.get_tmp_file_name("zillion" + suffix)) IMP.rmf.add_hierarchies(rmf, [l0, l1]) IMP.rmf.add_restraints(rmf, [r]) IMP.rmf.set_maximum_number_of_terms(rmf, 10) IMP.rmf.save_frame(rmf) num_nodes = self._get_num_nodes(rmf.get_root_node()) print(num_nodes) self.assertEqual(num_nodes, len(m.get_particle_indexes()) + 1 + 1)
slabss= IMP.npctransport.SlabSingletonScore(height, radius, 1) r= IMP.core.SingletonRestraint(slabss, p, "slab") r.set_log_level(IMP.WARNING) nm=IMP.base.create_temporary_file_name("display_slab", ".pym") w= IMP.display.create_writer(nm) if use_rmf: rnm=IMP.base.create_temporary_file_name("display_slab", ".rmf") rmf= RMF.create_rmf_file(rnm) #IMP.rmf.add_hierarchies(rmf, [p]) sg= IMP.npctransport.SlabWireGeometry(height, radius, 100) sg.set_was_used(True); if use_rmf: sg.set_color(IMP.display.Color(0,1,0)) sgs= sg.get_components() nh= rmf.get_root_node().add_child("slab", RMF.GEOMETRY) IMP.rmf.add_geometries(nh, sgs) #[sc.show() for sc in sgs] w.add_geometry(sg) bb=IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0, 0, 0), IMP.algebra.Vector3D(sz, sz, sz)) #nh= rmf.get_root_node().add_child("derivatives", RMF.GEOMETRY) gs=[] if use_rmf: nh= rmf.get_root_node().add_child("deriv", RMF.GEOMETRY) for c in IMP.algebra.get_grid_interior_cover_by_spacing(bb, 5): #print c d.set_coordinates(c)
slabss = IMP.npctransport.SlabSingletonScore(height, radius, 1) r = IMP.core.SingletonRestraint(slabss, p, "slab") r.set_log_level(IMP.WARNING) nm = IMP.base.create_temporary_file_name("display_slab", ".pym") w = IMP.display.create_writer(nm) if use_rmf: rnm = IMP.base.create_temporary_file_name("display_slab", ".rmf") rmf = RMF.create_rmf_file(rnm) #IMP.rmf.add_hierarchies(rmf, [p]) sg = IMP.npctransport.SlabWireGeometry(height, radius, 100) sg.set_was_used(True) if use_rmf: sg.set_color(IMP.display.Color(0, 1, 0)) sgs = sg.get_components() nh = rmf.get_root_node().add_child("slab", RMF.GEOMETRY) IMP.rmf.add_geometries(nh, sgs) #[sc.show() for sc in sgs] w.add_geometry(sg) bb = IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(0, 0, 0), IMP.algebra.Vector3D(sz, sz, sz)) #nh= rmf.get_root_node().add_child("derivatives", RMF.GEOMETRY) gs = [] if use_rmf: nh = rmf.get_root_node().add_child("deriv", RMF.GEOMETRY) for c in IMP.algebra.get_grid_interior_cover_by_spacing(bb, 5): #print c d.set_coordinates(c)