Exemplo n.º 1
0
def create_molecules():
    """ Creates the molecules """
    global GUANINE, ADENINE, CYTOSINE, URACIL

    GUANINE = pdb.PDBMolecule('{}/pdb/GMP.pdb'.format(SETTINGS.AppLocation),
                              center=True)
    ADENINE = pdb.PDBMolecule('{}/pdb/AMP.pdb'.format(SETTINGS.AppLocation),
                              center=True)
    CYTOSINE = pdb.PDBMolecule('{}/pdb/CMP.pdb'.format(SETTINGS.AppLocation),
                               center=True)
    URACIL = pdb.PDBMolecule('{}/pdb/UMP.pdb'.format(SETTINGS.AppLocation),
                             center=True)
Exemplo n.º 2
0
def create_molecules():
    """ Creates the molecules """
    global GUANINE, ADENINE, CYTOSINE, URACIL_ONE, ADENINE_TWO

    GUANINE = pdb.PDBMolecule('{}/pdb/GMP.pdb'.format(SETTINGS.AppLocation),
                              offset=[-100, 0, 0])
    ADENINE = pdb.PDBMolecule('{}/pdb/AMP.pdb'.format(SETTINGS.AppLocation),
                              offset=[-100, 0, 0])
    CYTOSINE = pdb.PDBMolecule('{}/pdb/CMP.pdb'.format(SETTINGS.AppLocation),
                               offset=[-100, 0, 0])
    URACIL_ONE = pdb.PDBMolecule('{}/pdb/UMP.pdb'.format(SETTINGS.AppLocation),
                                 offset=[-100, 0, 0])
    ADENINE_TWO = pdb.PDBMolecule('{}/pdb/AMP.pdb'.format(
        SETTINGS.AppLocation),
                                  offset=[-100, 0, 0])
Exemplo n.º 3
0
def alphact_conformational_change(frame, alphact_stage_one_sliced, alphact_stage_two_sliced):
    """
    This function simulation the conformational change of the alpha ct peptide with the
    alpha helix of the insulin molecule
    """
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False)
    INSULIN_RECEPTOR.move_to([0,0,0])
    frame_start = 270 #the first frame when this function is called upon
    
    for num in range(10014, 10115):
        if num < (frame - frame_start) * round(101/60) + 10014:
            if num not in alphact_stage_two_sliced:
                #remove a portion of the atoms that are not in second stage based on the current frame
                alphact_stage_one_sliced.remove(num)
    for num in range(10171, 10211):
        if num < (frame - frame_start) * round(40/60) + 10171:
            #add a portion of atoms that are not in the first stage based on the current frame
            alphact_stage_one_sliced.append(num)

    alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(alphact_stage_one_sliced, 'alphact_one')
    rotation = (frame - frame_start - 60) * -0.01 #set a number for the amount the molecule should rotate based on the frame
    alphact_stage_one_sliced_mol.rotate([0,0,1], rotation) #rotate the molecule on the z axis with the rotation variable
                
    insulin_alpha = INSULIN_RECEPTOR.divide(ATOM_POS["N"], "alphact_two")
    insulin_alpha.move_offset([0,30,0])
                
    return alphact_stage_one_sliced_mol, insulin_alpha
Exemplo n.º 4
0
def molecules():
    """ Creates molecules and contains other constants """
    global ETHANOL

    ETHANOL = pdb.PDBMolecule('{}/pdb/ethanol.pdb'.format(
        SETTINGS.AppLocation),
                              center=True)
Exemplo n.º 5
0
def make_molecules(molecules):
    """
    make_molecules([frame, molecules])
    """
    for obj in ANIMATION_OBJECTS:
        molecule_data = ANIMATION_OBJECTS[obj]["molecule"]

        if molecule_data[0] and not molecule_data[1]:
            # Making normal molecules from pdb file
            mol = pdb.PDBMolecule(molecule_data[2], center=True)
            molecule = {
                "molecule": mol,
                "reset": [0, mol.atoms.copy()],
                "text": None
            }

        elif not molecule_data[0]:
            # Making basic vapory objects
            molecule = {"molecule": molecule_data[1:]}

        else:
            # Make the molecule a None object until it is time to split the moleucle
            molecule = None

        molecules[obj] = molecule
    return molecules
