Ejemplo n.º 1
0
        def save_flip_selections():
            '''Save the user-selected flips to a new PDB object.'''
            o = main.get_object(mpobj.get())
            flipkin = self.flipkin_radio.getvalue()
            reduce_obj = o.pdb['reduce']
            flipkin_obj = o.pdb[flipkin]
            userflips_obj = o.pdb['userflips']
            # Create a new userflips object even if it already exists in case
            # previous selections have been changed.
            v = cmd.get_view()
            cmd.create(userflips_obj, reduce_obj)
            cmd.set_view(v)

            for i, v in enumerate(o.views[flipkin]):
                # If reduce value and user value are different, copy the
                # coordinates from the current flipkin molecule
                if v['reduce_chk_val'].get() != v['user_chk_val'].get():
                    # Do it the hard way, by combining objects.  This is plenty
                    # fast (we typically won't have too many flips to switch)
                    # and doesn't result in atom name mismatch errors for
                    # differently protonated HIS residues the way the
                    # load_coords method does.
                    flipped_sel = '({} and chain {} and resi {})'.format(
                            flipkin_obj, v['chain'], v['resi'])
                    userflips_sel = '({} and not (chain {} and resi {}))'.format(
                            userflips_obj, v['chain'], v['resi'])
                    combined_sel = '{} or {}'.format(
                            userflips_sel, flipped_sel)
                    v = cmd.get_view()
                    cmd.create(userflips_obj, combined_sel)
                    cmd.set_view(v)
                    msg = 'added flip for {} to {}'.format(flipped_sel,
                            userflips_obj)
                    logger.debug(msg)
            o.solo_pdb('userflips')
Ejemplo n.º 2
0
        def save_flip_selections():
            '''Save the user-selected flips to a new PDB object.'''
            o = main.get_object(mpobj.get())
            flipkin = self.flipkin_radio.getvalue()
            reduce_obj = o.pdb['reduce']
            flipkin_obj = o.pdb[flipkin]
            userflips_obj = o.pdb['userflips']
            # Create a new userflips object even if it already exists in case
            # previous selections have been changed.
            v = cmd.get_view()
            cmd.create(userflips_obj, reduce_obj)
            cmd.set_view(v)

            for i, v in enumerate(o.views[flipkin]):
                # If reduce value and user value are different, copy the
                # coordinates from the current flipkin molecule
                if v['reduce_chk_val'].get() != v['user_chk_val'].get():
                    # Do it the hard way, by combining objects.  This is plenty
                    # fast (we typically won't have too many flips to switch)
                    # and doesn't result in atom name mismatch errors for
                    # differently protonated HIS residues the way the
                    # load_coords method does.
                    flipped_sel = '({} and chain {} and resi {})'.format(
                        flipkin_obj, v['chain'], v['resi'])
                    userflips_sel = '({} and not (chain {} and resi {}))'.format(
                        userflips_obj, v['chain'], v['resi'])
                    combined_sel = '{} or {}'.format(userflips_sel,
                                                     flipped_sel)
                    v = cmd.get_view()
                    cmd.create(userflips_obj, combined_sel)
                    cmd.set_view(v)
                    msg = 'added flip for {} to {}'.format(
                        flipped_sel, userflips_obj)
                    logger.debug(msg)
            o.solo_pdb('userflips')
Ejemplo n.º 3
0
def images_refocus(images, target):

    global imagecount
    global ray
    global filename
    global ximage
    global yimage

    print "... Images %s - %s:" % (imagecount, imagecount + images - 1)
    print "Writing %s images zooming to selection:" % images
    print "  %s" % target

    current_view = cmd.get_view()  #get the starting view
    temporary_view = current_view  #make variabe to track interpolation
    cmd.zoom(target)  #zoom to the target selection
    end_view = cmd.get_view()  #get the ending view

    #get the difference between the start and ending views, divide per step
    views_difference = tuple(np.subtract(end_view, temporary_view))
    diff_per_image = tuple(i / images for i in views_difference)

    for i in range(0, images):  #cycle for number of images

        #update the interpolating view
        temporary_view = tuple(np.add(temporary_view, diff_per_image))

        cmd.set_view(temporary_view)

        #print image
        cmd.png("images/%s_%04d" % (filename, imagecount), ray=ray)

        #increment imagecounter
        imagecount = imagecount + 1
        cmd.refresh()
Ejemplo n.º 4
0
    def testScene(self):
        cmd.fragment('ala', 'm1')
        cmd.fragment('gly', 'm2')
        cmd.create('m2', 'm2', 1, 2)
        cmd.create('m2', 'm2', 1, 3)
        cmd.create('m2', 'm2', 1, 4)

        # store
        cmd.show_as('sticks', 'm1')
        cmd.show_as('spheres', 'm2')
        cmd.color('blue', 'm1')
        cmd.color('yellow', 'm2')
        view_001 = cmd.get_view()
        cmd.scene('new', 'store', 'hello world')

        # store
        cmd.frame(3)
        cmd.show_as('lines')
        cmd.color('red')
        cmd.turn('x', 45)
        view_002 = cmd.get_view()
        cmd.scene('new', 'store')

        # we actually don't know the auto naming counter
        # self.assertEqual(cmd.get_scene_list(), ['001', '002'])
        names = cmd.get_scene_list()

        # recall
        cmd.scene(names[0], 'recall', animate=0)
        self.assertArrayEqual(view_001, cmd.get_view(), delta=1e-3)
        self.assertEqual(cmd.count_atoms('m1'), cmd.count_atoms('color blue'))
        self.assertEqual(cmd.count_atoms('m1'), cmd.count_atoms('rep sticks'))
        self.assertEqual(cmd.count_atoms('m2'),
                         cmd.count_atoms('color yellow'))
        self.assertEqual(cmd.count_atoms('m2'), cmd.count_atoms('rep spheres'))
        self.assertNotEqual(cmd.get_wizard(), None)
        self.assertEqual(cmd.get_state(), 1)

        # recall
        cmd.scene(names[1], 'recall', animate=0)
        self.assertArrayEqual(view_002, cmd.get_view(), delta=1e-3)
        self.assertEqual(0, cmd.count_atoms('color blue'))
        self.assertEqual(0, cmd.count_atoms('rep sticks'))
        self.assertEqual(cmd.count_atoms(), cmd.count_atoms('color red'))
        self.assertEqual(cmd.count_atoms(), cmd.count_atoms('rep lines'))
        self.assertEqual(cmd.get_wizard(), None)
        self.assertEqual(cmd.get_state(), 3)

        # with movie (not playing) it must not recall the state
        cmd.mset('1-4')
        cmd.frame(1)
        cmd.scene(names[1], 'recall', animate=0)
        self.assertEqual(cmd.get_state(), 1)

        # rename and delete
        cmd.scene('F2', 'store')
        cmd.scene(names[0], 'rename', new_key='F1')
        cmd.scene(names[1], 'delete')
        self.assertEqual(cmd.get_scene_list(), ['F1', 'F2'])
