Ejemplo n.º 1
0
def splice_prep(step, pos_1, pos_2):
    """ Introduces the main body of the splicosome
        to assemble with the other parts and cut the intron """
    left, right = pos_1[:], pos_2[:]
    left[0] *= 0.94
    right[0] *= 0.89
    left[1] *= -1
    right[1] *= -1
    splice_left = Sphere(left, SPLICE_SIZE, "scale", [1.5, -1, 0],
                         models.splice_model)
    splice_right = Sphere(right, SPLICE_SIZE, "scale", [2, -1, 0],
                          models.splice_model)

    coord = get_added_distance(TP_START[8], TP_DUR[8], [0, 16, 0], step)
    y_loc = coord[1]
    splice_down = Sphere([0.5 * TWITCH1, 15 - y_loc, 2], BIG_SPLICE_SIZE,
                         "scale", [0, -1.25, 0], models.splice_model)

    text = Text(
        'ttf', '"timrom.ttf"',
        '"Here you see the main part of the spliceosome entering the screen"',
        0, 0, 'translate', [-15, -4.5, 5], 'scale', [1, 1, 1],
        models.text_model)
    text2 = Text(
        'ttf', '"timrom.ttf"',
        '"The smaller parts wil connect the intron ends to the main part"', 0,
        0, 'translate', [-15, -6, 5], 'scale', [1, 1, 1], models.text_model)
    return [splice_left, splice_right, splice_down, text, text2]
Ejemplo n.º 2
0
def scene(step):
    ''' Returns the scene at step number (1 step per frame) '''
    A = np.array([-10, 8, 0])
    B = np.array([5, 2, -20])
    
    # Find a point with distance 3 from A
    BA = B-A # Vector B->A
    d = math.sqrt(sum(np.power(BA, 2))) # distance
    BA = BA / d # Normalize by its length; BA / ||BA||
    scale = 4
    N = A + scale * BA # Scale and add to A
    l = Cylinder(A, B, 0.05, Pigment('color', [0, 1, 0]))
    s1 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    scale = 15
    N = A + scale * BA # Scale and add to A
    s2 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    scale = 24
    N = A + scale * BA # Scale and add to A
    s3 = Sphere(N, 0.5, Texture(Pigment('color', [0.9, 0.05, 0.05])))
    
    return Scene(povray.floor_camera,
                 objects=[povray.default_light, povray.checkered_ground, 
                 l, s1, s2, s3],
                 included=['colors.inc'])
Ejemplo n.º 3
0
def splice_cut(step, pos_1, pos_2):
    """ Moves both splice parts near each other and makes the cut """
    move = get_added_distance(TP_START[9], TP_DUR[9], [15, 5, 0], step)
    x_change, y_change = move[0], move[1]

    left, right = pos_1[:], pos_2[:]
    left[0] = 0.94 * left[0] - x_change
    right[0] = 0.89 * right[0] + x_change
    left[1] = -1 * left[1] - y_change
    right[1] = -1 * right[1] - y_change

    splice_left = Sphere(left, SPLICE_SIZE, "scale", [1.5, -1, 0],
                         models.splice_model)
    splice_right = Sphere(right, SPLICE_SIZE, "scale", [2, -1, 0],
                          models.splice_model)

    splice_down = Sphere([0, -1, 2], BIG_SPLICE_SIZE, "scale", [0, -1.25, 0],
                         models.splice_model)

    text = Text(
        'ttf', '"timrom.ttf"',
        '"Once the two smaller proteins have connected the intron ends"', 0, 0,
        'translate', [-15, -4.5, 5], 'scale', [1, 1, 1], models.text_model)
    text2 = Text('ttf', '"timrom.ttf"',
                 '"to the bigger protein, they will leave the reaction site"',
                 0, 0, 'translate', [-15, -6, 5], 'scale', [1, 1, 1],
                 models.text_model)
    return [splice_left, splice_right, splice_down, text, text2]
Ejemplo n.º 4
0
def bind_schematic(frame, size):

    """
    Animating the binding part schematicly
    """

    insuline_model = Texture(Pigment('color', [0, 1, 0.5], ), Finish('reflection', 0))
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))

    insuline = []
    s = size

    # frame 30 -> 120
    if frame < 120:
        x = (frame - 30) * (24.5*s / 90) - 30*s
        y = (frame - 30) * (-15*s / 90) + 20*s 
    else:
        x = -5*s
        y = 5*s

    insuline.append(Sphere([x, y, 0], s * 1.5, insuline_model))
    insuline.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('Insulin')), 0.5, [0, 0, 0], text_model, 'scale', 5, 'translate', [x - s, y-0.5*s, -2*s]))

    insuline.append(Sphere([0-x, y, 0], s * 1.5, insuline_model))
    insuline.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('Insulin')), 0.5, [0, 0, 0], text_model, 'scale', 5, 'translate', [0-x -1.4*s, y-0.5*s, -2*s]))

    return insuline
