def build(self): f = open("all_points.str") line = f.readline() f.close() path = basic_io.str_to_points(line) mg = None f = open("mg.top") line = f.readline() f.close() mg = motif_graph.motif_graph_from_topology(line) segments = self._get_segments(path) pathes = self._get_sub_pathes(segments) if mg == None: mg = motif_graph.MotifGraph() w = wrapper.FollowPathWrapper() w.run(path="path.0.str", mg="mg.top") f = open("mt_out.top") line = f.readline() f.close() mt_all = motif_tree.motif_tree_from_topology_str(line) mg.add_motif_tree(mt_all) print "building:" for i in range(1, len(pathes)): print "path: ", i last_node = mg.last_node() s = mg.topology_to_str() f = open("mg_input.top", "w") f.write(s + "\n") f.write(str(last_node.index) + " " + last_node.data.ends[1].name() + "\n") f.close() w = wrapper.FollowPathWrapper() w.run(path="path." + str(i) + ".str", mg="mg_input.top") f = open("mt_out.top") line = f.readline() f.close() mt = motif_tree.motif_tree_from_topology_str(line) mg.add_motif_tree(mt) mt_all.add_motif_tree(mt) mg.to_pdb("final_rna_path.pdb") f = open("mt_out.top", "w") f.write(mt_all.topology_to_str() + "\n") f.close()
def _run_path_finding(self, state): if self.built: state.vmg.remove_node_level(1) state.vmg.mg.decrease_level() all_points = [] reg_points = [] for p in self.points: reg_points.append(np.array(p.pos)) for i in range(len(reg_points) - 1): all_points.append(reg_points[i]) diff = reg_points[i + 1] - reg_points[i] unit_vector = util.normalize(diff) current = reg_points[i] + unit_vector * 5.0 while util.distance(reg_points[i + 1], current) > 5.0: all_points.append(current) current = current + unit_vector * 5.0 s = basic_io.points_to_str(all_points) f = open("all_points.str", "w") f.write(s) f.close() basic_io.points_to_pdb("all_points.pdb", all_points) f = open("mg.top", "w") f.write(state.vmg.mg.topology_to_str() + "\n") f.write( str(self.highlighted_ends[0][0]) + " " + self.highlighted_ends[0][1].name()) f.close() self.path_builder.build() f = open("mt_out.top") lines = f.readlines() f.close() mt = motif_tree.motif_tree_from_topology_str(lines[0]) state.vmg.mg.increase_level() state.vmg.add_motif_tree(mt, self.highlighted_ends[0][0], self.highlighted_ends[0][1].name()) for p in self.points: p.opacity = 0.5 for l in self.lines: l.opacity = 0.5 self.built = 1 state.update_center = 1
def _run_path_finding(self, state): if self.built: state.vmg.remove_node_level(1) state.vmg.mg.decrease_level() all_points = [] reg_points = [] for p in self.points: reg_points.append(np.array(p.pos)) for i in range(len(reg_points)-1): all_points.append(reg_points[i]) diff = reg_points[i+1] - reg_points[i] unit_vector = util.normalize(diff) current = reg_points[i] + unit_vector*5.0 while util.distance(reg_points[i+1], current) > 5.0: all_points.append(current) current = current + unit_vector*5.0 s = basic_io.points_to_str(all_points) f = open("all_points.str", "w") f.write(s) f.close() basic_io.points_to_pdb("all_points.pdb", all_points) f = open("mg.top", "w") f.write(state.vmg.mg.topology_to_str() + "\n") f.write(str(self.highlighted_ends[0][0]) + " " + self.highlighted_ends[0][1].name()) f.close() self.path_builder.build() f = open("mt_out.top") lines = f.readlines() f.close() mt = motif_tree.motif_tree_from_topology_str(lines[0]) state.vmg.mg.increase_level() state.vmg.add_motif_tree(mt, self.highlighted_ends[0][0], self.highlighted_ends[0][1].name()) for p in self.points: p.opacity = 0.5 for l in self.lines: l.opacity = 0.5 self.built = 1 state.update_center = 1
def build(self): f = open("all_points.str") line = f.readline() f.close() path = basic_io.str_to_points(line) mg = None f = open("mg.top") line = f.readline() f.close() mg = motif_graph.motif_graph_from_topology(line) segments = self._get_segments(path) pathes = self._get_sub_pathes(segments) if mg == None: mg = motif_graph.MotifGraph() w = wrapper.FollowPathWrapper() w.run(path="path.0.str", mg="mg.top") f = open("mt_out.top") line = f.readline() f.close() mt_all = motif_tree.motif_tree_from_topology_str(line) mg.add_motif_tree(mt_all) print "building:" for i in range(1, len(pathes)): print "path: ", i last_node = mg.last_node() s = mg.topology_to_str() f = open("mg_input.top", "w") f.write(s + "\n") f.write( str(last_node.index) + " " + last_node.data.ends[1].name() + "\n") f.close() w = wrapper.FollowPathWrapper() w.run(path="path." + str(i) + ".str", mg="mg_input.top") f = open("mt_out.top") line = f.readline() f.close() mt = motif_tree.motif_tree_from_topology_str(line) mg.add_motif_tree(mt) mt_all.add_motif_tree(mt) mg.to_pdb("final_rna_path.pdb") f = open("mt_out.top", "w") f.write(mt_all.topology_to_str() + "\n") f.close()