Exemplo n.º 6
0
def frame(step):
    """ Renders an Ethanol molecule centered in the scene """
    # Dit is een beetje dubbel maar zonder gaat er opnieuw iets mis met self.atom
    ETHANOL = pdb.PDBMolecule('{}/pdb/ethanol.pdb'.format(
        SETTINGS.AppLocation),
                              center=True)
    camera = Camera('location', [10, 0, 0], 'look_at', [0, 0, 0])
    nframes = eval(SETTINGS.NumberFrames)
    hele_rotatie = 2 * math.pi

    # When step is below or equal to 40, the ethanol molecule is devided into 2 parts.
    if step <= (nframes / 2):
        y_ass = (1 / (nframes / 2)) * step
        splitsing = ETHANOL.divide([7, 8], 'ethanol', offset=[0, y_ass, 0])

    else:
        # In the second half of the program, last 40 frames we rotate the molecules 360 degrees.
        y_ass = (1 / (nframes / 2)) * 40
        splitsing = ETHANOL.divide([7, 8], 'ethanol', offset=[0, y_ass, 0])
        step = step - 40
        rotatie_per_step = (hele_rotatie / nframes) * step
        ETHANOL.rotate([1, 0, 0], rotatie_per_step)
        splitsing.rotate([1, 0, 0], rotatie_per_step)

    # Return the Scene object for rendering.
    return Scene(camera,
                 objects=[models.default_light] + ETHANOL.povray_molecule +
                 splitsing.povray_molecule,
                 included=['colors.inc'])
def frame(step):
    global NUCL_1, NUCL_2, NUCL_3, NUCL_4, NUCL_5, NUCL_6, NUCL_7

    RNA = pdb.PDBMolecule('{}/pdb/RNA2.pdb'.format(SETTINGS.AppLocation), offset=[-100, 0, 0])
    # RNA.show_label(camera=models.default_camera, name=True)
    RNA.rotate([0, 1, 1], [0, 3.14, 3.14])

    nucleotide_atoms = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]

    NUCL_1 = RNA.divide(nucleotide_atoms, 'nucleotide_1')
    NUCL_2 = RNA.divide(nucleotide_atoms, 'nucleotide_2')
    NUCL_3 = RNA.divide(nucleotide_atoms, 'nucleotide_3')
    NUCL_4 = RNA.divide(nucleotide_atoms, 'nucleotide_4')
    NUCL_5 = RNA.divide(nucleotide_atoms, 'nucleotide_5')
    NUCL_6 = RNA.divide(nucleotide_atoms, 'nucleotide_6')
    NUCL_7 = RNA.divide(nucleotide_atoms, 'nucleotide_7')


    if step < 15:
        RNA.move_to([0, 0, 0])


    return Scene(Camera('location', [0, 0, -50], 'look_at', [0, 0, 0]),
                 objects=[models.default_light] + NUCL_1.povray_molecule + NUCL_4.povray_molecule)
def molecule():
    """ Creates a molecule for rendering """
    global VIAGRA
    VIAGRA = pdb.PDBMolecule('{}/pdb/viagra.pdb'.format(SETTINGS.AppLocation),
                             center=True)
    VIAGRA.move_offset([0, 1, 0])
    VIAGRA.scale_atom_distance(1.75)
Exemplo n.º 9
0
def alphains_bonded_to_alphact(frame, alphact_stage_two_sliced):
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False)
    INSULIN_RECEPTOR.move_to([0,0,0])
    alphact_complex_insulinalpha_pos = alphact_stage_two_sliced + ATOM_POS["N"] #create a list of atom positions from insulin and the peptide
    #create a molecule that is insulin in complex with the peptide
    alphact_complex_insulinalpha_mol = INSULIN_RECEPTOR.divide(alphact_complex_insulinalpha_pos, 'alphact_complex_insulinalpha')

    return alphact_complex_insulinalpha_mol