Ejemplo n.º 5
0
 def testView(self):
     cmd.turn('x', 30)
     a = cmd.get_view()
     cmd.view('A', 'store')
     cmd.turn('y', 30)
     self.assertNotEqual(a, cmd.get_view())
     cmd.view('A', 'recall', animate=0)
     self.assertEqual(a, cmd.get_view())
Ejemplo n.º 6
0
 def testView(self):
     cmd.turn('x', 30)
     a = cmd.get_view()
     cmd.view('A', 'store')
     cmd.turn('y', 30)
     self.assertNotEqual(a, cmd.get_view())
     cmd.view('A', 'recall', animate=0)
     self.assertEqual(a, cmd.get_view())
Ejemplo n.º 7
0
    def testScene(self):
        cmd.fragment('ala', 'm1')
        cmd.fragment('gly', 'm2')
        cmd.create('m2', 'm2', 1, 2)
        cmd.create('m2', 'm2', 1, 3)
        cmd.create('m2', 'm2', 1, 4)

        # store
        cmd.show_as('sticks', 'm1')
        cmd.show_as('spheres', 'm2')
        cmd.color('blue', 'm1')
        cmd.color('yellow', 'm2')
        view_001 = cmd.get_view()
        cmd.scene('new', 'store', 'hello world')

        # store
        cmd.frame(3)
        cmd.show_as('lines')
        cmd.color('red')
        cmd.turn('x', 45)
        view_002 = cmd.get_view()
        cmd.scene('new', 'store')

        # we actually don't know the auto naming counter
        # self.assertEqual(cmd.get_scene_list(), ['001', '002'])
        names = cmd.get_scene_list()

        # recall
        cmd.scene(names[0], 'recall', animate=0)
        self.assertArrayEqual(view_001, cmd.get_view(), delta=1e-3)
        self.assertEqual(cmd.count_atoms('m1'), cmd.count_atoms('color blue'))
        self.assertEqual(cmd.count_atoms('m1'), cmd.count_atoms('rep sticks'))
        self.assertEqual(cmd.count_atoms('m2'), cmd.count_atoms('color yellow'))
        self.assertEqual(cmd.count_atoms('m2'), cmd.count_atoms('rep spheres'))
        self.assertNotEqual(cmd.get_wizard(), None)
        self.assertEqual(cmd.get_state(), 1)

        # recall
        cmd.scene(names[1], 'recall', animate=0)
        self.assertArrayEqual(view_002, cmd.get_view(), delta=1e-3)
        self.assertEqual(0, cmd.count_atoms('color blue'))
        self.assertEqual(0, cmd.count_atoms('rep sticks'))
        self.assertEqual(cmd.count_atoms(), cmd.count_atoms('color red'))
        self.assertEqual(cmd.count_atoms(), cmd.count_atoms('rep lines'))
        self.assertEqual(cmd.get_wizard(), None)
        self.assertEqual(cmd.get_state(), 3)

        # with movie (not playing) it must not recall the state
        cmd.mset('1-4')
        cmd.frame(1)
        cmd.scene(names[1], 'recall', animate=0)
        self.assertEqual(cmd.get_state(), 1)

        # rename and delete
        cmd.scene('F2', 'store')
        cmd.scene(names[0], 'rename', new_key='F1')
        cmd.scene(names[1], 'delete')
        self.assertEqual(cmd.get_scene_list(), ['F1', 'F2'])
Ejemplo n.º 8
0
 def testReset(self):
     # view
     v = cmd.get_view()
     cmd.turn('x', 10)
     cmd.move('y', 10)
     self.assertNotEqual(v, cmd.get_view())
     cmd.reset()
     self.assertEqual(v, cmd.get_view())
     # object
     cmd.pseudoatom("m1")
     x = cmd.get_object_matrix("m1")
     cmd.translate([1,2,3], object="m1")
     self.assertNotEqual(x, cmd.get_object_matrix("m1"))
     cmd.reset("m1")
     self.assertEqual(x, cmd.get_object_matrix("m1"))
Ejemplo n.º 9
0
 def testReset(self):
     # view
     v = cmd.get_view()
     cmd.turn('x', 10)
     cmd.move('y', 10)
     self.assertNotEqual(v, cmd.get_view())
     cmd.reset()
     self.assertEqual(v, cmd.get_view())
     # object
     cmd.pseudoatom("m1")
     x = cmd.get_object_matrix("m1")
     cmd.translate([1, 2, 3], object="m1")
     self.assertNotEqual(x, cmd.get_object_matrix("m1"))
     cmd.reset("m1")
     self.assertEqual(x, cmd.get_object_matrix("m1"))
Ejemplo n.º 10
0
	def centeractive(self):
		if self.toggle['view']:
			cmd.set_view(self.toggle['view'])
			self.toggle['view'] = None
		else:
			self.toggle['view'] = cmd.get_view()			
			cmd.center(self.m.rdes.sel())
Ejemplo n.º 11
0
    def __init__(self, top, queue):
        
        #print "New instance of FlexSC Wizard"

        Wizard.__init__(self)
        self.top = top
        self.queue = queue
        self.FlexAID = self.top.top

        self.FlexAID.WizardError = False

        self.TargetName = self.FlexAID.IOFile.Target
        self.TargetFlex = self.top.Vars.TargetFlex

        self.ResidueName = '...'
        self.PanelResidue = '   Residue: '
        
        # Initial view
        self.View = cmd.get_view()
        self.State = cmd.get_state()
        self.auto_zoom = cmd.get("auto_zoom")
        
        # for Quit_Wizard
        self.ErrorCode = 1
        
        self.ErrorStatus = [ "Side-chains shown in white are already set as flexible.",
                             "Side-chains shown in orange are 'active' and are ready to be added." ]
Ejemplo n.º 12
0
 def check_file(self):
     while (self.watch):
         if (os.path.exists(self.file_name)):
             print "checking..."
             mtime = os.path.getmtime(self.file_name)
             if (mtime > self.mtime):
                 self.mtime = mtime
                 print "Re-loading %s" % self.file_name
                 time.sleep(2)
                 cmd.load(self.file_name, state=1)
                 cmd.reset()
                 cmd.hide(representation="lines", selection="all")
                 cmd.show(representation="cartoon", selection="all")
                 view = cmd.get_view()
                 camera = list(view)
                 camera[0] = -1
                 camera[1] = 0
                 camera[2] = 0
                 camera[3] = 0
                 camera[4] = 0
                 camera[5] = 1
                 camera[6] = 0
                 camera[7] = 1
                 camera[8] = 0
                 cmd.set_view(camera)
         time.sleep(self.time_wait)
Ejemplo n.º 13
0
def insert_current():
    #insert the current view into the list after the view
    #in views[cur_index]
    #set frames to default
    global cur_index
    global cur_view
    global views
    global frames
    global actions
    global scenes
    global settings
    global models
    global fades

    cur_index += 1
    cur_view = cmd.get_view()
    views.insert(cur_index, [cv for cv in cur_view])
    frames.insert(cur_index, 50)

    #deal with actions dictionary
    actions = incKeyAbove(actions, cur_index)
    scenes = incKeyAbove(scenes, cur_index)
    settings = incKeyAbove(settings, cur_index)
    models = incKeyAbove(models, cur_index)
    fades = incKeyAbove(fades, cur_index)

    print "New view:"
    print_view(cur_view)
    print "Inserted view with index", cur_index, "and a 50 frame transition"
Ejemplo n.º 14
0
	def revert(self):
		v = cmd.get_view()
		cmd.remove(self.rdes.obj+" and not chain A")
		m = cmd.get_model(self.rdes.obj)
		n = self.oldcrd
		if not n:
			cmd.create("tmp12345",self.rnat.sel())
			cmd.align("tmp12345",self.rdes.sel())
			n = cmd.get_model("tmp12345").atom
			cmd.delete("tmp12345")
		di,ni = 0,0
		while m.atom[di].resi != str(self.rdes.resi): di += 1
		dj = di
		while m.atom[dj].resi == str(self.rdes.resi): dj += 1
		if self.oldcrd: self.oldcrd = None
		else:           self.oldcrd = m.atom[di:dj]
		m.atom = m.atom[:di] + n + m.atom[dj:]
		for i in range(di,di+len(n)):
			m.atom[i].resi  = str(self.rdes.resi)
			m.atom[i].chain = str(self.rdes.chain)
		cmd.load_model(m,self.rdes.obj,1)
		cmd.save("tmp.pdb",self.rdes.obj)
		cmd.delete(self.rdes.obj)
		cmd.load("tmp.pdb",self.rdes.obj,1)
		cmd.show('car',self.rdes.obj)
		cmd.show('lines')		
		redopent(self.rdes.obj)
		cmd.set_view(v)
		print "revert removing "+"".join(self.aas)+" from aas!"
		self.aas = [getaa('A',self.rdes.resi,self.manager.d.obj)]
Ejemplo n.º 15
0
def showvecfrompoint(a, c, col=(1, 1, 1), lbl=''):
    """TODO: Summary

    Args:
        a (TYPE): Description
        c (TYPE): Description
        col (tuple, optional): Description
        lbl (str, optional): Description
    """
    if not lbl:
        global numray
        lbl = "ray%i" % numray
        numray += 1
    cmd.delete(lbl)
    v = cmd.get_view()
    OBJ = [
        cgo.BEGIN, cgo.LINES, cgo.COLOR, col[0], col[1], col[2], cgo.VERTEX,
        c[0], c[1], c[2], cgo.VERTEX, c[0] + a[0], c[1] + a[1], c[2] + a[2],
        cgo.END
    ]
    cmd.load_cgo(OBJ, lbl)
    # cmd.load_cgo([cgo.COLOR, col[0],col[1],col[2],
    #             cgo.SPHERE,   c[0],       c[1],       c[2],    0.08,
    #             cgo.CYLINDER, c[0],       c[1],       c[2],
    #                       c[0] + a[0], c[1] + a[1], c[2] + a[2], 0.02,
    #               col[0],col[1],col[2],col[0],col[1],col[2],], lbl)
    cmd.set_view(v)
Ejemplo n.º 16
0
def showline(a, c, col=(1, 1, 1), lbl=""):
    """TODO: Summary

    Args:
        a (TYPE): Description
        c (TYPE): Description
        col (tuple, optional): Description
        lbl (str, optional): Description
    """
    if not lbl:
        global numline
        lbl = "line%i" % numline
        numline += 1
    cmd.delete(lbl)
    v = cmd.get_view()
    OBJ = [
        cgo.BEGIN,
        cgo.LINES,
        cgo.COLOR,
        col[0],
        col[1],
        col[2],
        cgo.VERTEX,
        c[0] - a[0],
        c[1] - a[1],
        c[2] - a[2],
        cgo.VERTEX,
        c[0] + a[0],
        c[1] + a[1],
        c[2] + a[2],
        cgo.END,
    ]
    cmd.load_cgo(OBJ, lbl)
    cmd.set_view(v)
Ejemplo n.º 17
0
	def orient(self):
		if self.toggle['view']:
			cmd.set_view(self.toggle['view'])
			self.toggle['view'] = None
		else:
			self.toggle['view'] = cmd.get_view()
			cmd.orient(self.d.obj+" or pnt*")
Ejemplo n.º 18
0
    def __init__(self, top, queue, UseOldTypes):
        
        #print "New instance of Wizard SetAtomType"

        Wizard.__init__(self)
        
        self.top = top
        self.FlexAID = self.top.top
        self.queue = queue
        # Save view
        self.View = cmd.get_view()
        self.State = cmd.get_state()
                
        #self.pdbPath = self.FlexAID.SimPath + 'tmp.pdb'
        self.pdbPath = self.FlexAID.IOFile.ProcessedLigandPath.get()
        
        self.ErrorCode = 1

        self.SelAtomName = '...'   
        self.SelAtomType = '...'

        self.Set_DDL_Colors(UseOldTypes)       

        smm = []
        smm.append([ 2, 'Type Selection', '' ])
        for a in self.types:
            smm.append([ 1, self.type_name[a], 'cmd.get_wizard().set_AtomType("' + a + '")'])
        self.menu['type']=smm
       
        self.atom = list()
        self.ID = ''
Ejemplo n.º 19
0
def mysetview(look, up, pos=None, cen=None, ncp=None, fcp=None):
    Xaxis = -look.cross(up).normalized()
    Yaxis = projperp(look, up).normalized()
    Zaxis = -look.normalized()
    oldv = cmd.get_view()
    v = list(oldv)
    r = Mat(Xaxis, Yaxis, Zaxis)
    v[0] = r.xx
    v[1] = r.xy
    v[2] = r.xz
    v[3] = r.yx
    v[4] = r.yy
    v[5] = r.yz
    v[6] = r.zx
    v[7] = r.zy
    v[8] = r.zz
    if pos is not None:
        v[9:12] = pos.x, pos.y, pos.z
    if cen is not None:
        v[12:15] = cen.x, cen.y, cen.z
    if ncp is not None:
        v[15] = ncp
    if fcp is not None:
        v[16] = fcp
    cmd.set_view(v)
    return Yaxis
Ejemplo n.º 20
0
    def __call__(self):
        if self.name not in cmd.get_names('objects'):
            import threading
            threading.Thread(None, cmd.delete, args=(self.cb_name,)).start()
            return

        v = cmd.get_view()
        if v == self.prev_v:
            return
        self.prev_v = v

        t = v[12:15]

        if self.corner:
            vp = cmd.get_viewport()
            R_mc = [v[0:3], v[3:6], v[6:9]]
            off_c = [0.15 * v[11] * vp[0] / vp[1], 0.15 * v[11], 0.0]
            if self.corner in [2,3]:
                off_c[0] *= -1
            if self.corner in [3,4]:
                off_c[1] *= -1
            off_m = cpv.transform(R_mc, off_c)
            t = cpv.add(t, off_m)

        z = -v[11] / 30.0
        m = [z, 0, 0, 0, 0, z, 0, 0, 0, 0, z, 0, t[0] / z, t[1] / z, t[2] / z, 1]
        cmd.set_object_ttt(self.name, m)
Ejemplo n.º 21
0
def get_coord(v):
    if not isinstance(v, str):
        try:
            return v[:3]
        except:
            return False
    if v.startswith('['):
        return cmd.safe_list_eval(v)[:3]
    try:
        if cmd.count_atoms(v) == 1:
            # atom coordinates
            return cmd.get_atom_coords(v)
        else:
            # more than one atom --> use "center"
            # alt check!
            if cmd.count_atoms('(alt *) and not (alt "")') != 0:
                print(
                    "distancetoatom: warning! alternative coordinates found for origin, using center!"
                )
            view_temp = cmd.get_view()
            cmd.zoom(v)
            v = cmd.get_position()
            cmd.set_view(view_temp)
            return v
    except:
        return False
Ejemplo n.º 22
0
    def __init__(self, top, queue, Sphere, SphereDisplay, SphereSize,
                 ExtraPrompt):

        #print "New instance of flexsphere Wizard"

        Wizard.__init__(self)

        self.top = top
        self.queue = queue
        self.App = self.top.top

        self.App.WizardError = False
        self.App.WizardResult = 0

        self.Sphere = Sphere
        self.SphereView = self.Sphere.Copy()

        self.SphereSize = SphereSize
        self.SphereDisplay = SphereDisplay
        self.View = cmd.get_view()

        self.ErrorCode = 0

        self.Prompt = [
            "Press Shift + Mouse3 (Wheel Click) to move the sphere.",
            "Use the scaler in the " + self.App.Name +
            " interface to edit its radius."
        ]

        if ExtraPrompt:
            self.Prompt.append(ExtraPrompt)
Ejemplo n.º 23
0
def make_pov(file, meta=True):
        f1, f2 = file, file[:-4] + '.inc'
 
        (header,data) = cmd.get_povray()
        povfile = open(f1,'w')
        if meta: povfile.write(header)
        povview = cmd.get_view()
 
        povfile.write("""\n
// Uncomment the following lines if you have the pymolmacro.inc include file and want to use it.
/*
#include \"pymolmacro.inc\"
PYMOL_VIEW( %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f )
*/
 
""" % povview)
        povfile.write('#include "%s"\n\n' % f2)
        povfile.close()
        povfile = open(f2,'w')
        povfile.write(data)
        povfile.close()
Ejemplo n.º 24
0
def show_points(points, color = [1.0, 0.0, 0.0], selection='all', name = 'samples', labels=[]):
    view = cmd.get_view(quiet=not DEBUG)

    # adjust radius to size of bounding box
    bb = cmd.get_extent(selection, quiet=not DEBUG)
    ll = vec3(bb[0])
    tr = vec3(bb[1])
    diag = tr - ll
    r = diag.length() / 2.0

    # origin of rotation in model space
    #o = vec3(view[12:15])
    c = com.COM(selection)
    o = vec3(c)
    #spheres = [BEGIN, TRIANGLE_STRIP]
    spheres = [COLOR]
    spheres.extend(color)
    i = 0.0
    j = 0
    for p in points:
        
        #spheres.extend([COLOR, 1.0, 1 - scaled_value, 1 - scaled_value])
        spheres.extend([SPHERE, o[0]+r*p[0], o[1]+r*p[1], o[2]+r*p[2], 1.25])
        #drawVector(o, o + r * vec3(p))
        #spheres.extend([VERTEX, o[0]+r*p[0], o[1]+r*p[1], o[2]+r*p[2]])
        #i += 1.0/len(values)
        l = 1.1
        if (len(labels) > j):
            cmd.pseudoatom(labels[j] + "_label", pos = [o[0]+l * r*p[0], o[1]+l*r*p[1], o[2]+l*r*p[2], 1.25], label = labels[j])    

        j += 1

    #spheres.extend([END])
    cmd.load_cgo(spheres, name, 1)
Ejemplo n.º 25
0
def crisscross(x, y, z, d, name="ref_center"):
    obj = [
        LINEWIDTH, 3, COLOR,
        float(1.05),
        float(0.15),
        float(1.5), BEGIN, LINE_STRIP, VERTEX,
        float(x - d),
        float(y),
        float(z), VERTEX,
        float(x + d),
        float(y),
        float(z), END, BEGIN, LINE_STRIP, VERTEX,
        float(x),
        float(y - d),
        float(z), VERTEX,
        float(x),
        float(y + d),
        float(z), END, BEGIN, LINE_STRIP, VERTEX,
        float(x),
        float(y),
        float(z - d), VERTEX,
        float(x),
        float(y),
        float(z + d), END
    ]
    if name[0] == 'O':
        obj[3:6] = [float(1.00), float(0.80), float(0.80)]
    view = cmd.get_view()
    cmd.load_cgo(obj, name)
    cmd.set_view(view)
Ejemplo n.º 26
0
    def __init__(self, top, queue, ResSeq, LigandPath):
        
        #print "New instance of flexbond Class.\n"

        Wizard.__init__(self)

        self.top = top
        self.queue = queue
        self.FlexAID = self.top.top
        self.FlexAID.WizardError = False

        self.ResSeq = ResSeq
        
        self.dictFlexBonds = self.FlexAID.IOFile.Vars.dictFlexBonds
        self.dictNeighbours = self.FlexAID.IOFile.Vars.dictNeighbours

        self.RefLigand = LigandPath

        self.View = cmd.get_view()
        self.State = cmd.get_state()
        self.auto_zoom = cmd.get("auto_zoom")
        
        self.pick_count = 0
        
        self.panelForceBond = 'Adv.: Force bond OFF'
        self.Force = False

        self.point1 = list()
        self.point2 = list()

        self.atom1 = list()
        self.atom2 = list()

        self.ErrorStatus = [ "Flexible bonds of the ligand are shown in orange.",
                             "Selected flexible bonds of the ligand are shown in white." ]
Ejemplo n.º 27
0
 def testMove(self):
     for a in "xyz":
         cmd.turn(a, random.random() * 10 - 5)
         cmd.move(a, random.random() * 10 - 5)
     v = list(cmd.get_view())
     d = (2, 4, 6)
     cmd.move("x", d[0])
     cmd.move("y", d[1])
     cmd.move("z", d[2])
     m = cmd.get_view()
     v[9] += d[0]
     v[10] += d[1]
     v[11] += d[2]
     v[15] -= d[2]
     v[16] -= d[2]
     self.assertArrayEqual(v, m, delta=1e-3)
Ejemplo n.º 28
0
    def __call__(self):
        if self.name not in cmd.get_names('objects'):
            import threading
            threading.Thread(None, cmd.delete, args=(self.cb_name,)).start()
            return

        v = cmd.get_view()
        if v == self.prev_v:
            return
        self.prev_v = v

        t = v[12:15]

        if self.corner:
            vp = cmd.get_viewport()
            R_mc = [v[0:3], v[3:6], v[6:9]]
            off_c = [0.15 * v[11] * vp[0] / vp[1], 0.15 * v[11], 0.0]
            if self.corner in [2,3]:
                off_c[0] *= -1
            if self.corner in [3,4]:
                off_c[1] *= -1
            off_m = cpv.transform(R_mc, off_c)
            t = cpv.add(t, off_m)

        z = -v[11] / 30.0
        m = [z, 0, 0, t[0] / z, 0, z, 0, t[1] / z, 0, 0, z, t[2] / z, 0, 0, 0, 1]
        cmd.set_object_ttt(self.name, m, homogenous=1)
Ejemplo n.º 29
0
 def testMove(self):
     for a in "xyz":
         cmd.turn(a, random.random() * 10 - 5)
         cmd.move(a, random.random() * 10 - 5)
     v = list(cmd.get_view())
     d = (2,4,6)
     cmd.move("x", d[0])
     cmd.move("y", d[1])
     cmd.move("z", d[2])
     m = cmd.get_view()
     v[9] += d[0]
     v[10] += d[1]
     v[11] += d[2]
     v[15] -= d[2]
     v[16] -= d[2]
     self.assertArrayEqual(v, m, delta=1e-3)
Ejemplo n.º 30
0
    def crisscross(self, x, y, z, d, name="crisscross"):

        obj = [
            LINEWIDTH, 3, BEGIN, LINE_STRIP, VERTEX,
            float(x - d),
            float(y),
            float(z), VERTEX,
            float(x + d),
            flaot(y),
            float(z), END, BEGIN, LINE_STRIP, VERTEX,
            float(x),
            float(y - d),
            float(z), VERTEX,
            float(x),
            float(y + d),
            float(z), END, BEGIN, LINE_STRIP, VERTEX,
            float(x),
            float(y),
            float(z - d), VERTEX,
            float(x),
            float(y),
            float(z + d), END
        ]
        view = cmd.get_view()
        cmd.load_cgo(obj, name)
        cmd.set_view(view)
Ejemplo n.º 31
0
def make_pov(file, meta=True):
    f1, f2 = file, file[:-4] + '.inc'

    (header, data) = cmd.get_povray()
    povfile = open(f1, 'w')
    if meta: povfile.write(header)
    povview = cmd.get_view()

    povfile.write("""\n
// Uncomment the following lines if you have the pymolmacro.inc include file and want to use it.
/*
#include \"pymolmacro.inc\"
PYMOL_VIEW( %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f,
            %10.5f, %10.5f, %10.5f )
*/
 
""" % povview)
    povfile.write('#include "%s"\n\n' % f2)
    povfile.close()
    povfile = open(f2, 'w')
    povfile.write(data)
    povfile.close()
Ejemplo n.º 32
0
def storeview(viewname):
    """
        Store the current view as a set view command under the given filename
        """
    view = cmd.get_view()
    of = open(viewname, "w")
    oof = open(viewname + "a", "w")
    oof.write( ` view ` + "\n")
    oof.close()
    #also echo to screen
    print("set_view (\\")
    of.write("set_view (\\\n")
    for x in range(0, 6):
        for y in range(0, 3):
            index = x * 3 + y
            print("%15.9f" % view[index]),
            of.write("%15.9f" % view[index])
            if x == 5 and y == 2:
                print(" "),
                of.write(" ")
            else:
                print(","),
                of.write(",")
        if x < 5:
            print("\\")
            of.write("\\\n")
        else:
            print(")")
            of.write(")\n")
    of.close()
Ejemplo n.º 33
0
def insert_current():
    #insert the current view into the list after the view
    #in views[cur_index]
    #set frames to default
    global cur_index
    global cur_view
    global views
    global frames
    global actions
    global scenes
    global settings
    global models
    global fades
 
    cur_index += 1
    cur_view = cmd.get_view()
    views.insert( cur_index, [cv for cv in cur_view] )
    frames.insert( cur_index, 50 )
 
    #deal with actions dictionary
    actions = incKeyAbove( actions, cur_index )
    scenes = incKeyAbove( scenes, cur_index )
    settings = incKeyAbove( settings, cur_index )
    models = incKeyAbove( models, cur_index )
    fades = incKeyAbove( fades, cur_index )
 
    print "New view:"
    print_view( cur_view )
    print "Inserted view with index", cur_index, "and a 50 frame transition"
Ejemplo n.º 34
0
    def __init__(self, top, queue, Sphere, SphereDisplay, SphereSize, ExtraPrompt):

        #print "New instance of flexsphere Wizard"

        Wizard.__init__(self)

        self.top = top
        self.queue = queue
        self.App = self.top.top

        self.App.WizardError = False
        self.App.WizardResult = 0

        self.Sphere = Sphere
        self.SphereView = self.Sphere.Copy()

        self.SphereSize = SphereSize
        self.SphereDisplay = SphereDisplay
        self.View = cmd.get_view()

        self.ErrorCode = 0

        self.Prompt = [ "Press Shift + Mouse3 (Wheel Click) to move the sphere.",
                        "Use the scaler in the " + self.App.Name + " interface to edit its radius." ]
                        
        if ExtraPrompt:
            self.Prompt.append( ExtraPrompt )
Ejemplo n.º 35
0
def mkhelix(sel, t, r, n):
    v = cmd.get_view()
    for i in range(1, n):
        cmd.delete("h%i" % i)
        cmd.create("h%i" % i, sel)
        rot("h%i" % i, Vec(0, 0, 1), i * r, Vec(0, 0, 0))
        trans("h%i" % i, Vec(0, 0, i * t))
    cmd.set_view(v)
Ejemplo n.º 36
0
def transform_by_camera_rotation():
     view = list(cmd.get_view())
     M = view[0:3] + [-view[12]] + \
         view[3:6] + [-view[13]] + \
         view[6:9] + [-view[14]] + \
         view[12:15] + [1.]
     cmd.transform_selection('(all)', M, transpose=1)
     cmd.set_view([1,0,0,0,1,0,0,0,1] + view[9:])
Ejemplo n.º 37
0
def mkhelix(sel, t, r, n):
    v = cmd.get_view()
    for i in range(1, n):
        cmd.delete("h%i" % i)
        cmd.create("h%i" % i, sel)
        rot("h%i" % i, Vec(0, 0, 1), i * r, Vec(0, 0, 0))
        trans("h%i" % i, Vec(0, 0, i * t))
    cmd.set_view(v)
Ejemplo n.º 38
0
def mki213(N, sel = 'all'):
	v = cmd.get_view()
	cmd.delete("i213_*")
	cmd.delete('base80345769083457')
	cmd.delete('tmp80345769083457')
	c2 = com(sel)
	c3 = Vec(0, 0, 0)
	cmd.create( 'tmp80345769083457', sel)
	a2 = c2axis('tmp80345769083457')
	cmd.delete( 'tmp80345769083457')
	a3 = Vec(0, 0, 1)
	cmd.create('base80345769083457', sel+" and chain A and visible")
	seenit = []
	R2 = [rotation_matrix(a2, 0), rotation_matrix(a2, 180), ]
	R3 = [rotation_matrix(a3, 0), rotation_matrix(a3, 120), rotation_matrix(a3, 240), ]
	C = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	print a2, c2, a3, c3
	for i21 in range(2):
		for i32 in range(3 if N > 1 else 1):
			for i22 in range(2 if N > 2 else 1):
				for i33 in range(3 if N > 3 else 1):
					for i23 in range(2 if N > 4 else 1):
						for i34 in range(3 if N > 5 else 1):
							for i24 in range(2 if N > 6 else 1):
								for i35 in range(3 if N > 7 else 1):
									for i25 in range(2 if N > 8 else 1):
										test = Vec(0, 0, 0)
										test = R2[i21]*(test-c2)+c2
										test = R3[i32]*(test-c3)+c3
										test = R2[i22]*(test-c2)+c2
										test = R3[i33]*(test-c3)+c3
										test = R2[i23]*(test-c2)+c2
										test = R3[i34]*(test-c3)+c3
										test = R2[i24]*(test-c2)+c2
										test = R3[i35]*(test-c3)+c3
										test = R2[i25]*(test-c2)+c2
										#print test
										seen = False
										for xs in seenit:
											if (xs-test).length() < 0.1:
												seen = True
												break
										if seen: continue
										else: seenit.append(test)
										n = "i213_%i%i%i%i%i%i%i%i%i"%(i25, i35, i24, i34, i23, i33, i22, i32, i21)
										cmd.create(n, 'base80345769083457 and name n+ca+c')
										rot(n, a2, i21*180.0, c2)
										rot(n, a3, i32*120.0, c3)
										rot(n, a2, i22*180.0, c2)
										rot(n, a3, i33*120.0, c3)
										rot(n, a2, i23*180.0, c2)
										rot(n, a3, i34*120.0, c3)
										rot(n, a2, i24*180.0, c2)
										rot(n, a3, i35*120.0, c3)
										rot(n, a2, i25*180.0, c2)
	print len(seenit)
	cmd.delete('base80345769083457')
	cmd.set_view(v)
Ejemplo n.º 39
0
def showsphere(c, r=1, col=(1, 1, 1), lbl=''):
    v = cmd.get_view()
    if not lbl:
        global numvec
        lbl = "sphere%i" % numvec
        numvec += 1
    mycgo = cgo_sphere(c=c, r=r, col=col)
    cmd.load_cgo(mycgo, lbl)
    cmd.set_view(v)
def showcyl(c1, c2, r, col=(1, 1, 1), col2=None, lbl=''):
    if not lbl:
        global numseg
        lbl = "seg%i" % numseg
        numseg += 1
    cmd.delete(lbl)
    v = cmd.get_view()
    cmd.load_cgo(cgo_cyl(c1=c1, c2=c2, r=r, col=col, col2=col2), lbl)
    cmd.set_view(v)
Ejemplo n.º 41
0
def get_views(points):
    ''' computes view matrices from points.
        assumes that the current view defines the up vector '''

    view = cmd.get_view(quiet=not DEBUG)
    rot = get_rotation(view)
    cam = rot.getRow(2).normalize()
    model_up = rot.getRow(1).normalize()
    model_right = rot.getRow(0).normalize()

    # temporarily decrease epsilon used for comparisons of vectors in cgit
    # to prevent math domain error when computing angles
    epsilon = getEpsilon()
    setEpsilon(9e-4)

    e = []
    for point in points:
        
        # find rotation matrix R to the new point
        spn = vec3(point).normalize()
        q = rotation_to(spn, cam)
        R = q.toMat3()

        # add rotation to initial rotation
        RR = rot * R

        # new camera coordinate system aligns
        # up vector with model_up vector
        # new_cam = vec3(point).normalize()
        new_cam = RR.getRow(2).normalize()
        lookAt = -new_cam
        up = model_right.cross(lookAt).normalize()

        #print "up: " + str(up) + "model_up: " + str(model_up)
        #print up == model_up
        #print up.cross(model_up).length() < 9e-4
        if up != model_up:
            if up.cross(model_up).length() < 9e-4 or up.angle(model_up) > pi/2:
                up = -(model_right).cross(lookAt).normalize()

        right = lookAt.cross(up).normalize()

        # compute the new view matrix
        RRR = mat3()
        RRR.setRow(0, right)
        RRR.setRow(1, up)
        RRR.setRow(2, new_cam)
        
        new_view = []
        new_view.extend(RRR.toList())
        new_view.extend(view[9:18])

        e.append((point, new_view))
        
    setEpsilon(epsilon)

    return e
Ejemplo n.º 42
0
 def __call__(self):
       # get view on screen
       my_view = cmd.get_view()
       delta_mv = 0.
       for i in range(18):
         delta_mv = max(delta_mv,abs(my_view[i] - self.my_view[i]))
         self.my_view[i] = my_view[i] 
       #print my_view
       # get orientation/position matrices for two molecules
       # how does pymol define rotation center of molecule? 
       # apparnetly by geometric average
       pdbmat1 = cmd.get_object_matrix(self.pdbobj1)
       pdbmat2 = cmd.get_object_matrix(self.pdbobj2)
       delta_mm = 0.
       for i in range(12):
         delta_mm = max(delta_mm,abs(pdbmat1[i] - self.objmat1[i]))
         delta_mm = max(delta_mm,abs(pdbmat2[i] - self.objmat2[i]))
         self.objmat1[i] = pdbmat1[i] 
         self.objmat2[i] = pdbmat2[i] 
       if(delta_mm > 0.01): # we only do expensive energy calc if pose changed
         do_mm = True
       else:
         do_mm = False
       if((delta_mv > 0.01) or do_mm): # we only update if pose or view changed
         cgo_obj = pdb_interaction(pdbmat1,pdbmat2,self.pdb1,self.pdb2,self.gcen1,self.gcen2,
            self.energy,do_mm,self.logscale,self.dielectric,self.eps,self.nbest,self.energy_min)
         if(self.nbest[0] != self.nbest[1]):
           # print('Switching models ',self.nbest)
           self.nbest[1] = self.nbest[0]
         #
         # write new best pose to logfile
         #
         et = self.energy[0]
         ee = self.energy[1]
         ev = self.energy[2]
         if(self.energy[0] < self.energy_min):
           print('       NEW MIN ee: %12.3g ev: %12.3g et: %12.3g model %4d ' % (ee,ev,et,self.nbest[0]))
           self.energy_min = et
           self.dockeye_log.write('new min: %12.5g %12.5g %12.5g model %4d \n' % (ee,ev,et,self.nbest[0]))
           for i in range(4):
             for j in range(4):
               indx = j + 4*i
               self.dockeye_log.write('%12.5f ' % (pdbmat1[indx]))
             self.dockeye_log.write('\n')
           for i in range(4):
             for j in range(4):
               indx = j + 4*i
               self.dockeye_log.write('%12.5f ' % (pdbmat2[indx]))
             self.dockeye_log.write('\n')
         #else:
         #  if(do_mm): 
         #    #print('Current energy: ee: %12.3g ev: %12.3g et: %12.3g' % (ee,ev,et))
         #    continue
       if(do_mm):
         cmd.delete('dockeye_obj')
         cmd.load_cgo(cgo_obj,'dockeye_obj')
         draw_ligand(pdbmat2,self.pdb2,self.gcen2,self.nbest[0])
