コード例 #1
0
ファイル: test_particles.py プロジェクト: apolitis/imp
 def test_perturbed_frames(self):
     """Test reading and writing particles with frames"""
     for suffix in RMF.suffixes:
         m= IMP.kernel.Model()
         p0= IMP.kernel.Particle(m)
         p1= IMP.kernel.Particle(m)
         ik= IMP.IntKey("hi int")
         fk= IMP.FloatKey("hi float")
         p0.add_attribute(ik, 1)
         p1.add_attribute(fk, 2.0)
         p1.add_attribute(ik, 3)
         name= self.get_tmp_file_name("particles."+suffix)
         print name
         rmf= RMF.create_rmf_file(name)
         IMP.base.set_log_level(IMP.base.SILENT)
         IMP.rmf.add_particles(rmf, [p0, p1])
         IMP.rmf.save_frame(rmf, 0)
         p1.set_value(ik, 5)
         IMP.rmf.save_frame(rmf, 1)
         del rmf
         rmf= RMF.open_rmf_file_read_only(name)
         cat= rmf.get_category("IMP")
         print cat
         keys= rmf.get_keys(cat)
         print [rmf.get_name(k) for k in keys]
         bps= IMP.rmf.create_particles(rmf, m)
コード例 #2
0
ファイル: test_particles.py プロジェクト: newtonjoo/imp
 def test_perturbed_frames(self):
     """Test reading and writing particles with frames"""
     RMF.set_log_level("trace")
     for suffix in IMP.rmf.suffixes:
         m = IMP.kernel.Model()
         p0 = IMP.kernel.Particle(m)
         p1 = IMP.kernel.Particle(m)
         ik = IMP.IntKey("hi int")
         fk = IMP.FloatKey("hi float")
         p0.add_attribute(ik, 1)
         p1.add_attribute(fk, 2.0)
         p1.add_attribute(ik, 3)
         name = self.get_tmp_file_name("particles" + suffix)
         print(name)
         rmf = RMF.create_rmf_file(name)
         IMP.base.set_log_level(IMP.base.SILENT)
         IMP.rmf.add_particles(rmf, [p0, p1])
         IMP.rmf.save_frame(rmf, str(0))
         p1.set_value(ik, 5)
         IMP.rmf.save_frame(rmf, str(1))
         del rmf
         print("closed")
         rmf = RMF.open_rmf_file_read_only(name)
         cat = rmf.get_category("IMP")
         print(cat)
         keys = rmf.get_keys(cat)
         print([rmf.get_name(k) for k in keys])
         bps = IMP.rmf.create_particles(rmf, m)
         print("load 0")
         IMP.rmf.load_frame(rmf, RMF.FrameID(0))
         self.assertEqual(len(bps), 2)
         print("out")
         bps[0].show()
         self.assertTrue(bps[0].has_attribute(ik))
         self.assertEqual(bps[0].get_value(ik), 1)
         self.assertTrue(bps[1].has_attribute(ik))
         self.assertEqual(bps[1].get_value(ik), 3)
         self.assertTrue(bps[1].has_attribute(fk))
         self.assertEqual(bps[1].get_value(fk), 2.0)
         IMP.rmf.load_frame(rmf, RMF.FrameID(1))
         self.assertTrue(bps[1].has_attribute(ik))
         self.assertEqual(bps[1].get_value(ik), 5)
コード例 #3
0
ファイル: test_particles.py プロジェクト: sirusb/imp
 def test_perturbed_frames(self):
     """Test reading and writing particles with frames"""
     RMF.set_log_level("trace")
     for suffix in IMP.rmf.suffixes:
         m = IMP.kernel.Model()
         p0 = IMP.kernel.Particle(m)
         p1 = IMP.kernel.Particle(m)
         ik = IMP.IntKey("hi int")
         fk = IMP.FloatKey("hi float")
         p0.add_attribute(ik, 1)
         p1.add_attribute(fk, 2.0)
         p1.add_attribute(ik, 3)
         name = self.get_tmp_file_name("particles" + suffix)
         print name
         rmf = RMF.create_rmf_file(name)
         IMP.base.set_log_level(IMP.base.SILENT)
         IMP.rmf.add_particles(rmf, [p0, p1])
         IMP.rmf.save_frame(rmf, str(0))
         p1.set_value(ik, 5)
         IMP.rmf.save_frame(rmf, str(1))
         del rmf
         print "closed"
         rmf = RMF.open_rmf_file_read_only(name)
         cat = rmf.get_category("IMP")
         print cat
         keys = rmf.get_keys(cat)
         print[rmf.get_name(k) for k in keys]
         bps = IMP.rmf.create_particles(rmf, m)
         print "load 0"
         IMP.rmf.load_frame(rmf, RMF.FrameID(0))
         self.assertEqual(len(bps), 2)
         print "out"
         bps[0].show()
         self.assertTrue(bps[0].has_attribute(ik))
         self.assertEqual(bps[0].get_value(ik), 1)
         self.assertTrue(bps[1].has_attribute(ik))
         self.assertEqual(bps[1].get_value(ik), 3)
         self.assertTrue(bps[1].has_attribute(fk))
         self.assertEqual(bps[1].get_value(fk), 2.0)
         IMP.rmf.load_frame(rmf, RMF.FrameID(1))
         self.assertTrue(bps[1].has_attribute(ik))
         self.assertEqual(bps[1].get_value(ik), 5)