Exemplo n.º 10
0
def molecule_maker(mol1, mol2, name):
    """Combines two molecules into one"""
    combo = mol1.atoms
    while len(mol2.atoms) > 0:
        combo += [mol2.atoms.pop(0)]
    final_combo = pdb.PDBMolecule(name, atoms=combo, center=False)
    final_combo.render_molecule()
    return final_combo
Exemplo n.º 11
0
def create_molecules():
    """ Creates the molecules """
    global NUCL_1, NUCL_2, NUCL_3, NUCL_4, NUCL_5, NUCL_6, NUCL_7, RNA_2, RNA_1

    # Create first RNA molecule
    RNA_1 = pdb.PDBMolecule('{}/pdb/RNA.pdb'.format(SETTINGS.AppLocation))
    RNA_1.rotate([0, 1, 1], [0, pi, pi])

    # Create second RNA molecule
    RNA_2 = pdb.PDBMolecule('{}/pdb/RNA.pdb'.format(SETTINGS.AppLocation))
    RNA_2.rotate([0, 1, 1], [0, pi, pi])

    # Create RNA molecule for the making of nucleotides
    rna_to_nucl = pdb.PDBMolecule('{}/pdb/RNA.pdb'.format(
        SETTINGS.AppLocation))
    rna_to_nucl.rotate([0, 1, 1], [0, pi, pi])

    # Determine which atoms make the nucelotides
    nucleotide_atoms = [
        0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
        20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31
    ]

    # Creating all the different molecules
    NUCL_1 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_1',
                                offset=[-70, 0, 0])
    NUCL_2 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_2',
                                offset=[-70, 0, 0])
    NUCL_3 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_3',
                                offset=[-70, 0, 0])
    NUCL_4 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_4',
                                offset=[-70, 0, 0])
    NUCL_5 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_5',
                                offset=[-70, 0, 0])
    NUCL_6 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_6',
                                offset=[-70, 0, 0])
    NUCL_7 = rna_to_nucl.divide(nucleotide_atoms,
                                'nucleotide_7',
                                offset=[-70, 0, 0])
Exemplo n.º 12
0
def insulin_bonded_to_ectodomain(frame):
    """
    Showing the complete ectodomain of the insulin receptor in complex with one insulin molecule
    """
    light = LightSource([0, 0, -100], 'color', [1, 1, 1])
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False)
    INSULIN_RECEPTOR.move_to([0,0,0])
    
    return INSULIN_RECEPTOR, light
Exemplo n.º 13
0
def alphains_binding_alphact(frame, alphact_stage_two_sliced): 
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False)
    INSULIN_RECEPTOR.move_to([0,0,0])
    alphact_stage_two_sliced_mol = INSULIN_RECEPTOR.divide(alphact_stage_two_sliced, 'alphact_two')
    insulin_alpha = INSULIN_RECEPTOR.divide(ATOM_POS["N"], "insulin_alpha")
    frame_start = 330

    insulin_offset = (60 - ( frame - frame_start + 1)) / 2 #move the insulin towards the alpha peptide 
    insulin_alpha.move_offset([0,insulin_offset,0])

    return alphact_stage_two_sliced_mol, insulin_alpha
Exemplo n.º 14
0
def amino_maker(triplet):
    """Genereerd een aminozuur bij een triplet.
    args: triplet: Het triplet waar het aminozuur bij ge genereerd moet worden.
    return: De PDBMolecule van het aminozuur"""

    locatie = '{a}/pdbeind/{b}.pdb'
    aminozuur = bintemplate.TRIPLETTOAMINO[triplet]
    amino = pdb.PDBMolecule(locatie.format(a=SETTINGS.AppLocation,
                                           b=aminozuur),
                            center=True)
    return amino
def scene_objects():
    """ Creates molecule objects and any other pre-calculated data """
    global ETHANOL, VIAGRA, BENZENE, RAD_PER_SCENE, FRONT_LIGHT

    FRONT_LIGHT = LightSource([0, 14, -28], 'color', [1, 0.8, 0.4],
                              'fade_distance', 6, 'fade_power', 2,
                              'area_light', 3, 3, 12, 12,
                              'circular orient adaptive', 0)

    # Calculate the radians per scene
    RAD_PER_SCENE = (math.pi / 180) * 3

    # Read in a PDB file and construct a molecule
    ETHANOL = pdb.PDBMolecule('pdb/ethanol.pdb',
                              center=False,
                              offset=[-10, 8, -5])
    VIAGRA = pdb.PDBMolecule('pdb/viagra.pdb',
                             center=False,
                             offset=[3, -3, -7])
    BENZENE = pdb.PDBMolecule('pdb/benzene.pdb',
                              center=False,
                              offset=[0, 8, -5])
Exemplo n.º 16
0
def bind_insuline_complete_ectodomain(frame):
    """
    Animating the insuline binding to the insulin receptor ectodomain part
    """
    light = LightSource([0, 0, -100], 'color', [1, 1, 1])
    INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_PDB, center=False) #create a the insulin receptor molecule from the pdb-file
    INSULIN_RECEPTOR.move_to([0,0,0]) #move the insulin receptor to the middle of the simulation
   
    insulin = INSULIN_RECEPTOR.divide(INSULIN_ATOM, 'insulin') #create the insulin molecule by dividing the insulin receptor
    y = 120 - ( 2 * (frame - 180) ) #setting a y-coordinate for insulin so it moves to the receptor
    insulin.move_offset([0, y, 0]) #move the insulin from its original pos to one with the y-coordinate
    
    return INSULIN_RECEPTOR, insulin, light
Exemplo n.º 17
0
def frame(step):
    global LIPID

    LIPID = pdb.PDBMolecule('{}/pdb/lipid_test.pdb'.format(
        SETTINGS.AppLocation),
                            offset=[-100, 0, 0])
    # RNA.show_label(camera=models.default_camera, name=True)
    # RNA.rotate([0, 1, 1], [0, 3.14, 3.14])

    if step < 15:
        LIPID.move_to([0, 0, 0])

    return Scene(Camera('location', [0, 0, -350], 'look_at', [0, 0, 0]),
                 objects=[models.default_light] + LIPID.povray_molecule)
def create_molecules():
    """ Creates the molecules """
    global GTP, GUANINE

    GTP = pdb.PDBMolecule('{}/pdb/gtp.pdb'.format(SETTINGS.AppLocation),
                          center=True)
    GTP.rotate([1, 1, 1], [pi * 1.5, pi, pi / 2])
    GTP.divide([11, 12, 13, 14, 15, 16, 17, 18], 'phosphate', offset=[
        0, 0, 0
    ])  # removes two phosphate groups to create guanine nucleotide
    GUANINE = GTP.divide(
        [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 28, 29, 34, 35],
        'guanine',
        offset=[4, 0, 0])  # splits into ribose-phosphate and the guanine base
Exemplo n.º 19
0
def scene_objects():
    """ Creates molecule objects and any other pre-calculated data """
    global ATP, FRONT_LIGHT

    # Create a light source including some effects
    FRONT_LIGHT = LightSource([0, 5, -29], 'color', [1, 1, 1],
                              'fade_distance', 15, 'fade_power', 2,
                              'area_light', 3, 3, 12, 12,
                              'circular orient adaptive', 0)

    # Read in a PDB file and construct a molecule
    ATP = pdb.PDBMolecule('pdb/ATP_ideal.pdb', center=False)
    # Move to the center, and raise a little
    ATP.move_to([0, 6, 0])
    # Rotate so that the N-tail points downwards a bit
    ATP.rotate([0, 1, 1], [0, 1.5, -0.7])
