Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- """template for creating a functioning cotransporter sim. script"""
- __author__ = ""
- #imports
- import sys
- from pypovray import pypovray, SETTINGS, pdb, logger
- from vapory import Sphere, Scene, Pigment, Cylinder, Camera, Texture, Finish, Blob, LightSource
- #constants
- GLUT1_model = Texture(Pigment('color', [0, 1, 1], 'filter', 0),
- Finish('phong', 0, 'reflection', 0))
- phosphorkop_model = Texture(Pigment('color', [1, 0, 0], 'filter', 0),
- Finish('phong', 0, 'reflection', 0))
- phosphorsta_model = Texture(Pigment('color', [1, 0, 0], 'filter', 0),
- Finish('phong', 0, 'reflection', 0))
- Na_model = Texture(Pigment('color', [0, 1, 0], 'filter', 0),
- Finish('phong', 0, 'reflection', 0))
- camera = Camera('location', [-2, 8, 45], 'look_at', [0, 5, 0])
- light = LightSource([0, 0, 30], 0.8)
- Aant_lip = 20
- Begin_lip = -10
- #functions
- def objects():
- #create the blob, ions and glucose
- global Further_protein, phosphorkopbin, phosphorkopbuit, phosphorstabin, phosphorstabuit
- Further_protein = Sphere([2.5, 3.5, -3], 3, 'scale', [5, 1.5, 1.5], GLUT1_model)
- phosphorkopbuit = Sphere([0, 0, 0], 2.5, 1.75,phosphorkop_model)
- phosphorstabuit = Cylinder([0, 0, 0], [6.5, 0, 0], 1.25, 1,phosphorsta_model)
- phosphorkopbin = Sphere([6.5, 0, 0], 2.5, 1.75,phosphorkop_model)
- phosphorstabin = Cylinder([6.5, 0, 0], [0, 0, 0], 1.25, 1,phosphorsta_model)
- def membrane_outside():
- #Creates the outside membrane
- phosbuit = []
- for i in range(Aant_lip):
- y_coord = (Begin_lip + i) * 3.5
- if y_coord > 1 and y_coord < 8:
- pass
- else:
- phosbuit.append(Blob('threshold', .45, phosphorkopbuit, phosphorstabuit, 'translate', [6, y_coord, 0]))
- return phosbuit
- def membrane_inside():
- #Creates the inner membrane
- phosbin = []
- for i in range(Aant_lip):
- y_coord = ((Begin_lip + 3.5) + i) * 3.5
- if y_coord > 1 and y_coord < 9:
- pass
- else:
- phosbin.append(Blob('threshold', .45, phosphorkopbin, phosphorstabin, 'translate', [12, y_coord, 0]))
- return phosbin
- def gate_up(step, nframes):
- #Move the protein up
- start_step = 60
- end_step = 70
- y_coord = 0
- if step < end_step:
- if start_step < step < end_step:
- #This if function opens the gate
- y_start = 7
- y_end = 8
- elif step <= start_step:
- y_start = 7
- y_end = 7
- y_total = y_end - y_start
- total_distance_per_frame = y_total / nframes
- y_coord = y_start + (step * total_distance_per_frame)
- elif step >= end_step:
- y_coord = 8
- Upper_protein = Sphere([2.5, y_coord, 0], 3, 'scale', [5, 1.5, 1.5], GLUT1_model)
- return Upper_protein
- def gate_down(step, nframes):
- # Move the protein down
- start_step = 60
- end_step = 70
- y_coord = 0
- if step < end_step:
- if start_step < step < end_step:
- y_start = 0
- y_end = -1
- elif step <= start_step:
- y_start = 0
- y_end = 0
- y_total = y_end - y_start
- total_distance_per_frame = y_total / nframes
- y_coord = y_start + (step * total_distance_per_frame)
- elif step >= end_step:
- y_coord = -1
- Lower_protein = Sphere([2.5, y_coord, 0], 3, 'scale', [5, 1.5, 1.5], GLUT1_model)
- return Lower_protein
- def glu_move(step, nframes):
- #move the glucose through the blob
- start_step = 60
- use_step = step - start_step
- if step > start_step:
- x_start = -12
- x_end = 0
- else:
- x_start = -12
- x_end = -12
- x_total = x_end - x_start
- total_distance_per_frame = x_total / (.18 *nframes)
- x_coord = x_start + (use_step * total_distance_per_frame)
- GLUCOSE = pdb.PDBMolecule('{}/pdb/glucose-2.pdb'.format(SETTINGS.AppLocation), center=True, offset=[-12, 3.75, 0])
- GLUCOSE.move_to([x_coord, 3.75, 0])
- return GLUCOSE
- def ion_move(step, nframes):
- #move the ions through the blob
- if step > 20:
- x_start = -12
- x_end = 0
- else:
- x_start = -12
- x_end = -12
- x_total = x_end - x_start
- total_distance_per_frame = x_total / (.25 * nframes)
- x_coord = x_start + step * total_distance_per_frame
- Na_ion = Sphere([x_coord, 9.5, 0], 2.04, Na_model)
- return Na_ion
- def transparant(step):
- #make the blob transparant as soon as the glucose and ions go in
- filter_col = 0
- Nearest_Protein = []
- if step > 20:
- filter_col += 0.1 * (step/5)
- if filter_col >= .8:
- filter_col = .8
- Nearest_protein = Sphere([2.5, 3.5, 3], 3, 'scale', [5, 1.5, 1.5],
- Texture(Pigment('color', [0, 1, 1], 'filter', filter_col),
- Finish('phong', 0, 'reflection', 0)))
- Nearest_Protein.append(Nearest_protein)
- return Nearest_Protein
- def frame(step):
- #here goes all scene thingy's
- logger.info(" @Step: %s", step)
- # Getting the total number of frames, see the configuration file
- nframes = eval(SETTINGS.NumberFrames)
- phosbuit = membrane_outside()
- phosbin = membrane_inside()
- GLUCOSE = glu_move(step, nframes)
- Nearest_Protein = transparant(step)
- Na_ion = ion_move(step, nframes)
- Upper_protein = gate_up(step, nframes)
- Lower_protein = gate_down(step, nframes)
- return Scene(camera,
- objects=[light, Further_protein, Upper_protein, Lower_protein, Na_ion] + GLUCOSE.povray_molecule + phosbuit + phosbin + Nearest_Protein)
- #main
- def main(args):
- #prep
- objects()
- #work
- pypovray.render_scene_to_mp4(frame)
- #pypovray.render_scene_to_png(frame, 1)
- #finalize
- return 0
- if __name__ == '__main__':
- exitcode = main(sys.argv)
- sys.exit(exitcode)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement