コード例 #1
0
def vis(res,
        path_prefix,
        c=["firebrick", "forest", 'purple', 'salmon', "gold", "red"]):

    for ind, r in enumerate(res):
        for a in r.atoms:
            cmd.show("spheres", "id " + str(a.id))
            cmd.set("sphere_color", c[ind], "id " + str(a.id))
        cmd.distance("d" + str(ind), "id " + str(r.atoms[0].id),
                     "id " + str(r.atoms[1].id))
        cmd.hide("labels")
        cmd.set("grid_slot", -2, "d" + str(ind))

    cmd.ray(1200)
    time.sleep(2)
    cmd.set("grid_mode", 0)
    cmd.png(path_prefix + "_restraints.png")
    #cmd.set("grid_mode", 1)
    cmd.move("zoom", -10)

    cmd.ray(1200, )
    time.sleep(4)
    cmd.png(path_prefix + "_grid_restraints.png")
    cmd.set("grid_mode", 0)
    cmd.hide("spheres")
    cmd.delete("d*")
コード例 #2
0
def save_image_closeup(filename, width=ray_width_closeups(), height=ray_height_closeups()):
    cmd.bg_color("white")
#    cmd.ray(ray_width_closeups(), ray_height_closeups())
    cmd.ray(width, height)
    cmd.png("./output/" + filename + ".png", dpi=dpi())
    cmd.bg_color("black")
    return 
コード例 #3
0
def stereo_ray(filename, width=0, height=0, quiet=1):
    '''
DESCRIPTION

   "stereo_ray" ray-traces the current scene twice (separated by 
   a six-degree rotation around the y axis)
   and saves a pair of images that can be combined in any image
   manipulation software to form a stereoimage.
   The first argument, the output file name, is mandatory.
   The second and third arguments, the size of the image, are not.
   If the width is given, the height will be calculated.
 
USAGE

   stereo_ray filename [, width [, height]]
 
EXAMPLE

   stereo_ray output, 1000, 600
   stereo_ray secondImage.png
   '''
    if filename.lower().endswith('.png'):
        filename = filename[:-4]

    cmd.ray(width, height, angle=-3)
    cmd.png(filename + "_r", quiet=quiet)
    cmd.ray(width, height, angle=3)
    cmd.png(filename + "_l", quiet=quiet)
コード例 #4
0
ファイル: stereo_ray.py プロジェクト: 8848/Pymol-script-repo
def stereo_ray(filename, width=0, height=0, quiet=1):
    """
DESCRIPTION

   "stereo_ray" ray-traces the current scene twice (separated by 
   a six-degree rotation around the y axis)
   and saves a pair of images that can be combined in any image
   manipulation software to form a stereoimage.
   The first argument, the output file name, is mandatory.
   The second and third arguments, the size of the image, are not.
   If the width is given, the height will be calculated.
 
USAGE

   stereo_ray filename [, width [, height]]
 
EXAMPLE

   stereo_ray output, 1000, 600
   stereo_ray secondImage.png
   """
    if filename.lower().endswith(".png"):
        filename = filename[:-4]

    cmd.ray(width, height, angle=-3)
    cmd.png(filename + "_r", quiet=quiet)
    cmd.ray(width, height, angle=3)
    cmd.png(filename + "_l", quiet=quiet)
コード例 #5
0
def render_to_file(fname, top=True, side=True, vesicle=False,
                   zoom_obj="pbcbox",
                   zoom_distance=10):
    fname = os.path.splitext(fname)[0]

    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
    if top:
        cmd.ray("2048")
        cmd.png("%s_top.png" % fname)

    if side:
        cmd.turn("x", -90)
        if vesicle:
            cmd.move("y", 150)
        cmd.ray("2048")
        cmd.png("%s_side.png" % fname)
    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
コード例 #6
0
    def test(self):
        cmd.fragment('ala')
        cmd.ray(100, 100)
        img = self.get_imagearray() # cmd.png without optional arguments

        # bug was: ray tracing twice, second time would not be 100x100
        self.assertEqual(img.shape[:2], (100,100))
コード例 #7
0
def abl(*files, **kwargs):
    MdsPymol.reset(options)

    if 'optionsFile' in kwargs:
        execfile(kwargs['optionsFile'], globals(), locals())

    for file in files:
        print "Processing file '%s'." % file
        fileOptions = perMapOptions.get(file, {})
        # Add a CGO prefix if we have multiple files and a prefix was not given.
        if len(files) > 1 and 'cgo prefix' not in fileOptions:
            basename, _ = os.path.splitext(os.path.basename(file))
            fileOptions['cgo prefix'] = basename + '_'
        mapOptions = defaultMapOptions.copy()
        restrictedUpdate(mapOptions, fileOptions)
        ACmap(file, mapOptions)

    # Process global options.

    cmd.clip('far', -20.0)
    #cmd.clip('near', 100.0)

    if options['axes compute']:
        Axes(options)
    if options['base grid compute']:
        BaseGrid(options)
    if options['view']:
        cmd.set_view(options['view'])
    if options['ray']:
        cmd.ray()
    if options['png file']:
        cmd.png(options['png file'])
    if options['quit']:
        cmd.quit()
コード例 #8
0
ファイル: pymolCMD.py プロジェクト: AfiKhan/MDQSAR-imatinib
def saveMultiplepng(pnamein, nbstates):

    finish_launching()
    for state in range(0,nbstates):
        print(state, nbstates)
        finish_launching()

        pfilin = pnamein + "_state" + str(state) + ".pdb"
        print (pfilin)
        cmd.load(pfilin, "state" + str(state))
        cmd.hide("everything", "all")



    for state in range(0, nbstates):
        cmd.show("surface", selection="state" + str(state))
        cmd.set("transparency", value=0.4)
        cmd.show("cartoon", selection="state" + str(state))
        cmd.spectrum("b", "chocolate_firebrick_red_tv_red_deepsalmon_darksalmon_salmon_lightpink_white",
                     selection="all", minimum=0, maximum=100)
        cmd.select("lig" + str(state), "resn UNK and state" + str(state))
        cmd.show("stick", selection="lig" + str(state))
        cmd.bg_color("white")

        cmd.ray(2000, 2000)
        cmd.save(pnamein + "_state" + str(state) + ".png", selection="state" + str(state))
        cmd.hide("everything", "all")

    cmd.quit()