Exemplo n.º 20
0
def frame(step):
    """ Renders an ATP molecule centered in the scene """
    # 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)

    # Calculates distance per frame for the to be splitted molecule parts
    x_start = 0
    x_end = 8
    x_distance = x_end - x_start
    x_distance_per_frame = (x_distance / (n_frames / 2))

    # Variables used for rotating of molecules
    full_circle = 2 * pi  # One full circle equals exactly 2 times pi
    rotation_per_frame = full_circle / (n_frames / 2)

    # creating the nucleotide
    gtp = pdb.PDBMolecule('{}/pdb/gtp.pdb'.format(SETTINGS.AppLocation),
                          center=True)
    gtp.rotate([1, 1, 1], [pi * 1.5, pi, pi / 2])
    gtp.divide([11, 12, 13, 14, 15, 16, 17, 18], 'phosphate', offset=[
        0, 0, 0
    ])  # removes two phosphate groups to create guanine nucleotide
    guanine = gtp.divide(
        [13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 28, 29, 34, 35],
        'base',
        offset=[4, 0, 0])  # splits into ribose-phosphate and the gaunine base

    # In the first half of the animation: split the guanine nucleotide into guanine and ribose-phosphate
    if step in range(0, n_frames // 2):
        gtp.move_to([-step * x_distance_per_frame, 0, 0])
        guanine.move_to([step * x_distance_per_frame, 0, 0])

    # In the second half of the animation: rotate both molecules one full circle
    if step in range(n_frames // 2, n_frames):
        gtp.rotate([0, 1, 0], rotation_per_frame * (step - (n_frames / 2)))
        guanine.rotate([1, 0, 0], rotation_per_frame * (step - (n_frames / 2)))
        gtp.move_to([-n_frames // 2 * x_distance_per_frame, 0, 0])
        guanine.move_to([n_frames // 2 * x_distance_per_frame, 0, 0])

    # Return the Scene object for rendering
    return Scene(models.floor_camera,
                 objects=[models.default_light] + gtp.povray_molecule +
                 guanine.povray_molecule)
Exemplo n.º 21
0
def scene_objects():
    """ Creates molecule objects and any other pre-calculated data """
    global ETHANOL, RAD_PER_SCENE, FRONT_LIGHT, TRACER

    FRONT_LIGHT = LightSource([0, 14, -28], 'color', [1, 0.8, 0.4],
                              'fade_distance', 6, 'fade_power', 2,
                              'area_light', 3, 3, 12, 12,
                              'circular orient adaptive', 0)

    # Calculate the radians per scene (one full rotation)
    RAD_PER_SCENE = (math.pi / eval(pypovray.SETTINGS.NumberFrames)) * 2
    # Create a list holding the 'tracing' spheres that are drawn as the molecule moves
    TRACER = []
    # Read in a PDB file and construct a molecule
    ETHANOL = pdb.PDBMolecule('pdb/ethanol.pdb',
                              center=False,
                              offset=[-10, 8, -5])
Exemplo n.º 22
0
def nucleo_maker(nucleo_str):
    """Voegt voor elke nucleotide in de nucleotide string een 3d structuur en voegt deze
    aan een list toe.
    Args: nucleo_str: een string van nucleotiden"""
    global nucleomoddel_list
    naam = ""
    for nucleotide in nucleo_str:
        if nucleotide == 'A':
            naam = '{}/pdbeind/Adenine.pdb'
        elif nucleotide == 'U':
            naam = '{}/pdbeind/Uracil.pdb'
        elif nucleotide == 'C':
            naam = '{}/pdbeind/Guanine.pdb'
        elif nucleotide == 'G':
            naam = '{}/pdbeind/Thymine.pdb'
        nucleomoddel_list.append(
            pdb.PDBMolecule(naam.format(SETTINGS.AppLocation), center=True))
def create_molecules():
    """ Creates the molecules """
    global NUCL_1, NUCL_2, NUCL_3, NUCL_4, NUCL_5, NUCL_6, NUCL_7, RNA

    RNA = pdb.PDBMolecule('{}/pdb/RNA2.pdb'.format(SETTINGS.AppLocation)) #, offset=[-100, 0, 0])
    # RNA.show_label(camera=models.default_camera, name=True)
    RNA.rotate([0, 1, 1], [0, pi, pi])

    nucleotide_atoms = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
                        21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]

    NUCL_1 = RNA.divide(nucleotide_atoms, 'nucleotide_1', offset=[-50, 0, 0])
    NUCL_2 = RNA.divide(nucleotide_atoms, 'nucleotide_2', offset=[-50, 0, 0])
    NUCL_3 = RNA.divide(nucleotide_atoms, 'nucleotide_3', offset=[-50, 0, 0])
    NUCL_4 = RNA.divide(nucleotide_atoms, 'nucleotide_4', offset=[-50, 0, 0])
    NUCL_5 = RNA.divide(nucleotide_atoms, 'nucleotide_5', offset=[-50, 0, 0])
    NUCL_6 = RNA.divide(nucleotide_atoms, 'nucleotide_6', offset=[-50, 0, 0])
    NUCL_7 = RNA.divide(nucleotide_atoms, 'nucleotide_7', offset=[-50, 0, 0])
Exemplo n.º 24
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)

    # Create molecule
    atp = pdb.PDBMolecule('{}/pdb/ATP_ideal.pdb'.format(SETTINGS.AppLocation),
                          center=True)
    atp.move_to([0, 5, 0])

    # Creates phospate sliced molecule
    phosphate = atp.divide([0, 1, 2, 3, 7, 31, 32], 'phosphate')

    # Creates other objects
    camera = Camera('location', [25, 5, 10], 'look_at', [0, 5, 0])
    light = LightSource([25, 5, 10], 'color', [1, 1, 1])

    # Splicing the molecules animation
    if step <= 20 and step > 5:
        y = (0 - 4 / 15) * (step - 5)  # Moves for 15 frames, -4x in total
        phosphate.move_offset([0, y, 0])

    # Keeping the phospate in it's position after it moved
    elif step > 5:
        y = (0 - 4 / 15) * (
            20 - 5)  # Moves it like the 20th frame to keep it's position
        phosphate.move_offset([0, y, 0])

        # Rotating the molecules
        if step >= 30 and step < 70:
            phosphate.rotate([1, 0, 0], np.pi * 2 / 40 *
                             (step - 30))  # Rotates it for 40 frames, 1 - 2pi
            atp.rotate([0, 1, 0], np.pi * 2 / 40 * (step - 30))

    # Return the Scene object containing all objects for rendering
    return Scene(
        camera,
        objects=[models.checkered_ground, models.default_light, light] +
        atp.povray_molecule + phosphate.povray_molecule)
def molecules():
    ''' Creates molecules and contains other constants '''
    global Molecule_name
    Molecule_name = pdb.PDBMolecule('{}/pdb/nameofyourmolecule.pdb'.format(
        SETTINGS.AppLocation),
                                    center=True)
Exemplo n.º 26
0
def create_ethanol():
    from pypovray import pypovray, SETTINGS, models, logger, pdb
    from vapory import Sphere, Scene, LightSource, Camera
    path = "/homes/kdijkstra/thema2/pdb/ethanol.pdb"
    ethanol = pdb.PDBMolecule(path, center=False, offset=[-10, 8, -5])
    return ethanol
Exemplo n.º 27
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)

    if step < 31:
        ins_id, atom_pos = get_ins(PATH_LINUX)

        camera = Camera('location', [0, 0, -300], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])

        insulin_pos = atom_pos["N"] + atom_pos["O"]
        #these need to be removed because the used insulin (b chain) is from a sheep, for humans the last aa must be removed
        insulin_pos.remove(9997)
        insulin_pos.remove(9998)
        insulin_pos.remove(9999)
        insulin_pos.remove(10000)
        insulin_pos.remove(10001)
        insulin_pos.remove(10002)

        INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_LINUX,
                                           center=False,
                                           offset=[-10, 8, -5])
        INSULIN_RECEPTOR.move_to([0, 0, 0])
        insulin = INSULIN_RECEPTOR.divide(insulin_pos, 'insulin')
        #insulin.move_to([-100,0,0])
        x = (30 * 0.1) - (0.1 * step)
        y = (30 * 2) - (2 * step)
        insulin.move_offset([x, y, 0])

    if step > 30:
        camera = Camera('location', [-40, 0, -200], 'look_at', [0, 0, 0])
        light = LightSource([0, 0, -100], 'color', [1, 1, 1])

        ins_id, atom_pos = get_ins(PATH_LINUX)
        alphact = atom_pos["P"]
        alphact_stage_one_sliced = []
        alphact_stage_two_sliced = []

        INSULIN_RECEPTOR = pdb.PDBMolecule(PATH_LINUX,
                                           center=False,
                                           offset=[-10, 8, -5])
        INSULIN_RECEPTOR.move_to([0, 0, 0])

        for pos in alphact:
            if pos in range(10014, 10171):
                alphact_stage_one_sliced.append(pos)
            if pos in range(10115, 10211):
                alphact_stage_two_sliced.append(pos)

        if step == 31:
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_one_sliced, 'alphact_one')
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 32:
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 33:
            alphact_stage_one_sliced += atom_pos["N"]
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_one_sliced, 'alphact_one')
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 34:
            alphact_stage_two_sliced += atom_pos["N"]
            alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            alphact_stage_one_sliced_mol.move_to([0, 0, 0])
        if step == 35:
            alphact_stage_two_sliced_mol = INSULIN_RECEPTOR.divide(
                alphact_stage_two_sliced, "alphact_two")
            insulin_alpha = INSULIN_RECEPTOR.divide(atom_pos["N"],
                                                    "alphact_two")
            alphact_stage_two_sliced_mol.move_to([0, 0, 0])
            insulin_alpha.move_to([50, 0, 0])
            return Scene(camera,
                         objects=[light] + insulin_alpha.povray_molecule +
                         alphact_stage_two_sliced_mol.povray_molecule)

        #simulation
        step_start = 36
        if step >= step_start:
            if step <= step_start + 10:

                for num in range(10014, 10115):
                    if num < (step - step_start) * round(101 / 10) + 10014:
                        if num not in alphact_stage_two_sliced:
                            alphact_stage_one_sliced.remove(num)
                for num in range(10171, 10211):
                    if num < (step - step_start) * round(40 / 10) + 10171:
                        alphact_stage_one_sliced.append(num)

                alphact_stage_one_sliced_mol = INSULIN_RECEPTOR.divide(
                    alphact_stage_one_sliced, 'alphact_one')
                rotation = (step - step_start - 10) * -0.1
                alphact_stage_one_sliced_mol.rotate([0, 0, 1], rotation)

                insulin_alpha = INSULIN_RECEPTOR.divide(
                    atom_pos["N"], "alphact_two")
                insulin_alpha.move_offset([0, 30, 0])

                return Scene(camera,
                             objects=[light] +
                             alphact_stage_one_sliced_mol.povray_molecule +
                             insulin_alpha.povray_molecule)
            elif step > step_start + 10 and step <= step_start + 20:
                alphact_stage_two_sliced_mol = INSULIN_RECEPTOR.divide(
                    alphact_stage_two_sliced, "alphact_two")
                return Scene(camera,
                             objects=[light] +
                             alphact_stage_two_sliced_mol.povray_molecule)

    return Scene(camera,
                 objects=[light] +
                 alphact_stage_one_sliced_mol.povray_molecule)