Ejemplo n.º 43
0
def display_box(name, max_coords, min_coords):
    #
    # From the original AutoDock plugin
    #

    box = [
        [max_coords[0], min_coords[0]],
        [max_coords[1], min_coords[1]],
        [max_coords[2], min_coords[2]],
    ]
    cylinder_size = 0.2
    color = [1.0, 1.0, 1.0]

    view = cmd.get_view()
    obj = []

    # box_color
    for i in range(2):
        for k in range(2):
            for j in range(2):
                if i != 1:
                    obj.append(CYLINDER)
                    obj.extend([box[0][i], box[1][j], box[2][k]])
                    obj.extend([box[0][i + 1], box[1][j], box[2][k]])
                    obj.append(cylinder_size)
                    obj.extend(color)
                    obj.extend(color)
                    obj.append(COLOR)
                    obj.extend(color)
                    obj.append(SPHERE)
                    obj.extend([box[0][i], box[1][j], box[2][k], cylinder_size])

                if j != 1:
                    obj.append(CYLINDER)
                    obj.extend([box[0][i], box[1][j], box[2][k]])
                    obj.extend([box[0][i], box[1][j + 1], box[2][k]])
                    obj.append(cylinder_size)
                    obj.extend(color)
                    obj.extend(color)
                    obj.append(COLOR)
                    obj.extend(color)
                    obj.append(SPHERE)
                    obj.extend([box[0][i], box[1][j + 1], box[2][k], cylinder_size])
                if k != 1:
                    obj.append(CYLINDER)
                    obj.extend([box[0][i], box[1][j], box[2][k]])
                    obj.extend([box[0][i], box[1][j], box[2][k + 1]])
                    obj.append(cylinder_size)
                    obj.extend(color)
                    obj.extend(color)
                    obj.append(COLOR)
                    obj.extend(color)
                    obj.append(SPHERE)
                    obj.extend([box[0][i], box[1][j], box[2][k + 1], cylinder_size])
    axes = [[2.0, 0.0, 0.0], [0.0, 2.0, 0.0], [0.0, 0.0, 2.0]]
    cmd.load_cgo(obj, name)
    cmd.set_view(view)
Ejemplo n.º 44
0
def dump_rep(name):
    if 'PYMOL_GIT_MOD' in os.environ:
        import shutil
        try:
            shutil.copytree(
                os.path.join(os.environ['PYMOL_GIT_MOD'], 'pymol2glmol', 'js'),
                os.path.join(os.getcwd(), 'js'))
        except OSError:
            pass

    names = cmd.get_session()['names']
    cmd.set('pdb_retain_ids', 1)

    ret = ''
    for obj in names:
        if (obj == None):
            continue
        if (obj[2] == 0):  # not visible
            continue
        if (obj[1] == 0 and obj[4] == 1 and obj[0] == name):
            ret += parseObjMol(obj)
        if (obj[1] == 0
                and obj[4] == 4):  # currently all dist objects are exported
            ret += parseDistObj(obj)

    cmd.turn('z', 180)
    view = cmd.get_view()
    cmd.turn('z', 180)
    cx = -view[12]
    cy = -view[13]
    cz = -view[14]
    cameraZ = -view[11] - 150
    fov = float(cmd.get("field_of_view"))
    fogStart = float(cmd.get("fog_start"))
    slabNear = view[15] + view[11]
    slabFar = view[16] + view[11]
    ret += "\nview:%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f,%.3f" % \
        (cx, cy, cz, cameraZ, slabNear, slabFar, fogStart, fov)
    for i in range(9):
        ret += ",%.3f" % view[i]

    bgcolor = cmd.get_setting_tuple('bg_rgb')[1]
    ret += "\nbgcolor:%02x%02x%02x" % (int(255 * float(bgcolor[0])), \
                                       int(255 * float(bgcolor[1])), int(255 * float(bgcolor[2])))
    if 'PYMOL_GIT_MOD' in os.environ:
        template = open(os.path.join(os.environ['PYMOL_GIT_MOD'], 'pymol2glmol', 'imported.html')).read().\
            replace("###INCLUDE_PDB_FILE_HERE###", cmd.get_pdbstr(name)).\
            replace('###INCLUDE_REPRESENTATION_HERE###', ret)
    else:
        template = open('imported.html').read().\
            replace("###INCLUDE_PDB_FILE_HERE###", cmd.get_pdbstr(name)).\
            replace('###INCLUDE_REPRESENTATION_HERE###', ret)

    f = open(name + '.html', 'w')
    f.write(template)
    f.close()
Ejemplo n.º 45
0
def orient_origin(selection):
    shift_to_center(selection)
    cmd.orient(selection)
    cv = list(cmd.get_view(quiet=1))
    #cmd.origin(selection, position=origin1)
    cmd.transform_selection(selection,
                            cv[0:3] + [0.0] + cv[3:6] + [0.0] + cv[6:9] +
                            [0.0] + cv[12:15] + [1.0],
                            transpose=1)
    cmd.reset()
Ejemplo n.º 46
0
 def createAtomObj(self, number):
     view = cmd.get_view()
     cmd.create(self.indexes_list[number], self.object_prefix + str(number))
     cmd.set_view(view)
     cmd.set("sphere_scale", '0.3', self.indexes_list[number])
     cmd.show_as('spheres', self.indexes_list[number])
     if number < 3:
         cmd.color("red", self.indexes_list[number])
     else:
         cmd.color("green", self.indexes_list[number])
Ejemplo n.º 47
0
def showlineabs(a, c, col=(1, 1, 1), lbl=''):
    if not lbl:
        global numline
        lbl = "line%i" % numline
        numline += 1
    cmd.delete(lbl)
    v = cmd.get_view()
    cgo = cgo_lineabs(a, c, col)
    cmd.load_cgo(cgo, lbl)
    cmd.set_view(v)
Ejemplo n.º 48
0
def dump_mviews():
    '''
DESCRIPTION

    Dump the current movie as 'set_view' with 'mview store' commands.
    '''
    for frame in get_keyframes() or ():
        cmd.frame(frame)
        print(cmd.get_view(3).strip())
        print('mview store, {}'.format(frame))
Ejemplo n.º 49
0
def get_PCA_views(selection):
    old_view = cmd.get_view(quiet=1)

    cmd.orient(selection)
    view = cmd.get_view(quiet=1)
    rot = get_rotation_from_view(view)
    
    # now rot resembles view
    pc3 = rot.getRow(2)
    pc1 = rot.getRow(0)
    pc2 = rot.getRow(1)

    preferred1 = rot.getRow(2).normalize()

    rot2 = rot.rotate(pi, pc1)

    preferred2 = rot2.getRow(2).normalize()

    return (preferred1, preferred2)