Ejemplo n.º 5
0
def make_membrane(loc, amount, size=5):
    """
    Create the membrane and returns the object
    """

    sphere_model = Texture(Pigment('color', [1, 0, 0], ), Finish('reflection', 0))
    cyl_model = Texture(Pigment('color', [0.7, 0.3, 0], ), Finish('reflection', 0))

    x_position = loc[0]
    y_position = loc[0] - size * 6
    objects = []
    for index in range(1, amount + 1):

        # Create top spheres
        objects.append(Sphere([x_position, loc[1], loc[2]], size, sphere_model))
        objects.append(Sphere([0 - x_position, loc[1], loc[2]], size, sphere_model))

        # Create top cylinders
        location = [x_position - size/3, loc[1], loc[2]], [x_position - size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [x_position + size/3, loc[1], loc[2]], [x_position + size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position - size/3, loc[1], loc[2]], [0-x_position - size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position + size/3, loc[1], loc[2]], [0-x_position + size/3, loc[1] - size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        # Create bottom spheres
        objects.append(Sphere([x_position, y_position, loc[2]], size, sphere_model))
        objects.append(Sphere([0 - x_position, y_position, loc[2]], size, sphere_model))

        # Create bottom cylinders
        location = [x_position - size/3, y_position, loc[2]], [x_position - size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [x_position + size/3, y_position, loc[2]], [x_position + size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position - size/3, y_position, loc[2]], [0-x_position - size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        location = [0-x_position + size/3, y_position, loc[2]], [0-x_position + size/3, y_position + size*2.5, loc[2]]
        objects.append(Cylinder(location[0], location[1], size/6, cyl_model))

        x_position += size * 2

    return objects
Ejemplo n.º 6
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    # Start- and end-points
    x_start = -10
    x_end = 10
    distance = x_end - x_start

    # Calculate distance to move at each step
    distance_per_frame = (distance / nframes) * 2

    # Calculate new x-coordinate
    if step < (nframes / 2):
        # Move from left to right (starting at x = -10)
        x_coord = x_start + step * distance_per_frame
    else:
        # Move from right to left (starting at x = 10)
        x_coord = x_end - (step - (nframes / 2)) * distance_per_frame

    # Create sphere at calculated x-coordinate using default model
    sphere = Sphere([x_coord, 0, 0], 2, models.default_sphere_model)

    # Return the Scene object containing all objects for rendering
    return Scene(models.default_camera,
                 objects=[sphere, models.default_ground, models.default_light])
Ejemplo n.º 7
0
def frame(step):
    """ Creates a frame of a given frame (step) number. """

    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    # Calculates rotation positions
    angle_per_frame = math.pi * 2 / nframes  # Calculates how much the angle needs to move per frame
    angle = angle_per_frame * step # Calculates the angle of the frame

    # Gets locations
    x = math.cos(angle) * 20
    z = math.sin(angle) * 20

    # Create objects
    sphere = Sphere([6, 2, -2], 3, models.default_sphere_model)
    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, models.default_sphere_model)
    legend_1 = legend([-15, 0, 0], 5)
    camera = Camera('location', [x, 8, z], 'look_at', [0, 0, 0])

    # Return the Scene object containing all objects for rendering
    return Scene(camera,
                 objects=[sphere, models.default_light, models.checkered_ground, cylinder] + legend_1)
def frame(step):
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)

    radius = 25
    z_start = -25
    x_start = 0
    alpha = (-pi / 2) + (step * 2 * pi / nframes)
    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    x = x_start + x_coord
    z = z_start - z_coord

    camera_x = 0
    camera_z = -25

    # x gaat links en rechts en z verder de diepte in en terug -25?
    camera = Camera('location', [camera_x, 8, camera_z], 'look_at', [0, 0, 0])

    return Scene(
        camera,
        objects=[
            cylinder, sphere, models.default_light, models.checkered_ground
        ] + shapes,
        included=['colors.inc'])
Ejemplo n.º 9
0
def make_receptor(loc, size=5):
    """
    Creates the receptor and returns the object
    """
    rec_model = Texture(Pigment('color', [0, 1, 1], ), Finish('reflection', 0))

    x = loc[0]
    y = loc[1]
    z = loc[2]

    rec = list()
    rec.append(Cylinder([x - size * 1.2, y - size * 15, z], [x - size * 1.2, y + size*2, z], size, rec_model))
    rec.append(Cylinder([x + size * 1.2, y - size * 15, z], [x + size * 1.2, y + size*2, z], size, rec_model))
    rec.append(Cylinder([x - size * 1.2, y + size * 1.2, z], [x - size * 5, y + size * 4, z], size, rec_model))
    rec.append(Cylinder([x - size * 7.2, y + size * 4, z - size/2],
                        [x - size * 3.2, y + size * 4, z - size/2],
                        size / 1.321, rec_model))

    rec.append(Cylinder([x + size * 1.2, y + size * 1.2, z], [x + size * 5, y + size * 4, z], size, rec_model))
    rec.append(Cylinder([x + size * 7.2, y + size * 4, z - size/2],
                        [x + size * 3.2, y + size * 4, z - size/2],
                        size / 1.321, rec_model))

    rec.append(Sphere([x, y - size * 6, z], size * 3, rec_model))

    return rec
Ejemplo n.º 10
0
def bind_phosphorus(frame, size):
    """
    Animating the process of phosfor binding to the Tyr
    """

    phosphorus_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))
    text_model = Texture(Pigment('color', [1, 1, 0], ), Finish('reflection', 0))

    phosphorus = []
    s = size

    # frame 480 -> 570
    x_locs = [[-20, -5], [20, 5], [-20, -5], [20, 5]]
    y_locs = [13, 13, 10, 10]

    for _ in range(4):
        if frame < 570:
            x = (frame - 480) * ((x_locs[_][1]*s - x_locs[_][0]*s) / 90) + x_locs[_][0]*s
            y = 0 - y_locs[_] * s
        else:
            x = x_locs[_][1]*s
            y = 0 - y_locs[_]*s
        phosphorus.append(Sphere([x, y, 2], s * 1.2, phosphorus_model))
        phosphorus.append(Text('ttf', '"timrom.ttf"', '"{}"'.format(str('P')), 0.5, [0, 0, 0], text_model, 'scale', 7, 'translate', [x - 0.2*s, y-0.5*s, -1.5*s]))
    return phosphorus