Exemplo n.º 28
0
__author__ = 'Gijs Bakker, Niek Scholten'

import sys
from math import pi
import nonpov
import bintemplate
from pypovray import pypovray, SETTINGS, pdb
from vapory import Scene, Camera, LightSource

nucleomoddel_list = []
triplet_list = []
key_cycle = 0
aminomoddel_list = []
AMINO_AFSTAND = 41
key = pdb.PDBMolecule('{}/pdbeind/tRNA.pdb'.format(SETTINGS.AppLocation),
                      center=True)


def nucleo_maker(nucleo_str):
    """Voegt voor elke nucleotide in de nucleotide string een 3d structuur en voegt deze
    aan een list toe.
    Args: nucleo_str: een string van nucleotiden"""
    global nucleomoddel_list
    naam = ""
    for nucleotide in nucleo_str:
        if nucleotide == 'A':
            naam = '{}/pdbeind/Adenine.pdb'
        elif nucleotide == 'U':
            naam = '{}/pdbeind/Uracil.pdb'
        elif nucleotide == 'C':
            naam = '{}/pdbeind/Guanine.pdb'
def create_molecules():
    """ Creates the molecules """
    global GUANINE, ADENINE

    GUANINE = pdb.PDBMolecule('{}/pdb/GMP.pdb'.format(SETTINGS.AppLocation), offset=[-100, 0, 0])
    ADENINE = pdb.PDBMolecule('{}/pdb/AMP.pdb'.format(SETTINGS.AppLocation), offset=[-100, 0, 0])