コード例 #9
0
def surfback(width,height,color="gray",showcartoon=True,dname=""):
    #if (cmd.get("bg_image_filename")==None):
    cmd.set("bg_image_filename",None)
    cmd.hide("")
    cmd.set("fog", 0)
    cmd.set("reflect", 0)
    cmd.set("ambient",1)
    cmd.set("ray_trace_mode", 0)
    cmd.show("surface")
    cmd.set("surface_color",color)
    cmd.set("spec_reflect",0)
    cmd.ray(width,height)
    # I want below to work with tmpdir but, it fails. So this script makes unwanted tmpfile to dir named as dname
    cmd.png(dname+"surf.png")
    cmd.do("ls " + dname)
    cmd.do("ls " + dname+"surf.png")
    #cmd.load_png(dname+"surf.png")
    time.sleep(0.01)
    cmd.set("bg_image_filename",dname+"surf.png")
    cmd.set("bg_image_mode",0)
    if (showcartoon):
        cmd.hide("")
        cmd.show("cartoon")
        cmd.color("white")
        cmd.set("ray_trace_mode", 3)
        cmd.set("ambient", 1)
        cmd.set("reflect",0)
        cmd.set("valence", 0)
        cmd.set("spec_reflect",0)
        cmd.set("ray_trace_color", "gray0")
    #cmd.ray(n,n)
    #cmd.png("/
    print("Ray your image in the same aspect ratio as you specified in surfback")
コード例 #10
0
    def test(self):
        cmd.fragment('ala')
        cmd.ray(100, 100)
        img = self.get_imagearray()  # cmd.png without optional arguments

        # bug was: ray tracing twice, second time would not be 100x100
        self.assertEqual(img.shape[:2], (100, 100))
コード例 #11
0
def take_screenshot(params, pdb_file_name, protein_number, step_number):
    print("")
    print("SCREENSHOT! protein #", protein_number, pdb_file_name, " step ", step_number, " with ", cmd.count_atoms("all"), " atoms")
    screenshot_path = "./results/{}/screenshots/{}-{}/{}-{}.png".format(params.run_time_stamp, pdb_file_name, protein_number, pdb_file_name, step_number)
    cmd.ray()
    # cmd.zoom("all")
    cmd.center("all")
    cmd.png(screenshot_path)
コード例 #12
0
 def _test_recall(self):
     cmd.scene('s1', 'recall')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m3'], cmd.get_object_list('(enabled)'))
     cmd.enable('g1')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(enabled)'))
コード例 #13
0
 def _test_recall(self):
     cmd.scene('s1', 'recall')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m3'], cmd.get_object_list('(enabled)'))
     cmd.enable('g1')
     cmd.ray(1, 1)  # force scene update
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(visible)'))
     self.assertEqual(['m1', 'm3'], cmd.get_object_list('(enabled)'))
コード例 #14
0
def rotation_series(axis, increment, width, height, filename, with_centering):
    if (increment == 0):
        max_turns = 1
    else:
        max_turns = (360/increment) + 1

    for x in range(max_turns):    
        if x > 0: cmd.rotate(axis, increment)
        if with_centering: cmd.center("(all)")
        cmd.ray(width, height)
        cmd.png(filename + "_" + str(x * increment) + ".png", dpi=dpi())
    return
コード例 #15
0
ファイル: image.py プロジェクト: philopon/my-pymol-plugins
def save_image(
        width = 1920,
        height = 1080,
        selection = '(all)',
        format = 'png',
        state = -1,
        prefix = os.path.join(Windows_Desktop() or _Nix_Desktop(), 'PyMOL'),
        renderer = -1,
        shift = 0.0):
    cmd.ray(width, height, renderer, shift)

    for path in pathes(prefix, format):
        if not os.path.exists(path):
            cmd.save(path, selection, state, format)
            break
コード例 #16
0
    def test(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.pseudoatom('m3')
        cmd.group('g1', 'm1')
        cmd.disable('g1')
        cmd.disable('m2')
        cmd.ray(1, 1)  # force scene update
        cmd.scene('s1', 'store')

        self._test_recall()
        cmd.disable('*')
        self._test_recall()
        cmd.enable('*')
        self._test_recall()
コード例 #17
0
def save_image(width=1920,
               height=1080,
               selection='(all)',
               format='png',
               state=-1,
               prefix=os.path.join(Windows_Desktop() or _Nix_Desktop(),
                                   'PyMOL'),
               renderer=-1,
               shift=0.0):
    cmd.ray(width, height, renderer, shift)

    for path in pathes(prefix, format):
        if not os.path.exists(path):
            cmd.save(path, selection, state, format)
            break
コード例 #18
0
    def test(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.pseudoatom('m3')
        cmd.group('g1', 'm1')
        cmd.disable('g1')
        cmd.disable('m2')
        cmd.ray(1, 1)  # force scene update
        cmd.scene('s1', 'store')

        self._test_recall()
        cmd.disable('*')
        self._test_recall()
        cmd.enable('*')
        self._test_recall()
コード例 #19
0
def makecartoon():
    cmd.color('black', 'name C')
    cmd.color('yellow', 'name S')
    cmd.hide('lines', 'all')
    cmd.set('stick_radius', 0.1)
    cmd.set('sphere_scale', 0.25)
    cmd.set('sphere_scale', 1, 'name au')
    cmd.set('sphere_scale', 1, 'name ag')
    cmd.set('antialias', 2)
    cmd.set('opaque_background', 0)
    cmd.set('ray_trace_gain', 5)
    cmd.set('depth_cue', 0)
    cmd.show('sticks', 'all')
    cmd.show('spheres', 'all')
    cmd.ray(2400, 1800)
コード例 #20
0
ファイル: B02.py プロジェクト: wangdang511/pymol-open-source
def load():
    r = 0
    rep = ["lines", "sticks", "spheres", "dots", "ribbon", "cartoon"]
    list = glob("pdb/*/*")
    list = map(lambda x: (random.random(), x), list)
    list.sort()
    list = map(lambda x: x[1], list)
    #    list = [ "pdb/rb/pdb0rbs.noc" ] + list
    #    while list[0]!="pdb/f8/pdb1f8u":
    #        list.pop(0)
    for file in list:
        try:
            print file
            cmd.delete('pdb')
            cmd.load(file, 'pdb')
            cmd.orient('pdb')
            cmd.color('red', 'ss h')
            cmd.color('yellow', 'ss s')
            cmd.hide()
            if cmd.count_atoms() < 15000:
                cmd.show(rep[r], "all")
            elif cmd.count_atoms() < 50000:
                cmd.show("cartoon", "all")
            else:
                cmd.show("lines", "all")

            r = r + 1
            if r >= len(rep): r = 0
            sys.__stderr__.write(".")
            sys.__stderr__.flush()
            n = cmd.count_states()
            cmd.ray(160, 120)
            cmd.dirty()
            time.sleep(0.1)
            if n > 1:
                sys.__stderr__.write("\n")
                sys.__stderr__.flush()
        except:
            traceback.print_exc()
コード例 #21
0
def stereo_ray(output="", width="", height=""):
    """
DESCRIPTION
   "stereo_ray" ray-traces the current scene twice (separated by 
   a six-degree rotation around the y axis)
   and saves a pair of images that can be combined in any image
   manipulation software to form a stereoimage.
   The first argument, the output file name, is mandatory.
   The second and third arguments, the size of the image, are not.
   If the width is given, the height will be calculated.
 
USAGE
   stereo_ray filename [, width [, height]]
 
EXAMPLE
   stereo_ray output, 1000, 600
   stereo_ray secondImage.png
   """

    if output == "":
        print "no output filename defined\n"
        print "try: 'stereo_ray filename'"
        return -1
        # abort if no output file name given

    if width == "":
        width, height = cmd.get_session()["main"][0:2]
        # get dimensions from viewer if not given

    elif height == "":
        oldWidth, oldHeight = cmd.get_session()["main"][0:2]
        height = int(width) * oldHeight / oldWidth
        # calculate height from proportions of viewer if
        # only width is given

    cmd.ray(width, height, angle=-3)
    cmd.png(output + "_r")
    cmd.ray(width, height, angle=3)
    cmd.png(output + "_l")
コード例 #22
0
def stereo_ray(output='', width='', height=''):

    if output == '':
        print 'no output filename defined\n'
        print 'try: \'stereo_ray filename\''
        return -1
        # abort if no output file name given

    if width == '':
        width, height = cmd.get_session()['main'][0:2]
        # get dimensions from viewer if not given

    elif height == '':
        oldWidth, oldHeight = cmd.get_session()['main'][0:2]
        height = int(width) * oldHeight / oldWidth
        # calculate height from proportions of viewer if
        # only width is given

    cmd.ray(width, height, angle=-3)
    cmd.png(output + "_r")
    cmd.ray(width, height, angle=3)
    cmd.png(output + "_l")
コード例 #23
0
def stereo_ray(output='', width='', height=''):

   if output == '':
      print 'no output filename defined\n'
      print 'try: \'stereo_ray filename\''
      return -1
      # abort if no output file name given
 
   if width == '':
      width,height = cmd.get_session()['main'][0:2]
      # get dimensions from viewer if not given
 
   elif height == '':
      oldWidth,oldHeight = cmd.get_session()['main'][0:2]
      height = int(width)*oldHeight/oldWidth
      # calculate height from proportions of viewer if
      # only width is given
 
   cmd.ray(width, height, angle=-3)
   cmd.png(output+"_r")
   cmd.ray(width, height, angle=3)
   cmd.png(output+"_l")
コード例 #24
0
ファイル: B02.py プロジェクト: Almad/pymol
def load():
    r = 0
    rep = [ "lines","sticks","spheres","dots","ribbon","cartoon" ]
    list = glob("pdb/*/*")
    list = map(lambda x:(random.random(),x),list)
    list.sort() 
    list = map(lambda x:x[1],list)
#    list = [ "pdb/rb/pdb0rbs.noc" ] + list
#    while list[0]!="pdb/f8/pdb1f8u":
#        list.pop(0)
    for file in list:
        try:
            print file                     
            cmd.delete('pdb')              
            cmd.load(file,'pdb')           
            cmd.orient('pdb')              
            cmd.color('red','ss h')        
            cmd.color('yellow','ss s')     
            cmd.hide()                     
            if cmd.count_atoms()<15000:    
                cmd.show(rep[r],"all")     
            elif cmd.count_atoms()<50000:  
                cmd.show("cartoon","all")  
            else:                          
                cmd.show("lines","all")	   
                                           
            r = r + 1                      
            if r>=len(rep): r=0;           
            sys.__stderr__.write(".")      
            sys.__stderr__.flush()         
            n = cmd.count_states()         
            cmd.ray(160,120)               
            cmd.dirty()                    
            time.sleep(0.1)                
            if n>1:                        
                sys.__stderr__.write("\n") 
                sys.__stderr__.flush()     
        except:
            traceback.print_exc()
コード例 #25
0
def images(B):
    #cmd.do("cd {}".format(B))
    pdb_list = glob.glob("*.pdb")
    for pdb in pdb_list:
        cmd.load(pdb)
    cmd.run("/usr/local/bin/all_against_all.py")
    cmd.select("all_ps", "name PS1+PS2+PS3")
    cmd.do(
        "align_all_to_all(selection='all_ps',cutoff=0,cycles=0,full_matrix=1,method='align')"
    )
    cmd.remove("het")
    cmd.remove("all_ps")
    cmd.show("sticks", "all")
    cmd.hide("sticks", "all_ps")
    cmd.hide("sphere", "all_ps")
    cmd.set("sphere_scale", 0.30, "all_ps")
    cmd.orient("all")
    cmd.multisave("{}.pdb".format(B))
    cmd.set("ray_opaque_background", 0)
    cmd.ray(2400)
    cmd.set("antialias", 1)
    cmd.png("{}.png".format(B), 1200, 1200, 300)
    cmd.quit()
コード例 #26
0
ファイル: fatslim_pymol.py プロジェクト: FATSLiM/fatslim
def render_to_file(fname, top=True, side=True, vesicle=False, zoom_obj="pbcbox", zoom_distance=10):
    fname = os.path.splitext(fname)[0]

    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
    if top:
        cmd.ray("2048")
        cmd.png("%s_top.png" % fname)

    if side:
        cmd.turn("x", -90)
        if vesicle:
            cmd.move("y", 150)
        cmd.ray("2048")
        cmd.png("%s_side.png" % fname)
    cmd.reset()
    cmd.zoom(zoom_obj, zoom_distance)
    if vesicle:
        cmd.turn("z", -90)
        cmd.move("y", -50)
コード例 #27
0
    def run():
        # get form data
        height = form.input_height.value()
        width = form.input_width.value()
        dpi = form.input_dpi.value()
        filename = form.input_filename.text()
        units = form.input_units.currentText()

        # calculate dots per centimeter or inch
        if units == 'cm':
            dots_per_unit = dpi * 2.54
        else:
            dots_per_unit = dpi

        # convert image size to pixels
        width *= dots_per_unit
        height *= dots_per_unit

        # render the image
        if filename:
            cmd.png(filename, width, height, dpi=dpi, ray=1, quiet=0)
        else:
            cmd.ray(width, height, quiet=0)
            print('No filename selected, only rendering on display')
コード例 #28
0
 def test(self):
     cmd.pseudoatom('m1')
     cmd.mset('1x1')
     cmd.create('m2', 'm1')
     cmd.ray()
     v = cmd.get_object_matrix('m2')
     self.assertArrayEqual(v, [
         1.,
         0.,
         0.,
         0.,
         0.,
         1.,
         0.,
         0.,
         0.,
         0.,
         1.,
         0.,
         0.,
         0.,
         0.,
         1.,
     ], 0.001, 'object matrix not identity')
コード例 #29
0
cmd.color("atomic", "not element C")
cmd.hide("licorice", "hydro")

# general settings
cmd.bg_colour("white")
cmd.set("ambient", 0.4)
cmd.set("antialias", 1)
cmd.set("ortho", 1)
cmd.set("sphere_mode", 5)
cmd.set("ray_trace_mode", 1)
cmd.set("cartoon_fancy_helices", 1)
cmd.set("cartoon_highlight_color", "grey30")

# draw the grid
## select the range
cmd.select('20A', 'ROCK1_ligand expand 20')
cmd.load('drawgridbox.pml')

# view
cmd.set_view ((
     0.003532045,   -0.998905182,   -0.046578705,
     0.942174196,   -0.012283626,    0.334894955,
    -0.335102588,   -0.045066781,    0.941101432,
    -0.000204355,    0.000496300, -208.231918335,
    53.537849426,  102.745925903,   29.107488632,
   130.434631348,  285.912689209,  -20.000000000 ))

# save pymol session
cmd.save(HERE / "pymol_3d_grid_encoding.pse")
cmd.ray(800, 800)
cmd.png(DATA / "pymol_3d_grid_encoding.png")
コード例 #30
0
ファイル: make_figure.py プロジェクト: ocramz/docker-pymol
def make_figure(output='', mode='',size=900,opaque='transparent'):

	"""

AUTHOR

	Martin Christen


DESCRIPTION

	"make_figure" creates publication-quality figures of the current scene.
	It understands several predefined "modes" and sizes.


USAGE

	make_figure filename [, mode] [, size (default=900 pixels)] [,opaque]


ARGUMENTS

	mode = string: type of desired figure (single, fb, sides, stereo or -nothing-)
	size = integer: size of the figure in pixels OR # panels (if <= 12)
	opaque = specify an opaque background.
	         By default, the script makes the background transparent.
EXAMPLES

	make_figure output
	make_figure output, single, 975, opaque
	make_figure output, fb, 2
	make_figure output, sides,4
	make_figure output, stereo


NOTES

	"single" mode makes a single 300 dpi figure
	
	"fb" mode makes TWO 300 dpi figure
	("front" and "back", rotating by 180 degrees about y)
	
	"sides" mode makes FOUR 300 dpi figures
	("front" "left" "right" and back, rotating by 90 degrees clockwise about y)
	
	"stereo" generates two 300 dpi, 750 px figures
	("L" and "R", to be combined as a stereo image)
	If you specify the stereo mode, the size argument is IGNORED.
		
	If no mode argument is given, the script generates quick figures
	for general	use: TWO figures (front and back) at 300 x 300 px, 72 dpi.
	
	Size is interpreted as pixels, except if the number is ridiculously small
	(<=12),	in which case the script as "number of panels" to make.

	Edit the script manually to define corresponding values.
	
	"""

	#define sizes here (in pixels)
	panel1 = 1800
	panel2 = 1350
	panel3 = 900
	panel4 = 900
	panel5 = 750
	panel6 = 750
	panel7 = 675
	panel8 = 675
	panel9 = 600
	panel10 = 585
	panel11 = 585
	panel12 = 585
	
	#verify size is an integer number and convert to pixels
	size = int(size)
	if size > 12:
		pixels = size
	
	elif size == 1:
		pixels = panel1
	
	elif size == 2:
		pixels = panel2
	
	elif size == 3:
		pixels = panel3
	
	elif size == 4:
		pixels = panel4
	
	elif size == 5:
		pixels = panel5
	
	elif size == 6:
		pixels = panel6
	
	elif size == 7:
		pixels = panel7
	
	elif size == 8:
		pixels = panel8
	
	elif size == 9:
		pixels = panel9
	
	elif size == 10:
		pixels = panel10
	
	elif size == 11:
		pixels = panel11
	
	elif size == 3:
		pixels = panel12

	#change background
	cmd.unset('opaque_background')
	if opaque == 'opaque':
		cmd.set('opaque_background')
	
	#apply mode
	if output == '':
		print 'no output filename defined\n'
		print 'try: \'make_figure filename\''
		return -1
		# abort if no output file name given

	if mode =='':
		cmd.set('surface_quality',1)
		cmd.set('opaque_background')
		cmd.png(output+"_back_quick",300,300,dpi=72)
		cmd.turn('y',180)
		cmd.png(output+"_front_quick",300,300,dpi=72)
		cmd.turn('y',180)
		cmd.set('surface_quality',0)
		# make front and back figures for quick mode

	elif mode == 'single':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output, dpi=300)
		cmd.set('surface_quality',0)
		# make a figure for single mode
		
	elif mode == 'fb':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_front", dpi=300)
		cmd.turn('y',180)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_back", dpi=300)
		cmd.turn('y',180)
		cmd.set('surface_quality',0)
		# make front and back figures for single mode

	elif mode == 'sides':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_1", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_2", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_3", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_4", dpi=300)
		cmd.turn('y',90)
		cmd.set('surface_quality',0)
		# make front and back figures for single mode
		
	elif mode == 'stereo':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(750, 750, angle=-3)
		cmd.png(output+"_R", dpi=300)
		cmd.ray(750, 750, angle=3)
		cmd.png(output+"_L", dpi=300)