Ejemplo n.º 50
0
def probe_object(obj):
    '''Run Probe on the "Reduce-d" coordinates of a loaded PyMOL object.

    ARGUMENTS

        obj (str)

            Name of a loaded PyMOL object that has already been passed as an
            argument to `reduce_object()` (or `reduce_obj` from the PyMOL
            command line).

    NOTE

        Reduce_object() must be run prior to probe_object() in order to set up
        an MPObject instance in the `objects` dictionary.  Running
        probe_object() on a plain PyMOL object will fail.  Also, accordingly,
        keep in mind that the coordinates probe_object() uses are those of the
        Reduce-modified version.  For an object `myobj`, this will typically
        be `mp_myobj.myobj_reduce`.

    '''


    o = get_object(obj)

    # Clear previous results
    cmd.delete(o.pdb['probe'])  # coords
    cmd.delete(o.get_kin_cgo_group('probe'))  # cgo

    # Create the PDB to use with the 'probe' kinemage
    if o.pdb['userflips'] in cmd.get_names():
        which = 'userflips'
    else:
        which = 'reduce'
    v = cmd.get_view()
    cmd.create(o.pdb['probe'], o.pdb[which])
    cmd.set_view(v)

    pdbstr = o.get_pdbstr('probe')
    output = generate_probe_output(pdbstr)

    # Fail gracefully if probe call returns no output.
    if not output:
        msg = 'Failed to generate Probe output for {}.'.format(obj)
        logger.error(msg)
        return

    logger.info("Generated Probe output for '{}'.".format(obj))

    # Store list of dots and vectors
    o.kin['probe'] = process_probe_output(output)

    # Draw dots and vectors
    o.draw('probe')
    cmd.set_view(v)
Ejemplo n.º 51
0
	def save(self,manual=False,savepse=False):
		sd = "mutalyze_MANUAL_SAVE/" if manual else savedir
		if not os.path.exists(sd): os.mkdir(sd)
		redopent(self.obj)
		sname = self.getsavename(sd)
		if savepse: cmd.save(sname+".pse")
		cmd.save (sname+".pdb",self.obj+" or pnt*")
		with open(sname+".resfile","w") as o: o.write(self.resfile()+"\n")
		#print "saved pse, pdb, and resfile with notes"
		self.remembermm = self.manager.m
		self.remembermv = cmd.get_view()
Ejemplo n.º 52
0
def frame_scaler():
    previous_frame = None
    while True:
        frame = (yield)
        if previous_frame and frame and frame.scale_probability(previous_frame) > 0.2:
            scale_factor = frame.scale_factor(previous_frame)
            if scale_factor != 1.0:
                view = list(cmd.get_view())
                delta_z = math.log(scale_factor) * 100.0
                view[11] += delta_z
                view[15] -= delta_z
                view[16] -= delta_z
                cmd.set_view(view)
        previous_frame = frame
Ejemplo n.º 53
0
def insert_scene():
    global views
    global actions
    global settings
    global frames
    global cur_index
    global cur_view
    global scenes
    global scene_counter
    global models
    global fades
 
    cur_index += 1
    cur_view = cmd.get_view()
    views.insert( cur_index, [cv for cv in cur_view] )
    frames.insert( cur_index, 50 )
 
    #deal with dictionaries
    actions = incKeyAbove( actions, cur_index )
    scenes = incKeyAbove( scenes, cur_index )
    settings = incKeyAbove( settings, cur_index )
    models = incKeyAbove( models, cur_index )
    fades = incKeyAbove( fades, cur_index )
 
    #this stuff has to be done after the above
    #find a free scene name
    i = 1
    found = 1
    while found == 1:
        found = 0
        for sname in scenes.values():
            print "|"+sname+"|"
            if sname == "slerpy_"+str(i):
                found = 1
                break
        if found == 1:
            i += 1
        else:
            break
    newname = "slerpy_"+str(i)
 
    scene_counter += 1
    cmd.scene( newname, "store" )
    scenes[ cur_index ] = newname
    actions[ cur_index ] = "scene "+newname
 
    print "New view:"
    print_view( cur_view )
    print "Inserted view with index", cur_index, "and a 50 frame transition"
    print "Added scene",newname
Ejemplo n.º 54
0
	def focus(self):
		self.manager.m = self
		if self.manager.prevm: cmd.hide('sticks',self.manager.prevm.rdes.sel())
		if self.manager.prevm: cmd.color('green',self.manager.prevm.rdes.sel()+" and elem C")
		fr = self.rnat.obj+" and name n+ca+c and resi %i-%i"%(self.rnat.resi-10,self.rnat.resi+10)		
		to = self.rdes.obj+" and name n+ca+c and resi %i-%i"%(self.rdes.resi-10,self.rdes.resi+10)
		cmd.align(fr,to)
		cmd.show('sticks',self.rdes.sel())
		cmd.color('white',self.rdes.sel()+" and elem C")
		cmd.center(self.rdes.sel())
		v = list(cmd.get_view())
		v[11] = -80.0
		cmd.set_view(tuple(v))
		cmd.clip('slab',50,self.rdes.sel())
Ejemplo n.º 55
0
def Rotate( angleX, angleY):
	#if not CheckMaster(controller):
	#	return
	currtime = time.clock()
	global lastmovetime
	#Slowdown code vvv - don't use for right now
	if ((currtime - lastmovetime) < .01):
	        #print "derp"
		return
	view = list(cmd.get_view())
	view = rotateView(view, angleX/20, angleY/20, 0)
	cmd.set_view(view)
	#DamageGUI()
	cmd.refresh()
	lastmovetime = time.clock()
Ejemplo n.º 56
0
def append_view():
    global views
    global frames
    global cur_index
    global cur_view
 
    cur_index = len(views)
    cur_view = cmd.get_view()
    views.append( [cv for cv in cur_view] )
    frames.append( 50 )
 
    print "New view: "
    print_view( cur_view )
    print "Appended view with index", cur_index, "and a 50 frame transition"
    print "The current view is", cur_index
Ejemplo n.º 57
0
def getnative():
    v = cmd.get_view()
    nats = []
    for obj in cmd.get_object_list():
        if len(obj) == 4:
            nats.append(obj)
            continue
        pid = obj[:4]
        if pid in nats:
            continue
        print "fetching native", pid
        cmd.fetch(pid)
        cmd.remove(pid + " and not chain A")
        cmd.remove(pid + " and resn HOH")
        cmd.align(pid, obj)
    cmd.set_view(v)
Ejemplo n.º 58
0
def hand_rotator():
    previous_frame = None
    while True:
        hand = (yield)
        if previous_frame and hand and hand.rotation_probability(previous_frame) > 0.1:
            view = list(cmd.get_view())
            matrix = hand.rotation_matrix(previous_frame)
            matrix *= Leap.Matrix(Leap.Vector(*view[0:3]),
                                  Leap.Vector(*view[3:6]),
                                  Leap.Vector(*view[6:9]))
            view[:9] = matrix.to_array_3x3()
            cmd.set_view(view)
        if hand:
            previous_frame = hand.frame
        else:
            previous_frame = None