Ejemplo n.º 11
0
def s2_cell_zoom(step):
    """ This scene has the camera moving closer towards the cell and entering it """
    cell_sphere = Sphere([0, 0, 0], 25, models.cell_model)
    dpf = get_added_distance(TP_START[2], TP_DUR[2], [0, 0, 49.7], step)
    camera_scene2 = Camera('location', [0, 0, -75], 'look_at', [0, 0, 0],
                           'translate', [dpf[0], dpf[1], dpf[2]])
    return Scene(camera_scene2, objects=[cell_sphere] + models.lights_scene1)
Ejemplo n.º 12
0
def frame(step):
    """ Creates a frame of 4 cones, 4 boxes, 1 sphere and a legend """

    # Define textures for different models
    sphere_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0.5))
    box_model = Texture(Pigment('color', [0, 1, 1], ), Finish('reflection', 0))
    cone_model = Texture(Pigment('color', [1, 0, 1], ), Finish('reflection', 0))

    # Create objects
    sphere = Sphere([0, 0, 0], 3, sphere_model)

    box_1 = Box([-5, -5, -4], [-3, 5, 4], box_model)
    box_2 = Box([3, -5, -4], [5, 5, 4], box_model)
    box_3 = Box([-5, 4, -4], [5, 6, 4], box_model)
    box_4 = Box([-5, -5, -4], [5, -3, 4], box_model)

    cone_1 = Cone([0, 6, 0], 3, [0, 10, 0], 0, cone_model)
    cone_2 = Cone([0, -6, 0], 3, [0, -10, 0], 0, cone_model)
    cone_3 = Cone([-5, 0, 0], 3, [-9, 0, 0], 0, cone_model)
    cone_4 = Cone([5, 0, 0], 3, [9, 0, 0], 0, cone_model)

    light_1 = LightSource([0, 10, -25], 'color', [1, 1, 1])
    light_2 = LightSource([0, 8, -7], 'color', [1, 1, 1])

    xyz_legend = legend([-15, 0, 0], 5)

    camera = Camera('location', [0, 7, -30], 'look_at', [0, 2, 1])

    # Return the Scene object for rendering
    return Scene(camera,
                 objects=[sphere, box_1, box_2, box_3, box_4,
                          cone_1, cone_2, cone_3, cone_4, light_1, light_2] + xyz_legend)