コード例 #31
0
with open(edgepath,'r') as fin : 
    data = fin.readlines();
edges = [line.strip().split() for line in data]


for n,e in  enumerate(edges) : 
    t = cmd.dist('dist'+str(n),'3H4E//A/'+e[0]+'/CA',\
		'3H4E//A/'+e[1]+'/CA')

    if t < cutoff  : 
        cmd.delete('dist'+str(n)) 
    else : 
        cmd.color('blue','dist'+str(n))
        cmd.hide('labels','dist'+str(n))
        cmd.show('spheres','3H4E//A/'+e[0]+'/CA')
        cmd.show('spheres','3H4E//A/'+e[1]+'/CA')
        cmd.color('yellow','3H4E//A/'+e[0]+'/CA')
        cmd.color('yellow','3H4E//A/'+e[1]+'/CA')

cmd.set('dash_radius','0.2');
cmd.set('dash_gap','0.0');
cmd.set('sphere_scale','0.3')
#cmd.set('sphere_scale','0.8','retinal');
cmd.ray()
print('*'*5+'Image:%s'%os.path.abspath(outfp)+'*'*5)
cmd.png(os.path.abspath(outfp))

print '-------Completed Call--------';


コード例 #32
0
cmd.color('_colorm', 'sm')

#cmd.set ('label_font_id', 16)
#cmd.set ('label_size', 24)
#cmd.pseudoatom('xatom', pos=[1,0,0], label="x")
#cmd.pseudoatom('yatom', pos=[0,1,0], label="y")
#cmd.pseudoatom('zatom', pos=[0,0,2], label="z")
cmd.set('label_font_id', 16)
cmd.set('label_size', 20)
cmd.pseudoatom('xatom', pos=[2.5, 0, 0], label="x")
cmd.pseudoatom('yatom', pos=[0, 2.5, 0], label="y")
cmd.pseudoatom('zatom', pos=[0, 0, 5.5], label="z")

cmd.set('ray_opaque_background', 'on')
cmd.set('transparency', 0.50)

cmd.set_view('\
    -0.086753346,    0.836276770,    0.541441798,\
     0.670052588,   -0.353231400,    0.652936995,\
     0.737265468,    0.419426382,   -0.529700875,\
     0.000000000,    0.000000000,  -34.167503357,\
     0.108778238,    0.131587982,    2.662951946,\
    26.937919617,   41.397087097,  -20.000000000')

cmd.pseudoatom('latom', pos=[3.5, -2.5, 0], label="_label")

cmd.ray(1024, 1024)
cmd.png('this.png', dpi=600)

cmd.quit()
コード例 #33
0
def FocalBlur(aperture=2.0, samples=10, ray=0, width=0, height=0):
    '''
DESCRIPTION

    Creates fancy figures by introducing a focal blur to the image. The object
    at the origin will be in focus.

AUTHOR

    Jarl Underhaug
    University of Bergen
    jarl_dot_underhaug_at_gmail_dot_com

    Updates by Jason Vertrees and Thomas Holder

USAGE

    FocalBlur aperture=float, samples=int, ray=0/1, width=int, height=int

EXAMPELS

    FocalBlur aperture=1, samples=100
    FocalBlur aperture=2, samples=100, ray=1, width=600, height=400
    '''

    # Formalize the parameter types
    ray = (ray in ("True", "true", 1, "1"))
    aperture, samples = float(aperture), int(samples)
    width, height = int(width), int(height)

    # Create a temporary directory
    tmpdir = mkdtemp()

    # Get the orientation of the protein and the light
    light = cmd.get('light')[1:-1]
    light = [float(s) for s in light.split(',')]
    view = cmd.get_view()

    # Rotate the protein and the light in order to create the blur
    for frame in range(samples):
        # Angles to rotate protein and light
        # Populate angles as Fermat's spiral
        theta = frame * pi * 110.0 / 144.0
        radius = 0.5 * aperture * sqrt(frame / float(samples - 1))
        x = cos(theta) * radius
        y = sin(theta) * radius
        xr = x / 180.0 * pi
        yr = y / 180.0 * pi

        # Rotate the protein
        cmd.turn('x', x)
        cmd.turn('y', y)

        # Rotate the light
        ly = light[1] * cos(xr) - light[2] * sin(xr)
        lz = light[2] * cos(xr) + light[1] * sin(xr)
        lx = light[0] * cos(yr) + lz * sin(yr)
        lz = lz * cos(yr) - lx * sin(yr)
        cmd.set('light', [lx, ly, lz])

        curFile = "%s/frame-%04d.png" % (tmpdir, frame)
        print("Created frame %i/%i (%0.0f%%)" % (frame + 1, samples, 100 * (frame + 1) / samples))

        # Save the image to temporary directory
        if ray:
            cmd.ray(width, height)
            cmd.png(curFile)
        else:
            cmd.png(curFile, quiet=1)

        # Create the average/blured image
        try:
            avg = Image.blend(avg, Image.open(curFile), 1.0 / (frame + 1))
        except:
            avg = Image.open(curFile)

        # Return the protein and the light to the original orientation
        cmd.set('light', light)
        cmd.set_view(view)

    # Load the blured image
    avg.save('%s/avg.png' % (tmpdir))
    cmd.load('%s/avg.png' % (tmpdir))

    # Delete the temporary files
    rmtree(tmpdir)
コード例 #34
0
ファイル: bp_cube.py プロジェクト: belp77/pycubescd
cmd.pseudoatom('yatom', pos=[0, 2.5, 0], label="y")
cmd.pseudoatom('zatom', pos=[0, 0, 4.0], label="z")

cmd.set('ray_opaque_background', 'off')
cmd.set('transparency', 0.30)

#cmd.set_view ('\
#    -0.086753346,    0.836276770,    0.541441798,\
#     0.670052588,   -0.353231400,    0.652936995,\
#     0.737265468,    0.419426382,   -0.529700875,\
#     0.000000000,    0.000000000,  -34.167503357,\
#     0.108778238,    0.131587982,    1.662951946,\
#     26.937919617,   41.397087097,  -20.000000000' )
#

cmd.set_view('\
    -0.036295272,    0.997309446,    0.063655443,\
    -0.180431277,   -0.069193237,    0.981151760,\
     0.982915938,    0.024127077,    0.182457983,\
     0.000000000,    0.000000000,  -42.977798462,\
     0.235994816,    0.235994816,    0.235994816,\
    33.884025574,   52.071571350,  -20.000000000')

#cmd.pseudoatom('latom', pos=[3.5,-2.5,0], label="_label")
#cmd.pseudoatom('latom', pos=[-3,0,0], label=u"\u0394\u03C1'\u2081".encode('utf-8'))
cmd.pseudoatom('latom', pos=[-3, 0, 0], label=u"_label".encode('utf-8'))
cmd.ray(1200, 1200)
cmd.png('this.png', dpi=600)

cmd.quit()
コード例 #35
0
    lines = f.readlines()[1:]
    for line in lines:
        line_elements = line.strip().split(',')
        site = int(line_elements[0])
        neff = float(line_elements[-1])
        neffs[site] = neff

# Determine the min and max entropy to set the range of the color scale
min_neff = min(neffs.values())
max_neff = max(neffs.values())

# Change each residue's B factor to its entropy value
for site in neffs:
    cmd.alter("resi %d" % site, "b = %g" % neffs[site])

# Color the structure by B-factor values
cmd.spectrum('b', 'yellow_red', structure, minimum=min_neff, maximum=max_neff)

# set up view
cmd.set_view('-0.722045004,   -0.058464222,   -0.689368665, '
             '0.598552346,    0.446926057,   -0.664827526, '
             '0.346962959,   -0.892658830,   -0.287708551, '
             '0.000000000,    0.000000000, -119.305297852, '
             '16.283113480,   28.784046173,   25.007221222, '
             '91.323577881,  147.287002563,  -20.000000000')

cmd.select('none')

cmd.ray(1600, 1200)
cmd.png('./results/prefs/structure_by_neff.png')
コード例 #36
0
ファイル: turn_ray.py プロジェクト: rule-lab/lab-scripts
"""
A script that will execute a 360 degree spin of the structure, ray-tracing the
structure at each interval and saving the image.
"""

from pymol import cmd
import os.path

FRAMES = 360  # How many frames to spread the spin over
AXIS = 'y'  # The axis about which to spin
OUTPUT = 'turn_ray_images'  # The output directory for images
RAY_X = 1920  # The x-dimension of the image, 0 will use current window size
RAY_Y = 1080  # The y-dimension of the image, 0 will use current window size

os.mkdir(OUTPUT)

for i in xrange(FRAMES):
    cmd.turn(AXIS, 360.0 / FRAMES)
    cmd.ray(width=RAY_X, height=RAY_Y)
    frame_name = '{0}.png'.format(str(i).zfill(4))
    cmd.png(os.path.join(os.getcwd(), OUTPUT, frame_name))
コード例 #37
0
def compare_10gs_11gs():
    # it is possible to download proteins from RCSB (Protein Data Bank) to fetch_path, which is current working
    # directory by default
    cmd.set('fetch_path', cmd.exp_path(PATH_data))
    cmd.fetch('10gs')
    cmd.fetch('11gs')

    cmd.load('{0}10gs.cif'.format(PATH_data), '10gs')
    cmd.load('{0}11gs.cif'.format(PATH_data), '11gs')

    # proteins
    # pymol has several options for proteins alignment, align is better for proteins with high homology
    align_command = cmd.align  # or super, or cealign
    align_res = align_command('10gs', '11gs')
    if align_command == cmd.align:
        print('aligned with rmsd {0}'.format(align_res[0]))
    # cmd.create creates a separate object (copies everything to it)
    # het stands for heteroatoms (non-protein)
    cmd.create('10gs_protein', '10gs and not het')
    cmd.create('11gs_protein', '11gs and not het')
    # print protein sequences for fun
    fasta_10gs = cmd.get_fastastr(selection='10gs_protein')
    fasta_11gs = cmd.get_fastastr(selection='11gs_protein')
    print('10gs sequence:{0}'.format(fasta_10gs))
    print('11gs sequence:{0}'.format(fasta_11gs))
    cmd.delete('*_protein')  # delete objects

    # ligands
    cmd.select('10gs_ligands', '10gs and not resname HOH and het')
    cmd.select('11gs_ligands', '11gs and not resname HOH and het')
    space_10gs = {'lig_names': []}  # or simpy lig_names = []
    space_11gs = {'lig_names': []}
    # strange pymol interface to iterate over atoms
    cmd.iterate('10gs_ligands', 'lig_names.append(resn)', space=space_10gs)
    cmd.iterate('11gs_ligands', 'lig_names.append(resn)', space=space_11gs)
    ligs_10gs = set(space_10gs['lig_names'])
    ligs_11gs = set(space_11gs['lig_names'])
    # by the way, in both 10gs and 11gs we have MSE, which is actually a modified residue and not a ligand
    print('ligands found in 10gs: {0}'.format(ligs_10gs))
    print('ligands found in 11gs: {0}'.format(ligs_11gs))
    for ligand_unique in ligs_10gs.symmetric_difference(ligs_11gs):
        cmd.save(
            '{0}{1}_{2}_ligand.sdf'.format(
                PATH_data, '10gs' if ligand_unique in ligs_10gs else '11gs',
                ligand_unique), 'resname {0}'.format(ligand_unique))
    # deleting selection, objects remain unchanged
    cmd.delete('ligs*')

    print('drawing a figure (this will take some time)')
    cmd.set('transparency_mode', 1)
    cmd.bg_color('white')
    cmd.show('sticks', 'het and not resname HOH')
    cmd.color('white', 'not het')
    cmd.show('surface', 'not het')
    cmd.hide('lines')
    cmd.set('transparency', '0.7')
    cmd.show('spheres', 'resname HOH')
    cmd.color('palecyan', 'resname HOH')
    cmd.hide('nonbonded', 'resname HOH')
    cmd.set('sphere_transparency', '0.7')
    cmd.ray()
    cmd.png('{0}fig.png'.format(PATH_data))
コード例 #38
0
cutoff = 2

# Load the edges from file
with open(edgepath, 'r') as fin:
    data = fin.readlines()
edges = [line.strip().split() for line in data]

for n, e in enumerate(edges):
    t = cmd.dist('dist'+str(n),'3H4E//A/'+e[0]+'/CA',\
  '3H4E//A/'+e[1]+'/CA')

    if t < cutoff:
        cmd.delete('dist' + str(n))
    else:
        cmd.color('blue', 'dist' + str(n))
        cmd.hide('labels', 'dist' + str(n))
        cmd.show('spheres', '3H4E//A/' + e[0] + '/CA')
        cmd.show('spheres', '3H4E//A/' + e[1] + '/CA')
        cmd.color('yellow', '3H4E//A/' + e[0] + '/CA')
        cmd.color('yellow', '3H4E//A/' + e[1] + '/CA')

cmd.set('dash_radius', '0.2')
cmd.set('dash_gap', '0.0')
cmd.set('sphere_scale', '0.3')
#cmd.set('sphere_scale','0.8','retinal');
cmd.ray()
print('*' * 5 + 'Image:%s' % os.path.abspath(outfp) + '*' * 5)
cmd.png(os.path.abspath(outfp))

print '-------Completed Call--------'
コード例 #39
0
ファイル: render.py プロジェクト: brisvag/stir
def cheese(render_type,
           savefile=None,
           duration=5,
           mode='ray',
           width=1920,
           height=1080):
    """
DESCRIPTION

    loads nice settings for rendering and  take a picture or records a movie of the trajectory.
    Before running, position the camera to have a good point of view.

USAGE

    cheese render_type [, savefile [, duration [, mode [, width [, height]]]]]

ARGUMENTS

    render_type = one of:
        - set: only load render settings
        - snap: take a snapshot of the current view
        - traj: record the whole trajectory
        - bullettime: make a whole revolution around the z axis
    savefile = file name to use to save the movie, without extension. If not given,
               the movie won't be save but only shown (default=None)
    duration = duration in seconds of the final movie (default=5)
    mode = set to 'draw' to disable ray tracing (default='ray')
    width = width of the movie in pixel (default=1920)
    height = height of the movie in pixel (default=1080)
    """
    duration = int(duration)

    #    # store settings for later restoration
    #    store_settings.load()
    #    cmd.sync()
    #    settings_file = '/tmp/stir_settings.py'
    #    cmd.do(f'store_settings {settings_file}')

    # load nice settings for rendering
    config.rendering()
    cmd.sync()

    def init_movie():
        cmd.mdelete()
        cmd.mview('reset')
        frames = duration * 30
        cmd.mset(f'1x{frames}')
        return frames

    # only load settings
    if render_type == 'set':
        return
    # take a simple picture
    elif render_type == 'snap':
        cmd.ray(width=width, height=height)
    # make a still movie of the whole trajectory
    elif render_type == 'traj':
        frames = init_movie()
        cmd.mview('store', 1, state=1)
        cmd.sync()
        states = cmd.count_states()
        cmd.mview('store', frames, state=states)
        cmd.sync()
        cmd.mview('reinterpolate')
        cmd.sync()
    # make a movie rotating 360 around the z axis
    elif render_type == 'bullettime':
        frames = init_movie()
        cmd.mview('store', 1)
        cmd.mview('store', frames)
        # TODO: moving objects seems a bit hacky. Any better solution?
        for obj in cmd.get_object_list():
            cmd.mview('store', object=obj)
            cmd.sync()
        for i in range(4):
            frame = int(frames * (i + 1) / 4)
            cmd.frame(frame)
            cmd.sync()
            for obj in cmd.get_object_list():
                cmd.rotate('z', angle=-90, camera=0, object=obj)
                cmd.sync()
                cmd.mview('store', object=obj)
                cmd.sync()
                cmd.mview('reinterpolate', object=obj, power=1)
                cmd.sync()
        cmd.mview('reinterpolate')
        cmd.sync()
    else:
        raise ValueError(
            f'{render_type} is not a valid argument. See `help cheese`.')

    # save if required, otherwise just play it
    if savefile:
        if render_type in (
                'traj',
                'bullettime',
        ):
            cmd.viewport(width, height)
            movie.produce(f'{savefile}.mp4',
                          mode=mode,
                          encoder='ffmpeg',
                          quality=100)
        elif render_type in ('snap', ):
            cmd.png(f'{savefile}.png', dpi=300)
        cmd.sync()
    else:
        if render_type in (
                'traj',
                'bullettime',
        ):
            cmd.mplay()
        elif render_type in ('snap', ):
            pass
コード例 #40
0
def save_image_default(filename):
    cmd.bg_color("white")
    cmd.ray(default_image_size(), default_image_size())
    cmd.png("./output/" + filename + ".png", dpi=dpi())
    cmd.bg_color("black")
    return 
コード例 #41
0
values = inFile.readlines()
print values

# create the global, stored array
stored = []
 
# read the new B factors from file
for line in values: stored.append( float(line) )
print stored
max_b = max(stored)
min_b = min(stored)

cmd.bg_color("white")
print min_b
print max_b

# close the input file
inFile.close()
 
# clear out the old B Factors
cmd.alter("%s and n. CA"%pdb, "b=0.0")
 
# update the B Factors with new properties
cmd.alter("%s and n. CA"%pdb, "b=stored.pop(0)")
 
# color the protein based on the new B Factors of the alpha carbons
cmd.spectrum("b", "rainbow", "%s and n. CA"%pdb, minimum=min_b, maximum=max_b)
cmd.ray("775", "2400")
cmd.png("unscaled%s.png"%infilename.split("_")[0])
コード例 #42
0
ファイル: transfer.py プロジェクト: dseuss/diploma-thesis
A = AggregatTransferFromFile(fname)

cmd.set_view ([
    -0.480811268,    0.603387773,    0.636203885,
     0.675508440,    0.717507422,   -0.169974893,
    -0.559037924,    0.348030269,   -0.752567112,
    -0.000127681,    0.000030167, -122.974456787,
    13.921709061,   -7.469791889,   -4.264435768,
  -1086.176879883, 1332.132446289,  -20.000000000])
# select only a few sample points
indices = [0, 250, 500, 1000, 1999]
t = np.linspace(0, A._tLength, A._tSteps)[indices]

# Get values ordered by time in first index
values = np.swapaxes(A.get(), 0, 1)[indices]

selections = ['lab{}'.format(i + 1) for i in range(8)]
for lab in selections:
   cmd.label(lab, '')

selections = ['bcl{}'.format(i + 1) for i in range(7)]
for i, val in enumerate(values):
   alpha = p_to_alpha(val)
   for n, bcl in enumerate(selections):
      cmd.set_bond('stick_transparency', alpha[n], bcl)

   cmd.refresh()
   cmd.ray(width, height)
   print('Belongs to time {}'.format(t[i] * 5.20883746))
   cmd.png('../fmo_transfer_{}.png'.format(i), dpi=DPI, ray=1)
コード例 #43
0
def save_image_filament(filename):
    cmd.bg_color("white")
    cmd.ray(ray_width_filament(), ray_height_filament())
    cmd.png("./output/" + filename + ".png", dpi=dpi())
    cmd.bg_color("black")
    return 
コード例 #44
0
ファイル: setting.py プロジェクト: ssmadha/Standalone-ProMol
def setray0():
    cmd.set("ray_trace_mode", "0")
    cmd.ray()
