11 def create_residue(nh, af, pf):
12 for i
in range(0, 2 * scale):
13 child = nh.add_child(
"CA", RMF.REPRESENTATION)
14 pf.get(child).set_mass(1)
15 pf.get(child).set_radius(1.0 + i / 18.77)
16 af.get(child).set_element(7)
19 def create_chain(nh, rf, af, pf):
20 for i
in range(0, 60 * scale):
21 child = nh.add_child(str(i), RMF.REPRESENTATION)
22 rf.get(child).set_residue_type(
"cys")
23 rf.get(child).set_residue_index(i)
24 create_residue(child, af, pf)
27 def create_hierarchy(file):
28 cf = RMF.ChainFactory(file)
29 af = RMF.AtomFactory(file)
30 rf = RMF.ResidueFactory(file)
31 pf = RMF.ParticleFactory(file)
32 n = file.get_root_node()
33 for i
in range(0, 3 * scale):
34 child = n.add_child(str(i), RMF.REPRESENTATION)
35 cf.get(child).set_chain_id(str(i))
36 create_chain(child, rf, af, pf)
39 def create_frame(fh, ipf, atoms, frame):
42 v =
RMF.Vector3((1.0 * n.get_index() + 0 + frame) / 17.0,
43 (1.0 * n.get_index() + 1 + frame) / 19.0,
44 (1.0 * n.get_index() + 2 + frame) / 23.0)
48 ipf.get(fh.get_node(n)).set_coordinates(v)
49 return ret[0] + ret[1] + ret[2]
53 create_hierarchy(file)
55 for n
in file.get_node_ids():
56 if len(file.get_node(n).get_children()) == 0:
58 ipf = RMF.IntermediateParticleFactory(file)
60 for i
in range(0, 20):
61 file.add_frame(
"frame", RMF.FRAME)
62 ret += create_frame(file, ipf, atoms, i)
68 queue = [file.get_root_node()]
69 ipcf = RMF.IntermediateParticleConstFactory(file)
70 while (len(queue) > 0):
75 ret += ipcf.get(cur).get_radius()
76 queue += cur.get_children()
81 def load(file, nodes):
82 ipcf = RMF.IntermediateParticleConstFactory(file)
84 for fr
in file.get_frames():
85 file.set_current_frame(fr)
87 cur = ipcf.get(file.get_node(n)).get_coordinates()
91 return v[0] + v[1] + v[2]
94 def benchmark_create(file, type):
95 start = datetime.datetime.now()
97 print(type,
"create,", datetime.datetime.now() - start,
",", dist)
100 def benchmark_traverse(file, type):
101 start = datetime.datetime.now()
104 print(type,
"traverse,", datetime.datetime.now() - start,
",", t)
107 def benchmark_load(file, type):
109 ipcf = RMF.IntermediateParticleConstFactory(file)
110 for n
in file.get_node_ids():
111 if ipcf.get_is(file.get_node(n)):
113 start = datetime.datetime.now()
114 dist = load(file, nodes)
115 print(type,
"load,", datetime.datetime.now() - start,
",", dist)
117 name =
"benchmark_python.rmf"
119 benchmark_create(fh,
" python rmf")
123 benchmark_traverse(fh,
"python rmf")
124 benchmark_load(fh,
"python rmf")
FileConstHandle open_rmf_file_read_only(std::string path)
FileHandle create_rmf_file(std::string path)
Create an RMF from a file system path.