Ejemplo n.º 13
0
def frame(step):
    """ Creates a sphere and 4 boxes, places this in a scene """
    lichtje = LightSource([2, 8, -5], 5.0)
    default_camera = Camera('location', [0, 4, -40], 'look_at', [0, 2, -5])

    stylebox = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                       Finish('phong', 0.6, 'reflection', 0.4))
    boxright = Box([3, -2, -3], [5, 6, 4], stylebox)
    boxleft = Box([-5, -2, -3], [-3, 6, 4], stylebox)
    boxupper = Box([-5, 6, -3], [5, 8, 4], stylebox)
    boxbottom = Box([-5, -4, -3], [5, -2, 4], stylebox)

    styleball = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7))
    centerball = Sphere([0, 2, 0], 3, styleball)

    conetop = Cone([0, 8, 0], 3, [0, 12, 0], 0, stylebox)
    conebottom = Cone([0, -4, 0], 3, [0, -8, 0], 0, stylebox)
    coneleft = Cone([-5, 2, 0], 3, [-11, 2, 0], 0, stylebox)
    coneright = Cone([5, 2, 0], 3, [11, 2, 0], 0, stylebox)

    # Return the Scene object for rendering
    return Scene(default_camera,
                 objects=[
                     lichtje, centerball, boxright, boxleft, boxupper,
                     boxbottom, conetop, conebottom, coneleft, coneright
                 ])
