Ejemplo n.º 1
0
def rama_rescale(results):
    res1 = []
    res2 = []
    for (r1_id_str, diff2, r1_phi, r1_psi, r2_phi, r2_psi, v, r2_res_type,
         r1_score, r2_score) in results:
        for phi, psi, score, res in [(r1_phi, r1_psi, r1_score, res1),
                                     (r2_phi, r2_psi, r2_score, res2)]:
            max_value = find_region_max_value(r2_res_type, phi, psi)
            if max_value is None:
                res.append(score)
            else:
                res.append(score / max_value[1])
    return res1, res2
Ejemplo n.º 2
0
    def __init__(self, models, params, log):
        self.models = models
        self.log = log
        self.params = params
        self.total_rama = []
        rama_res = easy_mp.pool_map(
            processes=self.params.nproc,
            fixed_func=ramalyze_parallel,
            args=[m.get_hierarchy() for m in self.models])
        for r in rama_res:
            for res in r.results:
                self.total_rama.append(res)

        self.results = {}
        for rama_type in range(5):
            print "Working with", res_types[rama_type], "plot"
            for peak in get_favored_peaks(rama_type):
                print "  Working with peak:", peak
                start_point = peak[0] if self.params.grid_center_on_peak else (
                    0, 0)
                gof = grid_over_favored(
                    rama_type=rama_type,
                    rama_region=peak[0],
                    start_point=start_point,
                    grid_size=self.params.grid_size,
                    corners_inside=self.params.corners_inside)
                points = []
                for r in self.total_rama:
                    if (r.res_type == rama_type and
                        (r.rama_type == RAMALYZE_FAVORED
                         or self.params.use_allowed) and find_region_max_value(
                             rama_type,
                             r.phi,
                             r.psi,
                             allow_outside=self.params.use_allowed) == peak):
                        points.append((r.phi, r.psi))
                gof.add_points(points,
                               stop_on_outsiders=self.params.use_allowed)
                c = gof.get_corr(), gof.grid.get_total_points()
                if c.count(None) > 0:
                    c = None
                self.results[(rama_type, peak)] = c
Ejemplo n.º 3
0
    def __init__(self,
                 rama_type,
                 rama_region,
                 start_point,
                 grid_size,
                 corners_inside,
                 use_allowed=False):
        self.rama_type = rama_type
        self.rama_region = rama_region
        self.start_point = start_point
        self.grid_size = grid_size
        self.corners_inside = corners_inside
        self.r = ramachandran_eval.RamachandranEval()
        self.grid = grid()  # list of square objects
        points_x = grid_over_favored._get_grid_points(start_point[0],
                                                      grid_size)
        points_y = grid_over_favored._get_grid_points(start_point[1],
                                                      grid_size)
        for x in points_x:
            for y in points_y:
                n_inside = 0
                for dx in [0, 1]:
                    for dy in [0, 1]:
                        reg = find_region_max_value(rama_type,
                                                    x + grid_size * dx,
                                                    y + grid_size * dy)
                        if reg is not None and reg[0] == rama_region:
                            n_inside += 1
                if n_inside >= corners_inside:
                    v = self.r.evaluate(
                        rama_type, [x + 0.5 * grid_size, y + 0.5 * grid_size])
                    self.grid.append(
                        square((x, y), (x + grid_size, y + grid_size), v))
        print "    Number of grid cells", len(self.grid)

        self.grid.scale_to_1()
