예제 #1
0
def _do_it(path):
    fh = RMF.open_rmf_file_read_only(path)
    mf = RMF.Molecule(fh)
    cf = RMF.ChainFactory(fh)

    res = RMF.get_resolutions(fh.get_root_node(), RMF.PARTICLE, .1)
    if len(res) == 1:
        res = [-1]
    fh.set_current_frame(RMF.FrameID(0))
    diameter = RMF.get_diameter(fh.get_root_node())
    mydata = MyData(fh, diameter)
    for f in fh.get_frames():
        created = {}
        fh.set_current_frame(f)
        for r in res:
            _create_molecules(
                fh.get_root_node(),
                mf,
                cf,
                mydata,
                r,
                created)
            if len(created) == 0:
                # fall back
                _create_molecule(fh.get_root_node(), mydata, r, created)
        for c in created:
            cmd.load_model(created[c][1], c, f.get_index() + 1)
예제 #2
0
 def test_perturbed(self):
     """Test copying an rmf file"""
     # can't set index attribute any more
     return
     RMF.set_log_level("trace")
     name = RMF._get_temporary_file_path("chain.rmf")
     fh = RMF.create_rmf_file(name)
     fh.set_current_frame(RMF.FrameID(0))
     n = fh.get_root_node().add_child("n", RMF.REPRESENTATION)
     c = fh.get_category("sequence")
     k = fh.get_int_key(c, "chain id")
     k2 = fh.get_int_key(c, "other")
     n.set_static_value(k, 0)
     n.set_static_value(k2, 8)
     RMF.show_hierarchy_with_values(n)
     fh.flush()
     print("closing")
     del n
     del fh
     del k
     del c
     fh = RMF.open_rmf_file_read_only(name)
     fh.set_current_frame(RMF.FrameID(0))
     cf = RMF.ChainFactory(fh)
     n = fh.get_root_node().get_children()[0]
     RMF.show_hierarchy_with_values(n)
     self.assertTrue(cf.get_is(n))
     chain = cf.get(n).get_chain_id()
     self.assertEqual(chain, "A")
예제 #3
0
def create_hierarchy(file):
    cf = RMF.ChainFactory(file)
    af = RMF.AtomFactory(file)
    rf = RMF.ResidueFactory(file)
    pf = RMF.ParticleFactory(file)
    n = file.get_root_node()
    for i in range(0, 3 * scale):
        child = n.add_child(str(i), RMF.REPRESENTATION)
        cf.get(child).set_chain_id(str(i))
        create_chain(child, rf, af, pf)
예제 #4
0
    def test_chain(self):
        """Test the Chain decorator"""
        b = RMF.BufferHandle()
        rmf = RMF.create_rmf_buffer(b)

        rmf.add_frame('zero', RMF.FRAME)
        rt = rmf.get_root_node()

        cf = RMF.ChainFactory(rmf)
        c0 = rt.add_child("c0", RMF.REPRESENTATION)
        c1 = rt.add_child("c1", RMF.REPRESENTATION)
        c = cf.get(c0)
        # Check defaults
        self.assertEqual(c.get_chain_type(), 'UnknownChainType')
        self.assertEqual(c.get_sequence(), '')
        # Check setters
        c.set_chain_type('LPolypeptide')
        c.set_sequence('CGY')
        c.set_chain_id('X')

        # Check both const and non-const getters
        self.check_rmf(cf, c0, c1)
        self.check_rmf(RMF.ChainConstFactory(rmf), c0, c1)
예제 #5
0
fh = RMF.open_rmf_file_read_only(RMF.get_example_path("3U7W.rmf"))
fh.set_current_frame(RMF.FrameID(0))

outpath = RMF._get_temporary_file_path("3U7W-residues.rmf")
out = RMF.create_rmf_file(outpath)
out.add_frame("nothing", RMF.FRAME)
print("file is", outpath)
bf = RMF.BondFactory(out)

rcf = RMF.ResidueFactory(fh)
rf = RMF.ResidueFactory(out)
pcf = RMF.ParticleFactory(fh)
pf = RMF.ParticleFactory(out)
acf = RMF.AtomFactory(fh)
af = RMF.AtomFactory(out)
ccf = RMF.ChainFactory(fh)
cf = RMF.ChainFactory(out)
bf = RMF.BondFactory(out)
copy_to_residues(
    fh.get_root_node(),
    out.get_root_node(),
    rcf,
    rf,
    pcf,
    pf,
    acf,
    af,
    ccf,
    cf,
    bf,
    None)