Ejemplo n.º 14
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """
    # Show some information about how far we are with rendering
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Getting the total number of frames, see the configuration file
    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)
    radius = 25
    z_start = 0
    x_start = 0
    #werkt allbei
    # alpha = (-pi/2) + (step * 2 * pi / nframes)
    alpha = pi / (nframes / 2) * step + 1

    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    x = x_start + x_coord
    z = z_start - z_coord
    return Scene(
        Camera('location', [x, 8, z], 'look_at', [0, 0, 0]),
        objects=[
            models.checkered_ground, models.default_light, cylinder, sphere
        ] + leg)
Ejemplo n.º 15
0
def create_second_part_of_animation(frame_number,
                                    thirty_percent_of_total_frames,
                                    fifty_percent_of_total_frames):
    """
    In this function the whole RNA molecule is placed in the center of the scene and
    a sphere is moved over the molecule as a vesicle.
    """
    # Determine total frames of the second part of the animation
    total_frames_second_part = fifty_percent_of_total_frames - thirty_percent_of_total_frames

    # Determine in which step of the second part we are, starting with zero
    step_in_part = frame_number - (thirty_percent_of_total_frames + 1)

    # Place whole RNA molecule in the center of the scene
    RNA_1.move_to([0, 0, 0])

    # Determine the starting and ending x-coordinate of the vesicle
    x_start = 100
    x_end = 0

    # Calculating the distance per frame that the vesicle has to cover
    distance_x = x_end - x_start
    distance_per_frame_x = (distance_x / total_frames_second_part)

    # Calculating the x and y coordinates per frame according to the sine function
    x_coord = x_start + step_in_part * distance_per_frame_x
    y_coord = 2 * sin(x_coord / 5)

    # Making the vesicle with a sphere and placing it at the created x and y coordinates
    vesicle = Sphere([x_coord, y_coord, 0], 20, VESICLE_TEXTURE)

    return [vesicle]
Ejemplo n.º 16
0
def make_objects():
    global SPHERE, CYLINDER, LEGEND

    SPHERE = Sphere([6, 2, -2], 3, models.default_sphere_model)
    CYLINDER = Cylinder([-6, -1, 4], [-6, 7, 4], 3,
                        models.default_sphere_model)
    LEGEND = legend([-15, 0, 0], 5)
Ejemplo n.º 17
0
def frame(step):
    """ Returns the scene at step number (1 step per frame) """

    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    nframes = eval(SETTINGS.NumberFrames)

    style = Texture(Pigment('color', [0.80, 0.00, 1.00], 'filter', 0.7),
                    Finish('phong', 0.6, 'reflection', 0.4))

    cylinder = Cylinder([-6, -1, 4], [-6, 7, 4], 3, style)
    sphere = Sphere([6, 2, -2], 3, style)
    leg = legend([-15, 0, 0], 5)
    radius = 25
    z_start = 0
    x_start = 0

    alpha = (-pi / 2) + (step * 2 * pi / nframes)
    # For each step, de difference in the x and z positions is equal to the radius time the sin and cos of alpha.
    x_coord = radius * cos(alpha)
    z_coord = radius * sin(alpha)
    # Adding or subtracting the difference of the position for each step from the original camera position.
    x = x_start + x_coord
    z = z_start - z_coord
    return Scene(
        Camera('location', [x, 8, z], 'look_at', [0, 0, 0]),
        objects=[
            models.checkered_ground, models.default_light, cylinder, sphere
        ] + leg)
Ejemplo n.º 18
0
def splice_intro(step):
    """ Introduces both two splice complexes from the angles of the screen """
    change_list = get_added_distance(TP_START[6], TP_DUR[6], [12, 0, 0], step)
    x_change = change_list[0]

    splice_left = Sphere([-15 + x_change, TWITCH1, 0], SPLICE_SIZE, "scale",
                         [1.5, -1, 0], models.splice_model)
    splice_right = Sphere([15 - 0.95 * x_change, TWITCH2, 0], SPLICE_SIZE,
                          "scale", [2, -1, 0], models.splice_model)

    text = Text('ttf', '"timrom.ttf"',
                '"The removal of the introns is done by the spliceosome"', 0,
                0, 'translate', [-15, -4.5, 5], 'scale', [1, 1, 1],
                models.text_model)
    text2 = Text(
        'ttf', '"timrom.ttf"',
        '"As can been seen here the spliceosome consists out of multiple proteins"',
        0, 0, 'translate', [-15, -6, 5], 'scale', [1, 1, 1], models.text_model)
    return [splice_left, splice_right, text, text2]
Ejemplo n.º 19
0
def frame(step):
    """ Returns a scene at a step number in which a sphere is visualised. """
    # Feedback to user in terminal about render status
    curr_time = step / eval(SETTINGS.NumberFrames) * eval(SETTINGS.FrameTime)
    logger.info(" @Time: %.3fs, Step: %d", curr_time, step)

    # Calculates the total frames
    n_frames = eval(SETTINGS.NumberFrames)

    # Calculate the frames per wave
    repeats = 5
    n_frames_wave = n_frames / repeats  # amount of frames per wave

    # Calculates starting coordinates of the sphere
    increase = 4  # amount of increase per wave
    x_start = -10
    x_end = x_start + increase
    y_start = -4
    y_end = 4

    # Calculates total distance and distance per frame
    x_distance = x_end - x_start
    y_distance = y_end - y_start
    x_distance_per_frame = (x_distance / (n_frames_wave / 2))
    y_distance_per_frame = (y_distance / (n_frames_wave / 2))

    # Determine in which wave this step is
    if step // n_frames_wave == 0:
        wave = 0
    else:
        wave = step // n_frames_wave

    # Step has to reset for every wave, so subtract frames of previous wave(s)
    frame_in_wave = step - (wave * n_frames_wave)

    # If it is in the first part of the wave
    if frame_in_wave <= (n_frames_wave / 2):
        x_coord = x_start + (
            wave * increase
        ) + frame_in_wave * x_distance_per_frame  # Increases linear
        y_coord = y_start + frame_in_wave * y_distance_per_frame  # Increases linear
    # Second part of the wave
    else:
        x_coord = x_end + (wave * increase
                           )  # Stays constant and increases 4 for every wave
        y_coord = y_end - (
            frame_in_wave -
            (n_frames_wave / 2)) * y_distance_per_frame  # Decreases linear

    # Makes a sphere at given x- and Y-coordinates with the default style
    sphere = Sphere([x_coord, y_coord, 0], 0.5, models.default_sphere_model)

    # Returns the objects of the scene using the default camera settings
    return Scene(models.default_camera,
                 objects=[sphere, models.default_ground, models.default_light])
Ejemplo n.º 20
0
def s4_zoom_to_mrna(step):
    """ In this scene the camera moves into the nucleus
        to further illustrate that the splicing takes place in the nucleus """
    dpf_cam = get_added_distance(TP_START[4], TP_DUR[4], [0, 0, 22.5], step)
    camera_scene4 = Camera('location', [0, 0, -40], 'look_at', [0, 0, 0],
                           'translate', [dpf_cam[0], dpf_cam[1], dpf_cam[2]])

    dpf_nuc = get_added_distance(TP_START[4], TP_DUR[4], [-20, -7.5, -9.9],
                                 step)
    nucleus = Sphere([20, 7.5, 0], 7.5, models.nucleus_model, 'translate',
                     [dpf_nuc[0], dpf_nuc[1], dpf_nuc[2]])
    return Scene(camera_scene4, objects=[nucleus] + models.spot_lights)
Ejemplo n.º 21
0
def rdmb_povray_save(out_file,
                     vs,
                     ucs, vcs,
                     width=800, height=600,
                     rotx=0, roty=0, rotz=0,
                     angle=14):
    """Render and save RD results using Pov-Ray

    Render and save RD results using Pov-Ray

    Args:
        out_file: output file
        vs: vertices
        ucs, vcs: u/v conc.
        width, height: width and height of output image
        rotx, roty, rotz: rotation angle
        angle: camera angle

    """

    ucmax = 6.0
    ucs = ucs / ucmax
    ucs[ucs > 1.0] = 1.0
    # ucs = ucs / np.max(ucs)

    rot1 = [rotx, 0, 0]
    rot2 = [0, roty, 0]
    rot3 = [0, 0, rotz]

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')

    light = LightSource([-3, 2, -6], 'color', [1.0, 1.0, 1.0], 'parallel')
    light2 = LightSource([2, -2, -6], 'color', [0.6, 0.6, 0.6], 'parallel')
    background = Background('color', [1, 1, 1, 1])

    spheres = [Sphere(v, 0.02,
                      Finish('ambient', 0.2, 'diffuse', 0.8, 'phong', 1.0),
                      Texture(Pigment('color',
                                      [0.3+uc*0.7, 0.2+uc*0.8, 0.2+uc*0.8])),
                      'rotate', rot1,
                      'rotate', rot2,
                      'rotate', rot3) for v, uc in zip(vs, ucs)]

    objects = [light, light2, background] + spheres

    scene = Scene(camera, objects=objects)
    scene.render(out_file, width=width, height=height,
                 output_alpha=True, antialiasing=0.001,
                 tempfile=out_file+"__temp__.pov")
Ejemplo n.º 22
0
def splice_move_close(pos_1, pos_2):
    """ Merges the two splice complexes holding the pre-mRNA """
    left, right = pos_1[:], pos_2[:]
    left[0] *= 0.75
    right[0] *= 0.65
    left[1] *= -1
    right[1] *= -1
    splice_left = Sphere(left, SPLICE_SIZE, "scale", [1.5, -1, 0],
                         models.splice_model)
    splice_right = Sphere(right, SPLICE_SIZE, "scale", [2, -1, 0],
                          models.splice_model)

    text = Text(
        'ttf', '"timrom.ttf"',
        '"Two parts of the spliceosome seek out the beginning and the end of an intron"',
        0, 0, 'translate', [-15, -4.5, 5], 'scale', [1, 1, 1],
        models.text_model)
    text2 = Text(
        'ttf', '"timrom.ttf"',
        '"Their job is to bring them closer together and hand them over"', 0,
        0, 'translate', [-15, -6, 5], 'scale', [1, 1, 1], models.text_model)
    return [splice_left, splice_right, text, text2]
def sphere_circle():
    """ Creates a circle made up of 20 small spheres.
        A list of Sphere objects is returnded ready for rendering. """
    spheres = 20  # number of spheres to create
    ring = []
    ring_node_size = 0.6
    smodel = Texture(Pigment('color', [1, 0, 0], 'filter', 0.5),
                     Finish('phong', 0.8, 'reflection', 0.5))
    for i in range(spheres):
        ring.append(Sphere([0, 0, 0], ring_node_size, smodel,
                           'translate', [RADIUS, 0, 0],
                           'rotate', [0, 360/spheres * i, 0]))
    return ring
Ejemplo n.º 24
0
def s1_cell_overview():
    """ This scene is a single cell centered without any movement """
    cell_sphere = Sphere([0, 0, 0], 25, models.cell_model)

    text = Text('ttf', '"timrom.ttf"',
                '"To begin you first need to know that"', 0, 0, 'translate',
                [-14.5, -5, -30], 'scale', [2.5, 2.5, 1], models.text_model)
    text2 = Text('ttf', '"timrom.ttf"',
                 '"RNA Splicing takes place in the cell"', 0, 0, 'translate',
                 [-14.5, -6.25, -30], 'scale', [2.5, 2.5, 1],
                 models.text_model)
    return Scene(models.camera_scene1,
                 objects=[cell_sphere, text, text2] + models.lights_scene1)
Ejemplo n.º 25
0
def main():
    lookfrom = (13 / 1.5, 2 / 1.5, -5 / 1.5)
    lookat = (0, 0, 0)
    # dist_to_focus = 10.0
    # aperture = 0.1
    step = 1
    # camera
    camera = Camera('location', lookfrom, 'look_at', lookat)

    # background
    light = LightSource((0, 20, 0), 'color', (1, 1, 1))
    bg = Background('color', (0.5, 0.7, 1.0))
    base = Sphere((0, -1000, 0), 1000,
                  Texture(Pigment('color', (0.5, 0.5, 0.5))))
    htlist = [bg, base, light]
    for a in range(-11, 11, step):
        for b in range(-11, 11, step):
            choose_mat = random.random()
            center = (a + 0.9 * random.random(),
                      0.2, b + 0.9 * random.random())
            if distance(center, (4, 0.2, 0)) < 0.9:
                continue
            if choose_mat < 0.8:
                # diffuse
                color = (random.random() * random.random(),
                         random.random() * random.random(),
                         random.random() * random.random())
                htlist.append(
                    Sphere(center, 0.2, Texture(Finish('diffuse', 1), Pigment('color', color))))
            elif choose_mat < 0.95:
                # metal
                color = (0.5 * (1 + random.random()),
                         0.5 * (1 + random.random()),
                         0.5 * (1 + random.random()))
                # p1 = 0.5 * random.random()
                htlist.append(
                    Sphere(center, 0.2, Texture(Finish('Metal'), Pigment('color', color))))
            else:
                # glass
                htlist.append(Sphere(center, 0.2, Material('M_Glass')))

    # main 3 sphere
    htlist.append(
        Sphere((0, 1, 0), 1.0, Material('M_Glass')))
    htlist.append(
        Sphere((-4, 1, 0), 1.0, Texture(Finish('diffuse', 1), Pigment('color', (0.4, 0.2, 0.2)))))
    htlist.append(Sphere((4, 1, 0), 1.0, Texture('Chrome_Texture')))
    scene = Scene(camera, objects=htlist, included=[
                  'metals.inc', 'glass.inc', 'textures.inc', 'colors.inc'])
    with open("where-next.pov", "w") as ofp:
        print(str(scene), file=ofp)
    scene.render('where-next.png', width=800, height=600,
                 antialiasing=0.1, quality=10)
Ejemplo n.º 26
0
def frame(step):
    ''' Creates a sphere, boxes and cones and places it all in a scene '''
    colour_purple = Pigment('color', [
        1,
        0,
        1,
    ])
    colour_aquamarine = Pigment(
        'color',
        [0, 1, 1],
    )
    sphere = Sphere([0, 0, 0], 4, colour_purple)
    side_box_1 = Box(
        [4, -7, -4],
        [5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_2 = Box(
        [-4, -7, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_3 = Box(
        [5.5, 5.5, -4],
        [-5.5, 7, 4],
        colour_aquamarine,
    )
    side_box_4 = Box(
        [5.5, -5.5, -4],
        [-5.5, -7, 4],
        colour_aquamarine,
    )
    cone_1 = Cone([0, 7, 0], 3.5, [0, 11, 0], 0, colour_purple)
    cone_2 = Cone([0, -7, 0], 3.5, [0, -11, 0], 0, colour_purple)
    cone_3 = Cone([
        5.5,
        0,
    ], 3.5, [
        9.5,
        0,
    ], 0, colour_purple)
    cone_4 = Cone([-5.5, 0, 0], 3.5, [-9.5, 0, 0], 0, colour_purple)
    # Return the Scene object for rendering
    return Scene(models.default_camera,
                 objects=[
                     models.default_light, side_box_1, side_box_2, side_box_3,
                     side_box_4, cone_1, cone_2, cone_3, cone_4, sphere
                 ])
Ejemplo n.º 27
0
def scene(step):
    # Storing the cylinders
    cylinders = []
    n = 7
    for i in range(n):
        cylinders.append(
            Cylinder([0, 0, 0], [1.2, 0, 0], 1.0, 1.0, 'scale', [1, 0.25, 1],
                     'rotate', [-30, 0, 0], 'translate', [1.25, 0, 0],
                     'rotate', [0, i * 360 / n, 0], Texture('Chrome_Texture'),
                     Pigment('color', [0.1, 0.1, 0.1]),
                     Finish('phong', 1, 'reflection', 1)))

    # Reset color for the center sphere
    degrees = (360 / (SETTINGS.Duration * SETTINGS.RenderFPS)) * step

    prop = Blob(
        'threshold',
        0.65,
        # Add a Sphere with radius and strength = 1
        Sphere(
            [0, 0, 0],
            1.00,
            1.00,
            # Double the heigth of the Sphere
            'scale',
            [1, 2, 1],
            # Make it shine
            Texture('Chrome_Texture', Pigment('color', [0.1, 0.1, 0.1]),
                    Finish('phong', 0.5, 'reflection', 0.5))),
        # unpack cylinders
        *cylinders,
        # Scale the whole objects (enlarge)
        'scale',
        1.8,
        # rotate counter-clockwise
        'rotate',
        [90, 0, degrees],
        # re-center
        'translate',
        [0, 0.5, 0])

    camera = Camera('location', [5, 10, -8], 'look_at', [0, 0, 0])
    xyz_legend = legend([-10, 0, 0], 3)
    return Scene(
        camera,
        objects=[prop] + xyz_legend + povray.default_spots,
        # The 'Chrome_Texture comes from the 'textures.inc' file
        included=['textures.inc'])
Ejemplo n.º 28
0
def splicing_final():
    """ Provides the spliceosome and the text whilst the mrna forms """
    splice_down = Sphere([0, -1, 2], BIG_SPLICE_SIZE, "scale", [0, -1.25, 0],
                         models.splice_model)

    text = Text(
        'ttf', '"timrom.ttf"',
        '"The spliceosome now disconnects the intron and binds one end of"', 0,
        0, 'translate', [-15, -4.5, 5], 'scale', [1, 1, 1], models.text_model)
    text2 = Text(
        'ttf', '"timrom.ttf"',
        '"the intron to a suitable place on the other end of the intron."', 0,
        0, 'translate', [-15, -6, 5], 'scale', [1, 1, 1], models.text_model)
    text3 = Text(
        'ttf', '"timrom.ttf"',
        '"Meanwhile the exons get put together to form the finished mRNA"', 0,
        0, 'translate', [-15, -7.5, 5], 'scale', [1, 1, 1], models.text_model)
    return [splice_down, text, text2, text3]
Ejemplo n.º 29
0
def s3_in_cell():
    """ This scene makes it clear that the splicing process takes place in the nucleus """
    nucleus = Sphere([20, 7.5, 0], 7.5, models.nucleus_model)
    nucleus_text = Text('ttf', '"timrom.ttf"', '"Nucleus"', 0, 0, 'translate',
                        [6.75, 2.8, -7.6], 'scale', [2, 2, 0],
                        models.text_model)

    text = Text('ttf', '"timrom.ttf"',
                '"To be even more specific, the RNA splicing"', 0, 0,
                'translate', [-13.25, -4.2, -0], 'scale', [2.35, 2.35, 1],
                models.text_model)
    text2 = Text('ttf', '"timrom.ttf"',
                 '"takes place in the nucleus of the cell"', 0, 0, 'translate',
                 [-13.25, -5.4, -0], 'scale', [2.35, 2.35, 1],
                 models.text_model)
    return Scene(models.camera_scene3,
                 objects=[nucleus, nucleus_text, text, text2] +
                 models.spot_lights)
Ejemplo n.º 30
0
def render_povray(vs, rotx=0, roty=0, rotz=0,
                  width=400, height=400, angle=14, antialiasing=0.001):
    """Render vertices using Pov-Ray (Vapory)

    Render vertices using Pov-Ray (Vapory)

    Args:
        vs: vertices
        rotx, roty, rotz: rotation angle
        width, height:
        angle: camera angle

    Returns:
        rendered_scene:

    """

    rot1 = [rotx, 0, 0]
    rot2 = [0, roty, 0]
    rot3 = [0, 0, rotz]

    camera = Camera('location', [0, 0, -25],
                    'look_at', [0, 0, 0],
                    'angle', angle,
                    'right x*image_width/image_height')

    light = LightSource([-3, 2, -6], 'color', [1.0, 1.0, 1.0], 'parallel')
    light2 = LightSource([2, -2, -6], 'color', [0.6, 0.6, 0.6], 'parallel')
    background = Background('color', [1, 1, 1])

    spheres = [Sphere(v, 0.05,
                      Finish('ambient', 0.2, 'diffuse', 0.8, 'phong', 1.0),
                      Texture(Pigment('color', [1.0, 1.0, 1.0])),
                      'rotate', rot1,
                      'rotate', rot2,
                      'rotate', rot3) for v in vs]

    objects = [light, light2, background] + spheres

    scene = Scene(camera, objects=objects)

    return scene.render('ipython',
                        width=width, height=height,
                        antialiasing=antialiasing)