コード例 #45
0
ファイル: setting.py プロジェクト: ssmadha/Standalone-ProMol
def setray2():
    cmd.set("ray_trace_mode", "2")
    cmd.bg_color('white')
    cmd.ray()
コード例 #46
0
ファイル: setting.py プロジェクト: ssmadha/Standalone-ProMol
def setray3():
    cmd.set("ray_trace_mode", "3")
    cmd.ray()
コード例 #47
0
for i in range(5):
    cmd.load("./PDBs-%d/State%d-%d.pdb" % (p_id, stateid, i))

for i in range(5):
    cmd.align("State%d-%d" % (stateid, i),
              "State%d-%d" % (stateid, ref_state_id))

#alignto does the same thing as the above loop, but it sometimes could cause problem
#cmd.alignto("State%d-0"%stateid)
cmd.show("cartoon")
cmd.hide("lines", "!State%d-%d" % (stateid, ref_state_id))
cmd.center("all")
cmd.set("cartoon_transparency", 0.7, "all")
cmd.set("cartoon_transparency", 0, "State%d-%d" % (stateid, ref_state_id))
cmd.util.chainbow("all")
cmd.util.cnc("all")
cmd.orient()
cmd.util.performance(0)
cmd.set("ray_opaque_background", "off")
cmd.ray()
png_fn = os.path.join(outdir, "image-p%d-state-%d.png" % (p_id, stateid))
high_res_state = [0, 1, 2, 4, 11, 12, 13, 20, 28, 30]
if stateid in high_res_state:
    png_fn = os.path.join(outdir,
                          "image-p%d-state-%d-highres.png" % (p_id, stateid))
    cmd.ray(2400, 1800)
    cmd.png(png_fn, dpi=300)
else:
    cmd.png(png_fn)
cmd.quit()
コード例 #48
0
def pubimage_tmblr(*argumenthere, **kwd):
    '''Takes an image with the specified properties. The properties should be entered in the following order:
	
	ray_trace_mode, antialias, ray width, ray height, bg_color
			
	
	If not specified, then the properties default to
			ray_trace_mode (int 1-3) 	-->	 	3
			antialias (int 0-2)			--> 	2
			raynum1, raynum2 (int)	 	--> 	ray 1200, 1200
			bg_color (string) 			--> 	white
	'''

    # The following is for debugging:
    # argumenthere[0] (int 1-3) 				-->	 	ray_trace_mode (int)
    # argumenthere[1] (int 0-2)					--> 	antialias (int)
    # argumenthere[2], argumenthere[3] (int)	--> 	ray num1, num2 (int)
    # argumenthere[4] (string) 					--> 	bg_color (string)

    global iternum

    #Setting ray_trace_mode
    try:
        cmd.set('ray_trace_mode',
                value=int(argumenthere[0]),
                selection='',
                state=0,
                updates=1,
                log=0,
                quiet=1)
    except IndexError:
        cmd.set('ray_trace_mode', 3)

    #Setting antialias
    try:
        cmd.set('antialias',
                int(argumenthere[1]),
                selection='',
                state=0,
                updates=1,
                log=0,
                quiet=1)
    except IndexError:
        cmd.set('antialias', 2)

    #Setting bg_color
    try:
        cmd.bg_color(argumenthere[4])
    except IndexError:
        cmd.bg_color('white')

    #CENTER IMAGE TAKING AND ROTATION
    #Ray the image
    try:
        cmd.ray(width=int(argumenthere[2]),
                height=int(argumenthere[3]),
                antialias=-1,
                angle=0.0,
                shift=0.0,
                renderer=-1,
                quiet=1,
                async=0)
    except IndexError:
        cmd.ray(width=1200, height=1200)

    #Save the Image
    try:
        cmd.png('molecule' + str(iternum) + 'center.png')
    except IndexError:
        cmd.png('molecule' + str(iternum) + 'center.png')

    cmd.turn('x', 90.0)

    #TOP-DOWN IMAGE TAKING AND ROTATION
    #Ray the image
    try:
        cmd.ray(width=int(argumenthere[2]),
                height=int(argumenthere[3]),
                antialias=-1,
                angle=0.0,
                shift=0.0,
                renderer=-1,
                quiet=1,
                async=0)
    except IndexError:
        cmd.ray(width=1200, height=1200)

    #Save the Image
    try:
        cmd.png('molecule' + str(iternum) + 'topdown.png')
    except IndexError:
        cmd.png('molecule' + str(iternum) + 'topdown.png')

    cmd.turn('x', -180.0)

    #BOTTOM-UP IMAGE TAKING AND ROTATION
    #Ray the image
    try:
        cmd.ray(width=int(argumenthere[2]),
                height=int(argumenthere[3]),
                antialias=-1,
                angle=0.0,
                shift=0.0,
                renderer=-1,
                quiet=1,
                async=0)
    except IndexError:
        cmd.ray(width=1200, height=1200)

    #Save the Image
    try:
        cmd.png('molecule' + str(iternum) + 'bottomup.png')
    except IndexError:
        cmd.png('molecule' + str(iternum) + 'bottomup.png')

    cmd.turn('x', 90.0)
    cmd.turn('y', 90.0)

    #LEFT IMAGE TAKING AND ROTATION
    #Ray the image
    try:
        cmd.ray(width=int(argumenthere[2]),
                height=int(argumenthere[3]),
                antialias=-1,
                angle=0.0,
                shift=0.0,
                renderer=-1,
                quiet=1,
                async=0)
    except IndexError:
        cmd.ray(width=1200, height=1200)

    #Save the Image
    try:
        cmd.png('molecule' + str(iternum) + 'left.png')
    except IndexError:
        cmd.png('molecule' + str(iternum) + 'left.png')

    cmd.turn('y', -180.0)

    #RIGHT IMAGE TAKING AND ROTATION
    #Ray the image
    try:
        cmd.ray(width=int(argumenthere[2]),
                height=int(argumenthere[3]),
                antialias=-1,
                angle=0.0,
                shift=0.0,
                renderer=-1,
                quiet=1,
                async=0)
    except IndexError:
        cmd.ray(width=1200, height=1200)

    #Save the Image
    try:
        cmd.png('molecule' + str(iternum) + 'right.png')
    except IndexError:
        cmd.png('molecule' + str(iternum) + 'right.png')

    cmd.turn('y', 90.0)
    iternum += 1