Exemple #1
0
    def _get_sub_pathes(self, segments):
        pathes = []
        for i in range(len(segments)):
            if i == 0:
                continue

            p = []
            if i == 1:
                p.extend(segments[0])
            else:
                half = len(segments[i - 1]) / 2
                p.extend(segments[i - 1][half - 1:])

            if i == len(segments) - 1:
                p.extend(segments[i])
            else:
                half = len(segments[i]) / 2
                p.extend(segments[i][:half - 1])
            pathes.append(p)

        for i, p in enumerate(pathes):
            basic_io.points_to_pdb("path." + str(i) + ".pdb", p)
            f = open("path." + str(i) + ".str", "w")
            f.write(basic_io.points_to_str(p))
            f.close()

        return pathes
    def _get_sub_pathes(self, segments):
        pathes = []
        for i in range(len(segments)):
            if i == 0:
                continue

            p = []
            if i == 1:
                p.extend(segments[0])
            else:
                half = len(segments[i - 1]) / 2
                p.extend(segments[i - 1][half - 1 :])

            if i == len(segments) - 1:
                p.extend(segments[i])
            else:
                half = len(segments[i]) / 2
                p.extend(segments[i][: half - 1])
            pathes.append(p)

        for i, p in enumerate(pathes):
            basic_io.points_to_pdb("path." + str(i) + ".pdb", p)
            f = open("path." + str(i) + ".str", "w")
            f.write(basic_io.points_to_str(p))
            f.close()

        return pathes
    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