コード例 #4
0
ファイル: restraint_cache.py プロジェクト: AljGaber/imp
    # pass the cache to the restraint score based filter
    # it will use all the restraints in the cache
    rssft = IMP.domino.RestraintScoreSubsetFilterTable(rc)
    s.set_subset_filter_tables([ef, rssft])

    # create a subset with all the particles
    # Subsets keep the particles in sorted order and so are different than
    # a simple list of particles
    alls = IMP.domino.Subset(ps)

    # get all the assignments that fit
    sts = s.get_sample_assignments(alls)

    # create a temporary file to write things to
    rmf = RMF.create_rmf_file(IMP.create_temporary_file_name("cache", ".rmf"))
    print("saving configurations to", rmf.get_name())

    IMP.rmf.add_hierarchy(rmf, h)

    # the restraint cache processes the restraints to make them more efficient
    # for use with domino. So we want to get back the processed restraints
    # before looking at them further
    domino_restraints = rc.get_restraints()

    for r in domino_restraints:
        IMP.show_restraint_hierarchy(r)

    IMP.rmf.add_restraints(rmf, domino_restraints)
    # for each assignment load it, and add the configuration to an rmf file
    print("found assignments", sts)
    # we don't care about messages during saving
コード例 #5
0
    # pass the cache to the restraint score based filter
    # it will use all the restraints in the cache
    rssft = IMP.domino.RestraintScoreSubsetFilterTable(rc)
    s.set_subset_filter_tables([ef, rssft])

    # create a subset with all the particles
    # Subsets keep the particles in sorted order and so are different than
    # a simple list of particles
    alls = IMP.domino.Subset(ps)

    # get all the assignments that fit
    sts = s.get_sample_assignments(alls)

    # create a temporary file to write things to
    rmf = RMF.create_rmf_file(IMP.create_temporary_file_name("cache", ".rmf"))
    print("saving configurations to", rmf.get_name())

    IMP.rmf.add_hierarchy(rmf, h)

    # the restraint cache processes the restraints to make them more efficient
    # for use with domino. So we want to get back the processed restraints
    # before looking at them further
    domino_restraints = rc.get_restraints()

    for r in domino_restraints:
        IMP.show_restraint_hierarchy(r)

    IMP.rmf.add_restraints(rmf, domino_restraints)
    # for each assignment load it, and add the configuration to an rmf file
    print("found assignments", sts)
    # we don't care about messages during saving
コード例 #6
0
ファイル: simulation.py プロジェクト: apolitis/imp
bbss = IMP.core.BoundingBox3DSingletonScore(
    IMP.core.HarmonicUpperBound(0, k), bb)
bbr = IMP.container.SingletonsRestraint(bbss, ps)
rs.append(bbr)

sf = IMP.core.RestraintsScoringFunction(rs, "SF")

bd = IMP.atom.BrownianDynamics(m)
bd.set_log_level(IMP.base.SILENT)
bd.set_scoring_function(sf)

bd.set_maximum_time_step(10)

name = IMP.base.create_temporary_file_name("brownian", ".rmf")
rmf = RMF.create_rmf_file(name)
rmf.set_description("Brownian dyanmics trajectory with 10fs timestep.\n")
IMP.rmf.add_hierarchy(rmf, h)
IMP.rmf.add_restraints(rmf, rs)
IMP.rmf.add_geometry(rmf, IMP.display.BoundingBoxGeometry(bb))

os = IMP.rmf.SaveOptimizerState(rmf)
os.update_always("initial conformation")
os.set_log_level(IMP.base.SILENT)
os.set_simulator(bd)
bd.add_optimizer_state(os)

bd.optimize(frames)

print "file is", rmf.get_name()
コード例 #7
0
bbss = IMP.core.BoundingBox3DSingletonScore(
    IMP.core.HarmonicUpperBound(0, k), bb)
bbr = IMP.container.SingletonsRestraint(bbss, ps)
rs.append(bbr)

sf = IMP.core.RestraintsScoringFunction(rs, "SF")

bd = IMP.atom.BrownianDynamics(m)
bd.set_log_level(IMP.SILENT)
bd.set_scoring_function(sf)

bd.set_maximum_time_step(10)

name = IMP.create_temporary_file_name("brownian", ".rmf")
rmf = RMF.create_rmf_file(name)
rmf.set_description("Brownian dyanmics trajectory with 10fs timestep.\n")
IMP.rmf.add_hierarchy(rmf, h)
IMP.rmf.add_restraints(rmf, rs)
IMP.rmf.add_geometry(rmf, IMP.display.BoundingBoxGeometry(bb))

os = IMP.rmf.SaveOptimizerState(m, rmf)
os.update_always("initial conformation")
os.set_log_level(IMP.SILENT)
os.set_simulator(bd)
bd.add_optimizer_state(os)

bd.optimize(frames)

print("file is", rmf.get_name())