Ejemplo n.º 4
0
def exercise_1():
    # ((-63.0, -43.0), 1.0)
    print(find_region_max_value(RAMA_GENERAL, -100, 0))
    assert find_region_max_value(RAMA_GENERAL, -100,
                                 0) == ((-63.0, -43.0), 1.0)
    assert find_region_max_value(RAMA_GENERAL, -120,
                                 40) == ((-63.0, -43.0), 1.0)
    assert find_region_max_value(RAMA_GENERAL, -45,
                                 -55) == ((-63.0, -43.0), 1.0)
    assert find_region_max_value(RAMA_GENERAL, 0, 0) == None

    # ((-115.0, 131.0), 0.57068)
    assert find_region_max_value(RAMA_GENERAL, -80,
                                 100) == ((-115.0, 131.0), 0.57068)
    assert find_region_max_value(RAMA_GENERAL, -160,
                                 179) == ((-115.0, 131.0), 0.57068)
    assert find_region_max_value(RAMA_GENERAL, -80,
                                 60) == ((-115.0, 131.0), 0.57068)
    assert find_region_max_value(RAMA_GENERAL, -120,
                                 -179) == ((-115.0, 131.0), 0.57068)

    # ((53.0, 43.0), 0.323004)
    assert find_region_max_value(RAMA_GENERAL, 60,
                                 40) == ((53.0, 43.0), 0.323004)
    assert find_region_max_value(RAMA_GENERAL, 75,
                                 0) == ((53.0, 43.0), 0.323004)
    assert find_region_max_value(RAMA_GENERAL, 60,
                                 60) == ((53.0, 43.0), 0.323004)

    # ((53.0, -127.0), 0.0246619)
    assert find_region_max_value(RAMA_GENERAL, 53,
                                 -127) == ((53.0, -127.0), 0.0246619)
    assert find_region_max_value(RAMA_GENERAL, 54,
                                 -128) == ((53.0, -127.0), 0.0246619)
    assert find_region_max_value(RAMA_GENERAL, 53,
                                 -130) == ((53.0, -127.0), 0.0246619)

    print("==================================================")
    # ((-63.0, -41.0), 1.0)
    assert find_region_max_value(RAMA_GLYCINE, -80,
                                 -20) == ((-63.0, -41.0), 1.0)
    assert find_region_max_value(RAMA_GLYCINE, -80,
                                 60) == ((-63.0, -41.0), 1.0)
    assert find_region_max_value(RAMA_GLYCINE, -80,
                                 65) == ((-63.0, -41.0), 1.0)
    # ((63.0, 41.0), 1.0)
    assert find_region_max_value(RAMA_GLYCINE, 80, 0) == ((63.0, 41.0), 1.0)
    assert find_region_max_value(RAMA_GLYCINE, 80, -60) == ((63.0, 41.0), 1.0)
    # ((79.0, -173.0), 0.553852)
    assert find_region_max_value(RAMA_GLYCINE, 100,
                                 -160) == ((79.0, -173.0), 0.553852)
    assert find_region_max_value(RAMA_GLYCINE, 120,
                                 160) == ((79.0, -173.0), 0.553852)
    assert find_region_max_value(RAMA_GLYCINE, -100,
                                 140) == ((79.0, -173.0), 0.553852)
    assert find_region_max_value(RAMA_GLYCINE, -100,
                                 -160) == ((79.0, -173.0), 0.553852)

    print("==================================================")
    # ((-89.0, 5.0), 0.701149)
    assert find_region_max_value(RAMA_CISPRO, -80,
                                 0) == ((-89.0, 5.0), 0.701149)
    assert find_region_max_value(RAMA_CISPRO, -60,
                                 -20) == ((-89.0, 5.0), 0.701149)
    assert find_region_max_value(RAMA_CISPRO, -100,
                                 40) == ((-89.0, 5.0), 0.701149)
    # ((-75.0, 155.0), 1.0)
    assert find_region_max_value(RAMA_CISPRO, -80,
                                 140) == ((-75.0, 155.0), 1.0)
    assert find_region_max_value(RAMA_CISPRO, -80,
                                 -178) == ((-75.0, 155.0), 1.0)

    print("==================================================")
    # ((-57.0, -37.0), 0.99566)
    assert find_region_max_value(RAMA_TRANSPRO, -60,
                                 -20) == ((-57.0, -37.0), 0.99566)
    assert find_region_max_value(RAMA_TRANSPRO, -80,
                                 0) == ((-57.0, -37.0), 0.99566)
    assert find_region_max_value(RAMA_TRANSPRO, -40,
                                 -40) == ((-57.0, -37.0), 0.99566)
    # ((-81.0, 65.0), 0.0896269)
    assert find_region_max_value(RAMA_TRANSPRO, -80,
                                 60) == ((-81.0, 65.0), 0.0896269)
    # ((-59.0, 143.0), 1.0)
    assert find_region_max_value(RAMA_TRANSPRO, -60,
                                 140) == ((-59.0, 143.0), 1.0)
    assert find_region_max_value(RAMA_TRANSPRO, -80,
                                 -179) == ((-59.0, 143.0), 1.0)

    print("==================================================")
    # ((-70.1, 149.0), 0.9619998)
    assert find_region_max_value(RAMA_PREPRO, -120,
                                 140) == ((-67.0, 147.0), 0.992025)
    assert find_region_max_value(RAMA_PREPRO, -120,
                                 60) == ((-67.0, 147.0), 0.992025)
    assert find_region_max_value(RAMA_PREPRO, -160,
                                 80) == ((-67.0, 147.0), 0.992025)
    assert find_region_max_value(RAMA_PREPRO, -160,
                                 160) == ((-67.0, 147.0), 0.992025)
    # ((-57.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_PREPRO, -60,
                                 -40) == ((-57.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_PREPRO, -45,
                                 -55) == ((-57.0, -45.0), 1.0)
    # ((49.0, 57.0), 0.185259)
    assert find_region_max_value(RAMA_PREPRO, 49,
                                 57) == ((49.0, 57.0), 0.185259)
    assert find_region_max_value(RAMA_PREPRO, 60,
                                 60) == ((49.0, 57.0), 0.185259)
    assert find_region_max_value(RAMA_PREPRO, 55,
                                 55) == ((49.0, 57.0), 0.185259)

    print("==================================================")
    # ((-63.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_ILE_VAL, -60,
                                 -40) == ((-63.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_ILE_VAL, -120,
                                 -60) == ((-63.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_ILE_VAL, -120,
                                 20) == ((-63.0, -45.0), 1.0)
    assert find_region_max_value(RAMA_ILE_VAL, -80, 0) == ((-63.0, -45.0), 1.0)
    # ((-121.0, 129.0), 0.76163)
    assert find_region_max_value(RAMA_ILE_VAL, -100,
                                 140) == ((-121.0, 129.0), 0.76163)
    assert find_region_max_value(RAMA_ILE_VAL, -160,
                                 140) == ((-121.0, 129.0), 0.76163)
    assert find_region_max_value(RAMA_ILE_VAL, -60,
                                 140) == ((-121.0, 129.0), 0.76163)
    assert find_region_max_value(RAMA_ILE_VAL, -130,
                                 -179) == ((-121.0, 129.0), 0.76163)