예제 #1
0
 def testLabel(self, func):
     cmd.pseudoatom('m1')
     for expr in expr_list + ['resn + " " + resi']:
         func('*', expr)
         self.assertEqualIterate('label', expr)
     func()
     self.assertTrueIterate('label == ""')
예제 #2
0
def createPseudoatom (coordinates, objectName):
    x=float(coordinates[0])
    y=float(coordinates[1])
    z=float(coordinates[2])
    #print x,y,z,objectName
    posString="[%3.2f,%3.2f,%3.2f]" % (x,y,z)
    cmd.pseudoatom(pos=posString, object=objectName)
예제 #3
0
    def testLabelPositionZ(self, use_shaders, ray):
        '''
        Test label z position for regular labels
        '''
        if not ray and invocation.options.no_gui:
            self.skipTest('no gui')

        cmd.set('use_shaders', use_shaders)

        cmd.viewport(200, 200)

        cmd.pseudoatom('m1', vdw=10, label='X')
        cmd.zoom(buffer=12)

        cmd.show('spheres')
        cmd.color('blue')
        cmd.set('label_color', 'red')
        cmd.set('label_size', 20)
        cmd.set('label_font_id', 7) # bold
        self.ambientOnly()

        # label outside of sphere
        cmd.set('label_position', [0, 0, 11.1])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img, delta=20)

        # label inside of sphere
        cmd.set('label_position', [0, 0, 10.5])
        img = self.get_imagearray(ray=ray)
        self.assertImageHasColor('blue', img)
        self.assertImageHasNotColor('red', img, delta=20)
예제 #4
0
 def test_atom_state_settings_3f(self, f, data):
     m1 = "pseudo01"
     lp1, lp2 = lp = map(f, data)
     cmd.pseudoatom(m1)
     cmd.pseudoatom(m1)
     cmd.create(m1, m1, 1, 2)
     stored.pos = {}
     stored.lp1 = lp1
     stored.lp2 = lp2
     stored.origp = None
     # get origp (should be 0.,0.,0.
     cmd.alter("(index 1)", "stored.origp = s['label_placement_offset']")
     # change atom-state setting to lp1 for atom in both states
     cmd.alter_state(0, "(index 1)", "s['label_placement_offset']=stored.lp1")
     # change atom-level setting for all atoms to something else
     cmd.alter("all", "s['label_placement_offset']=stored.lp2")
     # get atom-state settings
     cmd.iterate_state(0, "all", "stored.pos['%s-%s-%s' % (model, state, index)]=s['label_placement_offset']")
     # atom-state setting should be lp1 for atom 1
     self.assertEqual(tuple(lp1), stored.pos['%s-%s-%s' % (m1, 1, 1)])
     self.assertEqual(tuple(lp1), stored.pos['%s-%s-%s' % (m1, 2, 1)])
     # atom setting should override to lp2 for atom 2 in both states
     self.assertEqual(tuple(lp2), stored.pos['%s-%s-%s' % (m1, 1, 2)])
     self.assertEqual(tuple(lp2), stored.pos['%s-%s-%s' % (m1, 2, 2)])
     # unset all atom-level settings, atom-state settings should still exist
     cmd.alter("all", "s['label_placement_offset']=None")
     stored.pos = {}
     cmd.iterate_state(0, "all", "stored.pos['%s-%s-%s' % (model, state, index)]=s['label_placement_offset']")
     self.assertEqual(tuple(lp1), stored.pos['%s-%s-%s' % (m1, 1, 1)])
     self.assertEqual(tuple(lp1), stored.pos['%s-%s-%s' % (m1, 2, 1)])
     self.assertEqual(tuple(stored.origp), stored.pos['%s-%s-%s' % (m1, 1, 2)])
     self.assertEqual(tuple(stored.origp), stored.pos['%s-%s-%s' % (m1, 2, 2)])
예제 #5
0
    def test(self):
        cmd.set('suspend_updates')
        cmd.set('depth_cue', 0)
        cmd.set('ambient', 1)
        cmd.set('specular', 0)
        cmd.set('stereo_angle', 10)
        cmd.pseudoatom()
        cmd.show_as('sphere')
        cmd.zoom()
        cmd.stereo('anaglyph')
        cmd.set('suspend_updates', 0)

        wh = (40, 40)
        cmd.draw(*wh, antialias=0)
        cmd.sync()

        img = self.get_imagearray(prior=1)
        self.assertEqual(wh, img.shape[:2])

        # ray tracing and shaders in PyMOL 1.7.6+:
        # 0xe50000
        # 0x00e5e5
        # -> delta=26 (0x1a)

        self.assertImageHasColor('0xff0000', img, delta=0x1a)
        self.assertImageHasColor('0x00ffff', img, delta=0x1a)
예제 #6
0
    def testLabelRelativeMode(self):
        # +-----+-----+
        # |     |     |
        # +-----+-----+
        # | XYZ |     |
        # +-----+-----|

        self.ambientOnly()
        cmd.set('opaque_background')
        cmd.set('label_font_id', 7)  # bold
        cmd.set('label_color', 'white')
        cmd.set('label_size', -1)  # Angstrom sized
        cmd.pseudoatom('m1', label="XYZ")
        cmd.zoom()

        width = 400
        height = 200
        w4 = width // 4
        h4 = height // 4

        cmd.viewport(width, height)

        for x in (-1, 1):
            for y in (-1, 1):
                # relative position
                cmd.set('label_relative_mode', 1)
                cmd.set('label_screen_point', (0.5 * x, 0.5 * y, 0))
                self.assertColorInQuadrant(x, y, width, height)

                # absolute position in pixels
                cmd.set('label_relative_mode', 2)
                cmd.set('label_screen_point', ((2 + x) * w4, (2 + y) * h4, 0))
                self.assertColorInQuadrant(x, y, width, height)
예제 #7
0
    def test_wildcard_sets_ranges(self):
        for i in range(10): cmd.pseudoatom('m%d' % i, chain=chr(65 + i))
        cmd.alter('m5', 'chain = "AB"')
        cmd.alter('m6', 'chain = "BA"')
        cmd.alter('m7', 'chain = "CC"')
        cmd.alter('m8', 'chain = "ZA"')
        cmd.alter('m9', 'chain = "ABA"')
        # A patterns
        self.assertEqual(1, cmd.count_atoms('chain A'))
        self.assertEqual(3, cmd.count_atoms('chain A*'))
        self.assertEqual(4, cmd.count_atoms('chain *A'))
        self.assertEqual(5, cmd.count_atoms('chain *A*'))
        self.assertEqual(1, cmd.count_atoms('chain A*A'))
        # B patterns
        self.assertEqual(2, cmd.count_atoms('chain B*'))
        self.assertEqual(2, cmd.count_atoms('chain *B'))
        self.assertEqual(4, cmd.count_atoms('chain *B*'))
        # X patterns (no matches)
        self.assertEqual(0, cmd.count_atoms('chain X*'))
        self.assertEqual(0, cmd.count_atoms('chain *X'))
        self.assertEqual(0, cmd.count_atoms('chain *X*'))
        # list with wildcards
        self.assertEqual(5, cmd.count_atoms('chain B*+A*'))
        self.assertEqual(3, cmd.count_atoms('chain B*+A*A'))
        self.assertEqual(3, cmd.count_atoms('chain B*+A*A+*X'))

        # lexicographical alpha ranges, A:C, will match AB (A <= AB <= C) but not CC (C < CC)
        # no wildcards in alpha ranges possible
        self.assertEqual(6, cmd.count_atoms('chain A:C'))
        self.assertEqual(6, cmd.count_atoms('chain A:CA'))
        self.assertEqual(7, cmd.count_atoms('chain A:CX')) # include CC
        self.assertEqual(6, cmd.count_atoms('chain A:C+Z'))
        self.assertEqual(7, cmd.count_atoms('chain A:C+Z*'))
예제 #8
0
파일: Sphere.py 프로젝트: NRGlab/NRGsuite
    def DisplaySphere(self):
   
        try:
            # Display the Sphere
            cmd.delete(self.SphereDisplay)
            cmd.refresh()
        except:
            pass

        try:
            cmd.pseudoatom(self.SphereDisplay,
                           pos=self.SphereView.Center,
                           vdw=self.SphereView.Radius,
                           state=self.State)
            cmd.refresh()

            cmd.color('oxygen', self.SphereDisplay)
            cmd.refresh()

            cmd.hide('everything', self.SphereDisplay)
            cmd.refresh()

            cmd.show('spheres', self.SphereDisplay)
            cmd.refresh()
            
        except:
            self.ErrorCode = 1

        return self.ErrorCode
예제 #9
0
    def testDoNotDuplicateGroup(self):
        cmd.pseudoatom("m3")
        cmd.group("g1", "m3")
        cmd.load("PYMOL-772-example.pse.gz", partial=1)

        v = cmd.get_names()
        self.assertEqual(v, ["m3", "g1", "m1", "m2"])
예제 #10
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)
예제 #11
0
def com(selection,state=None,mass=None,object=None, quiet=1, **kwargs):
   """
DESCRIPTION
 
   Places a pseudoatom at the center of mass
 
   Author: Sean Law
   Michigan State University
   slaw (at) msu . edu
 
SEE ALSO
 
   pseudoatom, get_com
   """
   quiet = int(quiet)
   if (object == None):
      object = cmd.get_legal_name(selection)
      object = cmd.get_unused_name(object + "_COM", 0)
   cmd.delete(object)
 
   if (state != None):
      x, y, z=get_com(selection,mass=mass, quiet=quiet)
      if not quiet:
         print "%f %f %f" % (x, y, z)
      cmd.pseudoatom(object,pos=[x, y, z], **kwargs)
      cmd.show("spheres",object)
   else:
      for i in range(cmd.count_states()):
         x, y, z=get_com(selection,mass=mass,state=i+1, quiet=quiet)
         if not quiet:
            print "State %d:%f %f %f" % (i+1, x, y, z)
         cmd.pseudoatom(object,pos=[x, y, z],state=i+1, **kwargs)
         cmd.show("spheres", 'last ' + object)
예제 #12
0
def load_net():
    file_coors = open_it()
    i = 0
    for line in open(file_coors, "r"):
        coors_net = map(float, line.split())
        i = i + 1
        cmd.pseudoatom("net", pos=coors_net, name="node", resi=i, chain="A")
예제 #13
0
    def testDel(self):
        cmd.pseudoatom('m1')

        stored.keys = []
        cmd.alter('all', 'p.foo = 123')
        cmd.alter('all', 'p.bar = "Hello World"')
        cmd.iterate('all', 'stored.keys = list(sorted(p.all))')
        self.assertEqual(stored.keys, ['bar', 'foo'])

        stored.keys = []
        cmd.alter('all', "del p['foo']")
        cmd.iterate('all', 'stored.keys = list(sorted(p.all))')
        self.assertEqual(stored.keys, ['bar'])

        stored.keys = []
        cmd.alter('all', "p.bar = None")
        cmd.iterate('all', 'stored.keys = list(sorted(p.all))')
        self.assertEqual(stored.keys, [])

        # object-level
        cmd.set_property('bla', 456, 'm1')
        stored.keys = cmd.get_property_list('m1')
        self.assertEqual(stored.keys, ['bla'])
        cmd.set_property('bla', None, 'm1')
        stored.keys = cmd.get_property_list('m1')
        self.assertEqual(stored.keys, [])
예제 #14
0
 def test_sort(self):
     cmd.pseudoatom('m1', name='PS2')
     cmd.pseudoatom('m1', name='PS1')
     v = [a.name for a in cmd.get_model().atom]
     self.assertEqual(['PS2', 'PS1'], v)
     cmd.sort()
     v = [a.name for a in cmd.get_model().atom]
     self.assertEqual(['PS1', 'PS2'], v)
예제 #15
0
 def test_attach(self):
     cmd.pseudoatom()
     cmd.edit('first all')
     cmd.attach('C', 1, 1)
     self.assertEqual(2, cmd.count_atoms())
     cmd.attach('C', 1, 1)
     self.assertEqual(3, cmd.count_atoms())
     self.assertEqual(['C01', 'C02', 'PS1'], sorted(get_atom_names()))
예제 #16
0
 def test_set_object_ttt(self):
     M = [1.0, 0.0, 0.0, 0.0,
          0.0, 0.0,-1.0, 0.0,
          0.0, 1.0, 0.0, 0.0,
          0.0, 0.0, 0.0, 1.0]
     cmd.pseudoatom('m1')
     cmd.set_object_ttt('m1', M)
     self.assertArrayEqual(M, cmd.get_object_matrix('m1'), 1e-4)
예제 #17
0
 def test_sort(self):
     cmd.pseudoatom('m1', name='PS2')
     cmd.pseudoatom('m1', name='PS1')
     cmd.alter('all', 'name = name_list.pop()', space={'name_list': ['PS1', 'PS2']})
     v = [a.name for a in cmd.get_model().atom]
     self.assertEqual(['PS2', 'PS1'], v)
     cmd.sort()
     v = [a.name for a in cmd.get_model().atom]
     self.assertEqual(['PS1', 'PS2'], v)
예제 #18
0
    def testDirtyDelete(self):
        cmd.pseudoatom('m1')
        cmd.pseudoatom('m2')
        cmd.group('g1', 'm1 m2')
        cmd.set_wizard(MockWizard())

        cmd.draw()

        v = cmd.get_object_list('(g1)')
        self.assertEqual(v, ['m1', 'm2'])
예제 #19
0
    def highlight_Atom(self, atom):

        try:
            cmd.pseudoatom(self.AtomDisplay, pos=atom[5:], vdw=0.30, color='white')
            cmd.hide('nonbonded', self.AtomDisplay)
            cmd.show('spheres', self.AtomDisplay)
            cmd.mask(self.AtomDisplay)
        except:
            self.FlexAID.DisplayMessage("Failed to highlight atom upon selecting atom", 1)
            return
예제 #20
0
    def testAlter(self):
        cmd.pseudoatom('m1')

        for ptype, names in self.alter_names_atomic.items():
            stored.v_mock = tuple(map(ptype, range(len(names))))
            names_fmt = '(' + ','.join(names) + ',)'

            if not (cmd.alter('all', names_fmt + ' = stored.v_mock') and
                    cmd.iterate('all', 'stored.v_names = ' + names_fmt)):
                raise UserWarning('iterate failed')

            self.assertEqual(stored.v_names, stored.v_mock)
예제 #21
0
    def testPngExists(self):
        '''
        Save a PNG image with width/height specified and
        check if the file exists.
        '''
        cmd.pseudoatom('m1')
        cmd.show('spheres')

        with testing.mktemp('.png') as filename:
            cmd.png(filename, width=100, height=100, ray=0)
            cmd.draw()
            self.assertTrue(os.path.exists(filename), 'png file not written')
    def drawAnnote(self, axis, x, y, annote):
        
        # EDIT: remove last markers
        for markers in self.drawnAnnotations.itervalues():
            for m in markers: # tuple
                #m.set_visible(not m.get_visible())
                m.remove()
        self.axis.figure.canvas.draw()
        self.drawnAnnotations = {}
        
        if (x,y) in self.drawnAnnotations:
            markers = self.drawnAnnotations[(x,y)] 
            for m in markers:
                m.set_visible(not m.get_visible())
            self.axis.figure.canvas.draw()
        
        else:
            """
            Mark data point and show data
            """
            t = axis.text(x,y, "(%3.2f, %3.2f)"%(x,y), )
            m = axis.scatter([x],[y], marker='d', c='r', zorder=100)
            self.drawnAnnotations[(x,y)] =(t,m)
            self.axis.figure.canvas.draw()

        """Your code here!"""
        cmd.delete('all')
        # load pdb files
        pdb_ext = '.pdb'
        cmd.load(self.native)
        cmd.load(os.path.join(self.pdb_dir, annote + pdb_ext))
        # label
        cmd.pseudoatom('foo')
        cmd.hide('all')
        #cmd.label('foo', '"'+annote+'"')
        # color
        native_name = os.path.splitext(os.path.basename(self.native))[0]        
        cmd.color('green', native_name)        
        cmd.set('label_color', 'green', native_name)
        cmd.color('blue', annote)        
        cmd.set('label_color', 'blue', annote)
        cmd.set('label_color', 'blue', 'foo')
        # background
        cmd.bg_color("white")
        cmd.set("depth_cue", 0)
        cmd.set("ray_trace_fog", 0)
        # view
        cmd.show(representation='cartoon')
        # alignment
        cmd.super(annote, native_name)
        # zoom
        cmd.zoom()        
        
예제 #23
0
 def test_set_object_settings_3f(self, f, data):
     m1 = "pseudo01"
     m2 = "pseudo02"
     cmd.pseudoatom(m1)
     cmd.pseudoatom(m2)
     lp1, lp2 = lp = map(f, data)
     cmd.set("label_position", lp1, m1)
     cmd.set("label_position", lp2, m2)
     stored.pos = {}
     cmd.iterate("all", "stored.pos[model]=s['label_position']")
     self.assertEqual(tuple(lp1), stored.pos[m1])
     self.assertEqual(tuple(lp2), stored.pos[m2])
예제 #24
0
    def testIterate(self):
        cmd.pseudoatom('m1')

        for ptype, names in (
                list(self.alter_names_atomic.items()) +
                list(self.alter_names_atomic_special.items())):
            stored.v_names = None
            cmd.iterate('all', 'stored.v_names = [' + ','.join(names) + ']')

            self.assertNotEqual(stored.v_names, None)
            for v in stored.v_names:
                self.assertTrue(isinstance(v, ptype))
예제 #25
0
    def test_unsetting_atom_setting(self, f, data):
        m1 = "pseudo01"
        lp = f(data)
        cmd.pseudoatom(m1)
        stored.lp = lp
        stored.pos = {}
        cmd.iterate("all", "stored.pos['%s-%s' % (model, index)] = s['label_placement_offset']")

        cmd.alter("all", "s['label_placement_offset']=stored.lp")
        stored.pos2 = {}
        cmd.alter("all", "s['label_placement_offset']=None")
        cmd.iterate("all", "stored.pos2['%s-%s' % (model, index)] = s['label_placement_offset']")
        self.assertEqual(stored.pos, stored.pos2)
예제 #26
0
    def test_set_symmetry(self):
        sym = [68.7, 126.8, 184.0, 90.0, 90.0, 90.0, 'P 21 21 21']
        cmd.pseudoatom('m1')
        cmd.set_symmetry('m1', *sym)
        v = cmd.get_symmetry('m1')
        self.assertEqual(v[-1], sym[-1])
        self.assertArrayEqual(v[:-1], sym[:-1], 1e-4)

        cmd.pseudoatom('m2')
        cmd.symmetry_copy('m1', 'm2')
        v = cmd.get_symmetry('m2')
        self.assertEqual(v[-1], sym[-1])
        self.assertArrayEqual(v[:-1], sym[:-1], 1e-4)
예제 #27
0
    def test_protect(self):
        cmd.pseudoatom('m1', pos=[0.,0.,0.])
        cmd.pseudoatom('m1', pos=[1.,0.,0.])

        cmd.protect('m1`1')
        cmd.translate([0.,1.,0.])
        self.assertEqual([0.,0.,0.], cmd.get_atom_coords('m1`1'))
        self.assertEqual([1.,1.,0.], cmd.get_atom_coords('m1`2'))

        cmd.deprotect()
        cmd.translate([0.,0.,1.])
        self.assertEqual([0.,0.,1.], cmd.get_atom_coords('m1`1'))
        self.assertEqual([1.,1.,1.], cmd.get_atom_coords('m1`2'))
예제 #28
0
    def test(self):
        for i in range(100):
            cmd.pseudoatom('xxxxxxxxxx%04d' % i)

        setting = 'sphere_color'
        color = 'blue'
        name = 'xxxxxxxxxx0005'
        cmd.set(setting, color, name)
        self.assertEqual(cmd.get(setting, name), color)

        # crashes in 1.7.6.0 to 1.7.6.6
        util.color_deep('red', 'all')

        self.assertEqual(cmd.get(setting, name), 'default')
예제 #29
0
    def test(self):
        names_ungrouped = ['a0', 'a1', 'b0', 'b1', 'c0', 'c1', 'g1']
        names_grouped   = ['a0', 'a1', 'c0', 'c1', 'b0', 'g1', 'b1']

        for name in names_ungrouped[:-1]:
            cmd.pseudoatom(name)
        cmd.group(names_ungrouped[-1])

        self.assertEqual(cmd.get_names(), names_ungrouped)

        cmd.group('g1', 'b*')
        cmd.order('b0 g1', location="upper")

        self.assertEqual(cmd.get_names(), names_grouped)
예제 #30
0
파일: network.py 프로젝트: Telpecarne/Aqua
def load_net():
   file_coors= open_it()
   net=network(file_coors)
   for ii in range(net.num_nodes):
      cmd.pseudoatom('net',pos=net.node[ii].coors,resi=ii,chain='A')
      selec='resi '+str(ii)
      cmd.alter(selec,'resn='+'"'+net.node[ii].label+'"')
      cmd.label(selec,'"'+net.node[ii].label+'"')
      cmd.alter(selec,'b='+str(net.node[ii].weight))
      cmd.alter(selec,'q='+str(net.node[ii].cluster))
   for ii in range(net.num_nodes):
      for jj in net.node[ii].link.keys():
         cmd.bond('resi '+str(ii),'resi '+str(jj))
   cmd.spectrum('b','blue_red')
예제 #31
0
파일: cube.py 프로젝트: lstorchi/NOCVplots
##cmd.show ('spheres', 'clauc2h2')

cmd.load('this.cube')
cmd.isosurface('sp', 'this', 0.005)
cmd.color('gray90', 'sp')
cmd.isosurface('sm', 'this', -0.005)
cmd.color('red', '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', 'off')
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=" ")
예제 #32
0
def angle_between_domains(selection1,
                          selection2,
                          method='align',
                          state1=STATE,
                          state2=STATE,
                          visualize=1,
                          quiet=1):
    '''
DESCRIPTION

    Angle by which a molecular selection would be rotated when superposing
    on a selection2.

    Do not use for measuring angle between helices, since the alignment of
    the helices might involve a rotation around the helix axis, which will
    result in a larger angle compared to the angle between helix axes.

USAGE

    angle_between_domains selection1, selection2 [, method ]

ARGUMENTS

    selection1 = string: atom selection of first helix

    selection2 = string: atom selection of second helix

    method = string: alignment command like "align" or "super" {default: align}

EXAMPLE

    fetch 3iplA 3iplB, async=0
    select domain1, resi 1-391
    select domain2, resi 392-475
    align 3iplA and domain1, 3iplB and domain1
    angle_between_domains 3iplA and domain2, 3iplB and domain2

SEE ALSO

    align, super, angle_between_helices
    '''
    import math

    try:
        import numpy
    except ImportError:
        print(' Error: numpy not available')
        raise CmdException

    state1, state2 = int(state1), int(state2)
    visualize, quiet = int(visualize), int(quiet)

    if cmd.is_string(method):
        try:
            method = cmd.keyword[method][0]
        except KeyError:
            print('no such method:', method)
            raise CmdException

    mobile_tmp = get_unused_name('_')
    cmd.create(mobile_tmp, selection1, state1, 1, zoom=0)
    try:
        method(mobile=mobile_tmp,
               target=selection2,
               mobile_state=1,
               target_state=state2,
               quiet=quiet)
        mat = cmd.get_object_matrix(mobile_tmp)
    except:
        print(' Error: superposition with method "%s" failed' %
              (method.__name__))
        raise CmdException
    finally:
        cmd.delete(mobile_tmp)

    try:
        # Based on transformations.rotation_from_matrix
        # Copyright (c) 2006-2012, Christoph Gohlke

        R33 = [mat[i:i + 3] for i in [0, 4, 8]]
        R33 = numpy.array(R33, float)

        # direction: unit eigenvector of R33 corresponding to eigenvalue of 1
        w, W = numpy.linalg.eig(R33.T)
        i = w.real.argmax()
        direction = W[:, i].real

        # rotation angle depending on direction
        m = direction.argmax()
        i, j, k, l = [[2, 1, 1, 2], [0, 2, 0, 2], [1, 0, 0, 1]][m]
        cosa = (R33.trace() - 1.0) / 2.0
        sina = (R33[i, j] +
                (cosa - 1.0) * direction[k] * direction[l]) / direction[m]

        angle = math.atan2(sina, cosa)
        angle = abs(math.degrees(angle))
    except:
        print(' Error: rotation from matrix failed')
        raise CmdException

    if not quiet:
        try:
            # make this import optional to support running this script standalone
            from .querying import centerofmass, gyradius
        except (ValueError, ImportError):
            gyradius = None
            try:
                # PyMOL 1.7.1.6+
                centerofmass = cmd.centerofmass
            except AttributeError:
                centerofmass = lambda s: cpv.scale(cpv.add(*cmd.get_extent(s)),
                                                   0.5)

        center1 = centerofmass(selection1)
        center2 = centerofmass(selection2)
        print(' Angle: %.2f deg, Displacement: %.2f angstrom' %
              (angle, cpv.distance(center1, center2)))

        if visualize:
            center1 = numpy.array(center1, float)
            center2 = numpy.array(center2, float)
            center = (center1 + center2) / 2.0

            if gyradius is not None:
                rg = numpy.array(gyradius(selection1), float)
            else:
                rg = 10.0

            h1 = numpy.cross(center2 - center1, direction)
            h2 = numpy.dot(R33, h1)
            h1 *= rg / cpv.length(h1)
            h2 *= rg / cpv.length(h2)

            for pos in [center1, center2, center1 + h1, center1 + h2]:
                cmd.pseudoatom(mobile_tmp, pos=list(pos), state=1)

            # measurement object for angle and displacement
            name = get_unused_name('measurement')
            cmd.distance(name, *['%s`%d' % (mobile_tmp, i) for i in [1, 2]])
            cmd.angle(name, *['%s`%d' % (mobile_tmp, i) for i in [3, 1, 4]])

            # CGO arrow for axis of rotation
            visualize_orientation(direction, center1, rg, color='blue')

            cmd.delete(mobile_tmp)

    return angle
예제 #33
0
 def test_unpick(self):
     cmd.pseudoatom('m1')
     cmd.edit('m1')
     cmd.unpick()
     self.assertTrue('pk1' not in cmd.get_names('selections'))
예제 #34
0
            #get coordinates from ligand and mol file complex
            pos_halligand = get_pos("halligand")
            pos_halcomplex = get_pos("halcomplex")
            pos_halligand = np.array(pos_halligand)

            #rotate the complex to fit the negative x axis
            cmd.rotate("z", 180, "circ_complex", 0, 0, origin=[0, 0, 0])
            cmd.rotate("x", 180, "circ_complex", 0, 0, origin=[0, 0, 0])
            #do the same for the backbone of the complex
            cmd.rotate("x", 180, "comp_back", 0, 0, origin=[0, 0, 0])
            pos_c2ligand = get_pos("c2ligand")

            #create pseudoatoms of the ligand for calculating rotation angles without moving the actual ligand
            cmd.pseudoatom("pseudo_ciligand",
                           pos=[
                               pos_ciligand[0][0], pos_ciligand[0][1],
                               pos_ciligand[0][2]
                           ])
            cmd.pseudoatom("pseudo_c2ligand",
                           pos=[
                               pos_c2ligand[0][0], pos_c2ligand[0][1],
                               pos_c2ligand[0][2]
                           ])
            cmd.pseudoatom("pseudo_halligand",
                           pos=[
                               pos_halligand[0][0], pos_halligand[0][1],
                               pos_halligand[0][2]
                           ])
            cmd.select("pseudo_ligand", "pseudo_*ligand")

            #ADD PSEUDO BACKBONE
예제 #35
0
def visualize_epistasis(file,
                        obj,
                        max_atom_scale=2,
                        min_atom_scale=0.5,
                        max_line_scale=2,
                        min_line_scale=0.5,
                        pos_color=[1, 0, 0],
                        neg_color=[0, 0, 1],
                        backbone_color=[0.8, 0.8, 0.8]):
    '''
        Inputs
        file - data file of epistatic effects in csv format.
        obj - model object to visualize on. Usually the structure has the same name as the pbd identifier.
        max_atom_scale - maximum scale to size atoms by. Maximum size is assigned to the largest absolute value of epistatic effects.
        min_atom_scale - minimum scale to size atoms by. Minimum size is assigned to the smallest absolute value of epistatic effects.
        max_line_scale - maximum scale to size lines by. Maximum size is assigned to the largest absolute value of epistatic effects.
        min_line_scale - minimum scale to size lines by. Minimum size is assigned to the smallest absolute value of epistatic effects.
        pos_color - color for positive effects.
        neg_color - color for negative effects.
        backbone_color - color for the cartoon representation of the structure.
    '''

    # fetch the current vwd radius
    vdw_space = {'vdw_list': []}
    cmd.iterate_state(-1, "name CA", "vdw_list.append(vdw)", space=vdw_space)
    CA_vdw = vdw_space['vdw_list'][0]

    max_atom_scale = float(max_atom_scale)
    min_atom_scale = float(min_atom_scale)
    max_line_scale = float(max_line_scale)
    min_line_scale = float(min_line_scale)
    # house keeping
    # make sure the file exists
    p, s = read_csv(file)
    if p is None or s is None:
        print('Error: plotting failed, invalid data file.')
        return
    # make sure the chains exists
    chains = cmd.get_chains(obj)

    # program in colors
    cmd.set_color("pos_color", pos_color)
    cmd.set_color("neg_color", neg_color)

    # make sure colors do not smear
    cmd.set("cartoon_discrete_colors", "on")

    # determine order of epistasis, first order is plotted on atoms while higher levels are lines connecting atoms
    atom = [True if len(x) <= 1 else False for x in p]

    # normalize scores
    abs_score = [abs(x) for x in s]
    upper = max(abs_score)
    lower = min(abs_score)
    score_range = upper - lower

    # calculate scaling variables
    atom_scale_range = float(max_atom_scale) - float(min_atom_scale)
    line_scale_range = float(max_line_scale) - float(min_line_scale)
    scales = [(abs_score[i] - lower) / score_range
              for i in range(len(abs_score))]
    # set to atom or line scaling, respectively
    scales = [
        scales[i] * atom_scale_range +
        min_atom_scale if atom[i] else scales[i] * line_scale_range +
        min_line_scale for i in range(len(scales))
    ]

    # do some plotting

    sel_temp = '{obj}//{chain}/{resi}/CA'  # selection template
    for chain in chains:
        sel = sel_temp.format(obj=obj, chain=chain, resi="{resi}")
        for i in range(len(p)):
            scale = scales[i]
            # decide color
            score = s[i]

            color = "pos_color"
            if score < 0:
                color = "neg_color"
            # reset name
            name = ""
            # visualize
            if atom[i]:  # first order
                name = p[i][0]
                cmd.select(name, sel.format(resi=p[i][0]))
                cmd.show("sphere", name)
                cmd.set("sphere_scale", scale / CA_vdw, name)
            elif len(p[i]) == 2:  # second order
                name = "{}_{}".format(p[i][0], p[i][1])
                cmd.distance(name, sel.format(resi=p[i][0]),
                             sel.format(resi=p[i][1]))
                cmd.set("dash_radius", scale, name)
            elif len(p[i]) > 2:  # higher order
                # get all linked atoms and find the centroid
                target_resi = ""

                for j in range(len(p[i])):
                    if j == 0:
                        target_resi = p[i][j]
                        name = p[i][j]
                    else:
                        target_resi = target_resi + "+" + p[i][j]
                        name = name + "_" + p[i][j]
                group_sel = sel.format(resi=target_resi)  # make selection
                coords = []
                myspace = {'coords': coords}
                cmd.iterate_state(-1,
                                  group_sel,
                                  "coords.append([x,y,z])",
                                  space=myspace)  # get list of xyz coordinates
                xyz = centroid(coords)  # calculate the centroid
                # create a pseudoatom at the centroid, and link all atoms to it with lines
                cmd.pseudoatom("pseudoatoms", name=name, chain=chain, pos=xyz)
                for x in p[i]:
                    cmd.distance(name,
                                 "pseudoatoms//{}//{}".format(chain, name),
                                 sel.format(resi=x))
                cmd.set("dash_radius", scale, name)
            # clean up after each set of data
            cmd.color(color, name)
    # final clean up
    cmd.set("dash_gap", 0)
    cmd.hide("everything", "pseudoatoms")
    cmd.hide('labels')
    cmd.set('cartoon_color', backbone_color)
예제 #36
0
    def runSurfStamp_(self):
        import tempfile
        tmpdir = tempfile.TemporaryDirectory()
        tmp_outfile = tmpdir.name + "/tmpout.obj"

        if len(re.sub("[\s]*", "", self.text_outprefix.text())) > 0:
            tmp_outfile = self.text_outprefix.text()

        my_view = cmd.get_view()

        modelname = self.combo_model.currentText()

        output_modelname = re.sub("[^A-Za-z0-9\\.\\-]", "_",
                                  modelname) + "_obj"
        output_modelname = cmd.get_unused_name(output_modelname)

        surf_args = ["java", "-jar", surfstamp_jar]

        surf_args.extend(["-out", tmp_outfile])
        tmpmodel_created = ""

        if self.check_cartoon.isChecked() or (
                not self.check_builtin.isChecked()):
            #Use .obj generated by PyMOL. If this step is skipped, built-in generator is used.
            tmpmodel_created = cmd.get_unused_name("tmpmodel_")
            cmd.load_model(cmd.get_model(modelname), tmpmodel_created)

            cmd.set_view((0.9999905824661255, -0.00367919635027647,
                          -0.002306032460182905, 0.003680833615362644,
                          0.9999929666519165, 0.0007080769282765687,
                          0.0023034177720546722, -0.0007165365968830884,
                          0.999997079372406, 0.0, 0.0, -50.0, 0.0, 0.0, 0.0,
                          40.0, 100.0, -20.0))

            activeobjects = cmd.get_names('public_objects', enabled_only=1)
            for aa in list(activeobjects):
                cmd.disable(aa)
            cmd.enable(tmpmodel_created)
            modelname = tmpmodel_created
            cmd.hide("everything", modelname)

            if self.check_cartoon.isChecked():
                cmd.show("cartoon", modelname)
                surf_args.extend(["-use_ca", "-force", "-sep_block"])
            else:
                cmd.show("surface", modelname)
                surf_args.extend(["-force"])

            cmd.reset()
            cmd.origin(position=[0.0, 0.0, 0.0])
            cmd.center(origin=0)
            unusedname = cmd.get_unused_name("pseudo_")
            unused_selectionname = cmd.get_unused_name("pseudo_sel_")
            cmd.pseudoatom(unusedname, pos=[0, 0, 0])
            cmd.select(unused_selectionname, "/pseudo_//P/PSD`1/PS1")
            cmd.center(selection=unused_selectionname)
            cmd.save(tmpdir.name + "/tmpin.obj", modelname)
            cmd.delete(unusedname)
            cmd.delete(unused_selectionname)

            for aa in list(activeobjects):
                cmd.enable(aa)

            surf_args.extend(["-obj", tmpdir.name + "/tmpin.obj"])
            cmd.hide("everything", modelname)
        if self.check_mmcif.isChecked():
            tmp_infile = tmpdir.name + "/tmpin.cif"
            surf_args.extend(["-mmcif_use_label", "-mmcif", tmp_infile])
            cmd.save(tmp_infile, modelname)
        else:
            tmp_infile = tmpdir.name + "/tmpin.pdb"
            cmd.save(tmp_infile, modelname)
            surf_args.extend(["-pdb", tmp_infile])

        if len(tmpmodel_created) > 0:
            cmd.delete(tmpmodel_created)

        surf_args.extend(["-surface_resolution",
                          str(self.spin_reso.value())])
        surf_args.extend(["-image_size",
                          str(self.spin_imagesize.value())])

        if not self.check_outline.isChecked():
            surf_args.extend(["-nooutline"])
        if self.check_nowater.isChecked():
            surf_args.extend(["-nowater"])
        if self.check_oneletter.isChecked():
            surf_args.extend(["-residue_oneletter"])
        if self.check_nochainname.isChecked():
            surf_args.extend(["-nochainname"])

        if self.check_tile.isChecked():
            if self.check_cartoon.isChecked():
                surf_args.extend(
                    ["-tile", "-font_size",
                     str(self.spin_fontsize.value())])
            else:
                surf_args.extend([
                    "-tile", "-no_sep", "-font_size",
                    str(self.spin_fontsize.value())
                ])

        if self.check_colorall.isChecked():
            surf_args.extend(["-color_missing", "-color_chainbreak"])
        if self.check_ignore_occupancy.isChecked():
            surf_args.extend(["-ignore_occupancy"])

        surf_args.extend(["-quiet", "1"])
        import subprocess
        process = subprocess.run(surf_args,
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.STDOUT)
        #process = subprocess.run(surf_args, stdout=None, stderr=subprocess.PIPE);
        print(process.stdout.decode("utf-8"))
        #os.system(" ".join(surf_args)+" >&2 ");

        self.label_message.setText("Finished.")
        print("Finished.")
        self.text_outprefix.setText("")
        self.button_ok.setEnabled(True)
        self.update()

        if not re.search("\.obj$", tmp_outfile):
            tmp_outfile = tmp_outfile + ".obj"
        cmd.load_callback(pymol_obj_loader.myOBJCallback(tmp_outfile),
                          output_modelname)
        cmd.set_view(my_view)
예제 #37
0
def main(d1, d2):
    ## Make an output folder
    outdir = 'output_dd/' + input_protein + '+' + d1 + '+' + d2 + '/'
    #print (outdir)
    if os.path.isdir(outdir) == False:
        os.system('mkdir ' + outdir)

    domains = d1 + '+' + d2
    for pdb in dd[domains]:
        download_pdb_cif(pdb)
        for coordinates in dd[domains][pdb]:
            #print (pdb, domains, dd[domains][pdb][coordinates])
            chainA = coordinates.split('+')[0].split(':')[0]
            chainA_res = coordinates.split('+')[0].split(':')[1]
            chainB = coordinates.split('+')[1].split(':')[0]
            chainB_res = coordinates.split('+')[1].split(':')[1]
            cmd.load('pdbs/' + pdb.upper() + '.pdb')
            cmd.hide('everything')
            cmd.show('cartoon', 'chain ' + chainA + '+' + chainB)
            cmd.set('cartoon_fancy_helices', 1)
            print(pdb, chainA, chainA_res, chainB, chainB_res)
            try:
                x = cmd.centerofmass('chain ' + chainA)
                print('Success chainA')
                cmd.pseudoatom('chainA_label', pos=x)
                global nameA
                nameA = id_to_name[d1] + '(' + d1 + ')'
                cmd.label('chainA_label', 'nameA')
            except:
                print('Failed chainA')
            try:
                x = cmd.centerofmass('chain ' + chainB)
                print('Success chainB')
                cmd.pseudoatom('chainB_label', pos=x)
                global nameB
                nameB = id_to_name[d2] + '(' + d2 + ')'
                cmd.label('chainB_label', 'nameB')
                x = cmd.centerofmass('chain ' + chainA + '+' + chainB)
                cmd.origin(position=x)
                cmd.center('origin')
            except:
                print('Failed chainB')
            cmd.set('label_size', 7.5)
            cmd.set('cartoon_fancy_helices', 1)
            cmd.color('red', 'chain ' + chainA)
            cmd.color('orange', 'chain ' + chainB)
            for row in dd[domains][pdb][coordinates]:
                res1 = row[2]
                res2 = row[3]
                #cmd.distance('chain '+chainA+' and i. '+res1+' and n. CB', 'chain '+chainB+' and i. '+res2+' and n. CB')
                cutoff = 6.5
                m = cmd.distance(
                    'dist',
                    'chain ' + chainA + ' and i. ' + res1 + ' and n. CB',
                    'chain ' + chainB + ' and i. ' + res2 + ' and n. CB',
                    cutoff, 0)
                #m = cmd.get_distance(atom1='chain '+chainA+' and i. '+res1+' and n. CB',atom2='chain '+chainB+' and i. '+res2+' and n. CB',state=0)
                #print (pdb, m, chainA, res1, chainB, res2)
                cmd.select('res1', 'chain ' + chainA + ' and resi ' + res1)
                cmd.select('res2', 'chain ' + chainB + ' and resi ' + res2)

                if float(m) != 0.0:
                    cmd.show('sticks', 'res1')
                    cmd.show('sticks', 'res2')
                    cmd.color('cyan', 'res1')
                    cmd.color('yellow', 'res2')

            cmd.save(outdir + pdb + '_' + input_protein + '_' + d1 + '_' +
                     d2 + '_' + coordinates.replace(':', '_').replace(
                         '+', '_').replace('-', '_') + '.pse')
            cmd.save(outdir + pdb + '_' + input_protein + '_' + d1 + '_' +
                     d2 + '_' + coordinates.replace(':', '_').replace(
                         '+', '_').replace('-', '_') + '.pdb')
            cmd.delete('all')
        #break
    '''
예제 #38
0
import math
from pymol import cmd, finish_launching, plugins
from pymol.cgo import *

finish_launching()

cmd.load("ligands.mol2", "ligands")
ring_point_0 = [COLOR, 0.33, 1.0, 0.0] + [ALPHA, 0.8] + [
    SPHERE, float(18.0),
    float(13.0), float(112.5),
    float(2.0)
]

cmd.load_cgo(ring_point_0, "ring_point_0_obj", 1)
cmd.pseudoatom(object="ring_point_0_score",
               pos=(18.0, 13.0, 112.5),
               color=(1, 1, 1),
               label=21.6)

cmd.group("ring_0", members="ring_point_0_obj")
cmd.group("ring_0", members="ring_point_0_score")
ring_point_1 = [COLOR, 0.33, 1.0, 0.0] + [ALPHA, 0.8] + [
    SPHERE, float(18.5),
    float(15.0), float(109.0),
    float(2.0)
]

cmd.load_cgo(ring_point_1, "ring_point_1_obj", 1)
cmd.pseudoatom(object="ring_point_1_score",
               pos=(18.5, 15.0, 109.0),
               color=(1, 1, 1),
               label=14.0)
예제 #39
0
 def test_set_title(self):
     text = 'foo'
     cmd.pseudoatom('m1')
     cmd.set_title('m1', 1, text)
     self.assertEqual(cmd.get_title('m1', 1), text)
예제 #40
0
 def test_wildcards(self):
     cmd.pseudoatom('foo')
     cmd.pseudoatom('foobar')
     cmd.pseudoatom('foo_bar')
     cmd.pseudoatom('foo_bar_bla')
     cmd.pseudoatom('bar')
     cmd.pseudoatom('_bar')
     self.assertEqual(1, cmd.count_atoms('foo'))
     self.assertEqual(1, cmd.count_atoms('*foo'))
     self.assertEqual(4, cmd.count_atoms('*foo*'))
     self.assertEqual(1, cmd.count_atoms('bar'))
     self.assertEqual(4, cmd.count_atoms('*bar'))
     self.assertEqual(5, cmd.count_atoms('*bar*'))
     self.assertEqual(2, cmd.count_atoms('foo*bar'))
     self.assertEqual(3, cmd.count_atoms('*foo*bar*'))
     self.assertEqual(1, cmd.count_atoms('_*'))
     self.assertEqual(6, cmd.count_atoms('*'))
     self.assertEqual(6, cmd.count_atoms('*'))
     cmd.alter('*', 'name = "ABCD"')
     cmd.alter('foo', 'name = "ABED"')
     cmd.alter('bar', 'name = "ABEC"')
     self.assertEqual(6, cmd.count_atoms('name A*'))
     self.assertEqual(2, cmd.count_atoms('name ABE*'))
     self.assertEqual(1, cmd.count_atoms('name ABED*'))
     self.assertEqual(1, cmd.count_atoms('name AB*C'))
     self.assertEqual(5, cmd.count_atoms('name AB*C*'))
     self.assertEqual(5, cmd.count_atoms('name AB*D'))
     self.assertEqual(5, cmd.count_atoms('name AB*D*'))
예제 #41
0
def prune_grid(rna, score_file, outname, quantile=0.99, sasa_cutoff=20.0):
    # make sure all atoms within an object occlude one another
    cmd.flag("ignore", "none")

    # use solvent-accessible surface with high sampling density
    cmd.set('dot_solvent', 1)
    cmd.set('dot_density', 3)
    cmd.set('solvent_radius', 2.0)

    k = 1
    df = pd.read_csv(score_file, header=0, sep=",")
    means = df[['pred_MLP', 'pred_XGB', 'pred_RF', 'pred_LR',
                'pred_Extra']].apply(np.mean, 'columns')
    cutoff = np.quantile(a=means, q=quantile)

    for pred, pos in zip(
            df[['pred_MLP', 'pred_XGB', 'pred_RF', 'pred_LR',
                'pred_Extra']].values, df[['x', 'y', 'z']].values):
        if np.mean(pred) > cutoff:
            # create tmp complex
            cmd.pseudoatom("tmpPoint3",
                           hetatm=1,
                           name="C",
                           resn="UNK",
                           pos=[pos[0], pos[1], pos[2]])
            cmd.create("complextmp", "%s tmpPoint3" % rna)
            sasa = cmd.get_area('resn UNK and not polymer and complextmp')
            cmd.delete("complextmp tmpPoint3")
            # remove really highly exposed points
            if sasa < sasa_cutoff:
                cmd.pseudoatom("tmpPoint",
                               hetatm=1,
                               b=np.mean(pred),
                               q=sasa,
                               name="C",
                               resn="UNK",
                               resi=k,
                               chain="ZZ",
                               pos=[pos[0], pos[1], pos[2]])
                print(pred, pos, np.mean(pred), cutoff, sasa)
                k += 1
    # write out grid file
    coor = "%s_pruned_grid.xyz" % (outname)
    xyz = cmd.get_coords('tmpPoint', 1)
    df = pd.DataFrame.from_records(xyz)
    df.insert(0, "element", "C")
    df.to_csv(coor, index=False, header=False, sep=" ")

    # write out complex
    cmd.create("complex", "%s tmpPoint" % rna)
    coor = "%s_pruned_grid.pdb" % (outname)
    cmd.save(coor, "complex")
    coor = "cavity_pruned_grid.sd"
    cmd.save(coor, "tmpPoint")

    # remove isolated
    remove_isolated()

    # write out grid file
    coor = "%s_pruned_grid_clusters.xyz" % (outname)
    xyz = cmd.get_coords('tmpPoint', 1)
    df = pd.DataFrame.from_records(xyz)
    df.insert(0, "element", "C")
    df.to_csv(coor, index=False, header=False, sep=" ")

    # write out complex
    cmd.create("complex", "%s tmpPoint" % rna)
    coor = "%s_pruned_grid_clusters.pdb" % (outname)
    cmd.save(coor, "complex")
    coor = "cavity_pruned_grid.sd"
    cmd.save(coor, "tmpPoint")
예제 #42
0
cmd.isosurface(name="surface_acceptor_hotspot",
               map="acceptor_hotspot",
               level="5")

cmd.color("red", "surface_acceptor_hotspot")
cmd.set("transparency", 0.2, "surface_acceptor_hotspot")
cmd.group("hotspot", members="apolar_hotspot")
cmd.group("hotspot", members="surface_apolar_hotspot")
cmd.group("hotspot", members="donor_hotspot")
cmd.group("hotspot", members="surface_donor_hotspot")
cmd.group("hotspot", members="acceptor_hotspot")
cmd.group("hotspot", members="surface_acceptor_hotspot")
cmd.group("hotspot", members="buriedness_hotspot")
cmd.group("hotspot", members="surface_buriedness_hotspot")
cmd.pseudoatom(object="PS_apolar_hotspot_0",
               pos=(24.5, 1.0, 19.5),
               color=(1, 1, 1),
               label=12.8)

cmd.pseudoatom(object="PS_apolar_hotspot_1",
               pos=(23.0, -6.0, 15.0),
               color=(1, 1, 1),
               label=16.5)

cmd.pseudoatom(object="PS_apolar_hotspot_2",
               pos=(21.0, -1.0, 16.0),
               color=(1, 1, 1),
               label=6.4)

cmd.pseudoatom(object="PS_apolar_hotspot_3",
               pos=(18.5, 1.0, 20.0),
               color=(1, 1, 1),
예제 #43
0
import math
from pymol import cmd, finish_launching, plugins
from pymol.cgo import *

finish_launching()

cmd.load("ligands.mol2", "ligands")
ring_point_0 = [COLOR, 0.33, 1.0, 0.0] + [ALPHA, 0.8] + [
    SPHERE, float(27.5),
    float(5.0), float(64.5),
    float(2.0)
]

cmd.load_cgo(ring_point_0, "ring_point_0_obj", 1)
cmd.pseudoatom(object="ring_point_0_score",
               pos=(27.5, 5.0, 64.5),
               color=(1, 1, 1),
               label=191.4)

cmd.group("ring_0", members="ring_point_0_obj")
cmd.group("ring_0", members="ring_point_0_score")
acceptor_projected_point_1 = [COLOR, 1.0, 0.0, 0.0] + [ALPHA, 0.8] + [
    SPHERE, float(28.5),
    float(4.5), float(65.5),
    float(1)
]

cmd.load_cgo(acceptor_projected_point_1, "acceptor_projected_point_1_obj", 1)
cmd.pseudoatom(object="acceptor_projected_point_1_score",
               pos=(28.5, 4.5, 65.5),
               color=(1, 1, 1),
               label=190.6)
예제 #44
0
def elbow_angle(obj, light='L', heavy='H', limit_l=107, limit_h=113, draw=0):
    """

DESCRIPTION

    Calculates the integer elbow angle of an antibody Fab complex and
    optionally draws a graphical representation of the vectors used to
    determine the angle.

ARGUMENTS

    obj = string: object

    light/heavy = strings: chain ID of light and heavy chains, respectively

    limit_l/limit_h = integers: residue numbers of the last residue in the
    light and heavy chain variable domains, respectively

    draw = boolean: Choose whether or not to draw the angle visualization

REQUIRES: com.py, transformations.py, numpy (see above)


    """

    # store current view
    orig_view = cmd.get_view()

    limit_l = int(limit_l)
    limit_h = int(limit_h)
    draw = int(draw)

    # for temp object names
    tmp_prefix = "tmp_elbow_"

    prefix = tmp_prefix + obj + '_'

    # names
    vl = prefix + 'VL'
    vh = prefix + 'VH'
    cl = prefix + 'CL'
    ch = prefix + 'CH'

    # selections
    vl_sel = 'polymer and %s and chain %s and resi 1-%i' % (obj, light, limit_l)
    vh_sel = 'polymer and %s and chain %s and resi 1-%i' % (obj, heavy, limit_h)
    cl_sel = 'polymer and %s and chain %s and not resi 1-%i' % (obj, light, limit_l)
    ch_sel = 'polymer and %s and chain %s and not resi 1-%i' % (obj, heavy, limit_h)
    v_sel = '((' + vl_sel + ') or (' + vh_sel + '))'
    c_sel = '((' + cl_sel + ') or (' + ch_sel + '))'

    # create temp objects
    cmd.create(vl, vl_sel)
    cmd.create(vh, vh_sel)
    cmd.create(cl, cl_sel)
    cmd.create(ch, ch_sel)

    # superimpose vl onto vh, calculate axis and angle
    Rv = calc_super_matrix(vl, vh)
    angle_v, direction_v, point_v = transformations.rotation_from_matrix(Rv)

    # superimpose cl onto ch, calculate axis and angle
    Rc = calc_super_matrix(cl, ch)
    angle_c, direction_c, point_c = transformations.rotation_from_matrix(Rc)

    # delete temporary objects
    cmd.delete(vl)
    cmd.delete(vh)
    cmd.delete(cl)
    cmd.delete(ch)

    # if dot product is positive, angle is acute
    if (numpy.dot(direction_v, direction_c) > 0):
        direction_c = direction_c * -1   # ensure angle is > 90 (need to standardize this)

        # TODO: make both directions point away from the elbow axis.

    elbow = int(numpy.degrees(numpy.arccos(numpy.dot(direction_v, direction_c))))
    # while (elbow < 90):
    # elbow = 180 - elbow   # limit to physically reasonable range

    # compare the direction_v and direction_c axes to the vector defined by
    # the C-alpha atoms of limit_l and limit_h of the original fab
    hinge_l_sel = "%s//%s/%s/CA" % (obj, light, limit_l)
    hinge_h_sel = "%s//%s/%s/CA" % (obj, heavy, limit_h)
    hinge_l = cmd.get_atom_coords(hinge_l_sel)
    hinge_h = cmd.get_atom_coords(hinge_h_sel)
    hinge_vec = numpy.array(hinge_h) - numpy.array(hinge_l)

    test = numpy.dot(hinge_vec, numpy.cross(direction_v, direction_c))
    if (test > 0):
        elbow = 360 - elbow

    print("    Elbow angle: %i degrees" % elbow)

    if (draw == 1):
        # there is probably a more elegant way to do this, but
        # it works so I'm not going to mess with it for now

        pre = obj + '_elbow_'

        # draw hinge vector
        cmd.pseudoatom(pre + "hinge_l", pos=hinge_l)
        cmd.pseudoatom(pre + "hinge_h", pos=hinge_h)
        cmd.distance(pre + "hinge_vec", pre + "hinge_l", pre + "hinge_h")
        cmd.set("dash_gap", 0)

        # draw the variable domain axis
        com_v = COM(v_sel)
        start_v = [a - 10 * b for a, b in zip(com_v, direction_v)]
        end_v = [a + 10 * b for a, b in zip(com_v, direction_v)]
        cmd.pseudoatom(pre + "start_v", pos=start_v)
        cmd.pseudoatom(pre + "end_v", pos=end_v)
        cmd.distance(pre + "v_vec", pre + "start_v", pre + "end_v")

        # draw the constant domain axis
        com_c = COM(c_sel)
        start_c = [a - 10 * b for a, b in zip(com_c, direction_c)]
        end_c = [a + 10 * b for a, b in zip(com_c, direction_c)]
        cmd.pseudoatom(pre + "start_c", pos=start_c)
        cmd.pseudoatom(pre + "end_c", pos=end_c)
        cmd.distance(pre + "c_vec", pre + "start_c", pre + "end_c")

        # customize appearance
        cmd.hide("labels", pre + "hinge_vec")
        cmd.hide("labels", pre + "v_vec")
        cmd.hide("labels", pre + "c_vec")
        cmd.color("green", pre + "hinge_l")
        cmd.color("red", pre + "hinge_h")
        cmd.color("black", pre + "hinge_vec")
        cmd.color("black", pre + "start_v")
        cmd.color("black", pre + "end_v")
        cmd.color("black", pre + "v_vec")
        cmd.color("black", pre + "start_c")
        cmd.color("black", pre + "end_c")
        cmd.color("black", pre + "c_vec")
        # draw spheres
        cmd.show("spheres", pre + "hinge_l or " + pre + "hinge_h")
        cmd.show("spheres", pre + "start_v or " + pre + "start_c")
        cmd.show("spheres", pre + "end_v or " + pre + "end_c")
        cmd.set("sphere_scale", 2)
        cmd.set("dash_gap", 0, pre + "hinge_vec")
        cmd.set("dash_width", 5)
        cmd.set("dash_radius", 0.3)

        # group drawing objects
        cmd.group(pre, pre + "*")

    # restore original view
    cmd.set_view(orig_view)

    return 0
예제 #45
0
    float(0.5)
]

cmd.load_cgo(donor_projected_point_0, "donor_projected_point_0_obj", 1)
donor_projected_projection_0 = [COLOR, 0.6, 0.6, 1.0] + [ALPHA, 1.0] + [
    SPHERE,
    float(6.60241953313495),
    float(5.401737482286244),
    float(5.986274419667637),
    float(0.5)
]

cmd.load_cgo(donor_projected_projection_0, "donor_projected_projection_0_obj",
             1)
cmd.pseudoatom(object="donor_projected_line_0pa1",
               pos=(4.8497557616643245, 3.893318200000001, 4.407401095742814),
               color=(1, 1, 1))

cmd.pseudoatom(object="donor_projected_line_0pa2",
               pos=(6.60241953313495, 5.401737482286244, 5.986274419667637),
               color=(1, 1, 1))

cmd.distance(name="donor_projected_line_0",
             selection1="donor_projected_line_0pa1",
             selection2="donor_projected_line_0pa2",
             width=0.5,
             gap=0.2,
             label=0,
             state=1)

cmd.set("dash_color", (0.6, 0.6, 1.0), selection="donor_projected_line_0")
예제 #46
0
def PiPi(pdb_file, lig_name, centroid_distance, dih_parallel, dih_tshape):
    # Get ligand residue and print its name.
    ligAtomList = []
    ligAtomIdList = []
    mol = pybel.readfile('pdb', pdb_file).next()
    print "A total of %s residues" % mol.OBMol.NumResidues()
    lig = None
    for res in ob.OBResidueIter(mol.OBMol):
        # print res.GetName()
        if res.GetName() == lig_name:
            lig = res
            print "Ligand residue name is: ", lig.GetName()
            break
    if not lig:
        print "No ligand residue %s found, please confirm." % lig_name
        return 0
    else:
        for atom in ob.OBResidueAtomIter(lig):
            # print atom.GetIdx()
            ligAtomList.append(atom)
            ligAtomIdList.append(atom.GetIdx())

    # Set ring_id
    i = 0
    for ring in mol.sssr:
        ring.ring_id = i
        i += 1
        # print ring.ring_id

    # Determine which rings are from ligand.
    ligRingList = []
    ligAroRingList = []
    ligRingIdList = []
    recRingList = []
    recAroRingList = []
    for ring in mol.sssr:
        for atom in ligAtomList:
            if ring.IsMember(atom):
                if ring not in ligRingList:
                    ligRingList.append(ring)
                    ligRingIdList.append(ring.ring_id)
                    print "ligand ring_ID: ", ring.ring_id,
                    if ring.IsAromatic():
                        print "Aromatic"
                        ligAroRingList.append(ring)
                    else:
                        print "Saturated"
    for ring in mol.sssr:
        if ring.ring_id not in ligRingIdList:
            recRingList.append(ring)
            if ring.IsAromatic():
                recAroRingList.append(ring)
    print "\nReceptor has ", len(recRingList), " rings,",
    print " has ", len(recAroRingList), " aromatic rings."

    # Find and show the rings
    ligRingCenter = ob.vector3()
    recRingCenter = ob.vector3()
    ligNorm1 = ob.vector3()
    ligNorm2 = ob.vector3()
    recNorm1 = ob.vector3()
    recNorm2 = ob.vector3()
    coord1 = []
    coord2 = []
    pair = []  # Store the names of the objects
    pairList = []
    psObjectList = []
    i = 0
    for ligRing in ligAroRingList:
        ligRing.findCenterAndNormal(ligRingCenter, ligNorm1, ligNorm2)
        coord1 = [
            ligRingCenter.GetX(),
            ligRingCenter.GetY(),
            ligRingCenter.GetZ()
        ]
        # Create a pseudoatom for the centroid of each ring in the ligand
        objectName1 = 'psCenter%.2d' % i
        i += 1
        cmd.pseudoatom(object=objectName1, pos=coord1)
        psObjectList.append(objectName1)
        for recRing in recAroRingList:
            recRing.findCenterAndNormal(recRingCenter, recNorm1, recNorm2)
            dist = ligRingCenter.distSq(recRingCenter)
            angle = vecAngle(ligNorm1, recNorm1)
            if (dist**0.5 < centroid_distance and
                (angle < dih_parallel or angle > dih_tshape)):  # the criteria
                coord2 = [
                    recRingCenter.GetX(),
                    recRingCenter.GetY(),
                    recRingCenter.GetZ()
                ]
                # Create pseudoatom for each lig ring center
                objectName2 = 'psCenter%.2d' % i
                i += 1
                cmd.pseudoatom(object=objectName2, pos=coord2)
                psObjectList.append(objectName2)
                # pair=[coord1,coord2]
                pair = [objectName1, objectName2]
                # print "%.4f,%.4f,%.4f" % (pair[1][0],pair[1][1],pair[1][2])
                pairList.append(pair)
                cmd.distance('dist-' + objectName1 + '-' + objectName2,
                             pair[0], pair[1])
                print objectName1, objectName2, " angle is : %.2f" % angle
예제 #47
0
from os.path import join
import tempfile
import zipfile
import math
from pymol import cmd, finish_launching
from pymol.cgo import *

finish_launching()

cmd.pseudoatom(object="myline1pa1", pos=(0, 0, 0), color=(1, 1, 1))

cmd.pseudoatom(object="myline1pa2", pos=(1, 1, 1), color=(1, 1, 1))

cmd.distance(name="myline1",
             selection1="myline1pa1",
             selection2="myline1pa2",
             width=0.5,
             gap=0.2,
             label=0,
             state=1)

cmd.set("dash_color",
        (0.9411764705882353, 0.20392156862745098, 0.20392156862745098),
        selection="myline1")
cmd.set("dash_width", 10)
cmd.delete("myline1pa1")
cmd.delete("myline1pa2")
cmd.pseudoatom(object="mypseudoatom1",
               pos=(0, 0, 0),
               color=(0.9411764705882353, 0.20392156862745098,
                      0.20392156862745098, 0.5))
예제 #48
0
# create N particle system [x,y,z,r,vx,vy,vz]

particle = []
for resi in range(0, particle_count):
    particle.append([resi] +
                    map(lambda x: (random() - 0.5) * box_size / 2, [0] *
                        3) +  # x,y,z
                    [random() + 0.5] +  # r
                    map(lambda x: (random() - 0.5), [0] * 3)  # vx,vy,vz
                    )

# create cloud object

for part in particle:
    cmd.pseudoatom("cloud", resi=part[0], pos=part[1:4], vdw=part[4])

# draw spheres efficiently
cmd.show_as("spheres")
cmd.unset("cull_spheres")

# position the camera

cmd.zoom()
cmd.zoom("center", box_size)

# let there be color

cmd.spectrum()

# this is the main loop
예제 #49
0
 def testIterateLocalVars(self, func):
     cmd.pseudoatom('m1')
     stored.v = None
     func('all', 'foobar = model;stored.v = foobar')
     self.assertEqual(stored.v, 'm1')
예제 #50
0
cmd.color('_colorm', 'sm')

#cmd.load('dif_B1.cube')
#cmd.isosurface('spp', 'dif_B1', 0.00008)
#cmd.color('blue', 'spp')
#cmd.isosurface('smp', 'dif_B1', -0.00008)
#cmd.color('red', 'smp')

#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, 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' )
#
예제 #51
0
 def test_set_name(self):
     cmd.pseudoatom('m1')
     cmd.set_name('m1', 'm2')
     self.assertEqual(['m2'], cmd.get_names())
예제 #52
0
print("Translation vector: ")
print(translation_vector)
print([translation_vector[0][0],translation_vector[0][1],translation_vector[0][2]])

#translate molecule from mol file to 0,0,0
cmd.translate([translation_vector[0][0],translation_vector[0][1],translation_vector[0][2]],"circ_complex",-1,0)

#get coordinates from ligand and mol file complex
pos_halligand = []
pos_halcomplex = []
cmd.iterate_state(1, 'halligand', 'pos_halligand.append((x,y,z))')
cmd.iterate_state(1, 'halcomplex', 'pos_halcomplex.append((x,y,z))')
pos_halligand = np.array(pos_halligand)

#add pseudoatom on x axis to measure angle for rotation around y axis
cmd.pseudoatom("x-1",pos=[-1,0,0])
#measure angle for molfile rotation
angle = cmd.get_angle(atom1="cicomplex",atom2="halcomplex",atom3="x-1")
#rotate mol file
cmd.rotate("z",180,"circ_complex",0,0,origin=[0,0,0])

#cmd.pseudoatom("e",pos=[-2,0,z_temp])


print(angle)
print(pos_halligand[0][2])
cmd.pseudoatom("z1",pos=[0,0,1])


cmd.pseudoatom("pseudo_ciligand",pos=[pos_ciligand[0][0],pos_ciligand[0][1],pos_ciligand[0][2]])
cmd.pseudoatom("pseudo_c2ligand",pos=[pos_c2ligand[0][0],pos_c2ligand[0][1],pos_c2ligand[0][2]])
예제 #53
0
cmd.isosurface(name="surface_acceptor_hotspot",
               map="acceptor_hotspot",
               level="5")

cmd.color("red", "surface_acceptor_hotspot")
cmd.set("transparency", 0.2, "surface_acceptor_hotspot")
cmd.group("hotspot", members="apolar_hotspot")
cmd.group("hotspot", members="surface_apolar_hotspot")
cmd.group("hotspot", members="donor_hotspot")
cmd.group("hotspot", members="surface_donor_hotspot")
cmd.group("hotspot", members="acceptor_hotspot")
cmd.group("hotspot", members="surface_acceptor_hotspot")
cmd.group("hotspot", members="buriedness_hotspot")
cmd.group("hotspot", members="surface_buriedness_hotspot")
cmd.pseudoatom(object="PS_apolar_hotspot_0",
               pos=(25.0, 7.5, 16.5),
               color=(1, 1, 1),
               label=11.5)

cmd.pseudoatom(object="PS_apolar_hotspot_1",
               pos=(25.0, 6.5, 14.0),
               color=(1, 1, 1),
               label=10.0)

cmd.pseudoatom(object="PS_apolar_hotspot_2",
               pos=(22.0, 5.5, 11.5),
               color=(1, 1, 1),
               label=18.1)

cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_0")
cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_0")
cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_1")
예제 #54
0
        def hs_gsimplifier(*args, **kwargs):

            radius = form.radius1.value()
            color = kwargs.get("color", "red")

            selections = args

            for selection in selections:
                if not is_sele(selection):
                    raise RuntimeError(
                        "Selection \"{}\" does not exists.".format(selection))

            states = cmd.count_states(selection=selections[0])
            hs_values = []
            all_coords = []
            for state in range(1, states + 1):
                stored.info = []

                for selection in selections:
                    cmd.iterate_state(
                        state, selection,
                        "stored.info.append([ID, partial_charge, (x,y,z), \"{}\"])"
                        .format(selection))
                for line in stored.info:
                    partial_charge = line[1]
                    coord = line[2]
                    hs_values.append(partial_charge)
                    all_coords.append(coord)

                hs = np.array(copy.copy(stored.info))

                n = dict()
                for h in hs:
                    dists = np.linalg.norm(np.array(h[2]) - list(zip(*hs))[2],
                                           axis=1)
                    # Convert to dict due to same hotspots IDs
                    n[(h[0], h[3])] = hs[dists <= radius]

                exc_indexes = []
                hs_id = free_hotspot_id(hs, exc_indexes=exc_indexes)

                while hs_id is not None:
                    excluded, coords = find_all_coords(n,
                                                       hs_id,
                                                       exc_indexes=[],
                                                       coords=[])
                    exc_indexes.extend(excluded)
                    if form.geometric.isChecked():
                        middle_point = group_center(np.array(coords))
                        cmd.pseudoatom(object="simply",
                                       color=color,
                                       pos=middle_point,
                                       state=state)
                    else:
                        middle_points = find_center(hs_values,
                                                    all_coords,
                                                    nbr=len(exc_indexes))
                        for point in middle_points:
                            cmd.pseudoatom(object="simply",
                                           color=color,
                                           pos=point,
                                           state=state)

                    hs_id = free_hotspot_id(hs, exc_indexes=exc_indexes)

                cmd.show(representation="spheres", selection="simply")
예제 #55
0
from os.path import join
import tempfile
import zipfile
import math
from pymol import cmd, finish_launching
from pymol.cgo import *

finish_launching()

cmd.pseudoatom(object="mylinepa1", pos=(1, 1, 1), color=(1, 1, 1))

cmd.pseudoatom(object="mylinepa2", pos=(2, 2, 2), color=(1, 1, 1))

cmd.distance(name="myline",
             selection1="mylinepa1",
             selection2="mylinepa2",
             width=0.5,
             gap=0.2,
             label=0,
             state=1)

cmd.set("dash_color",
        (0.9411764705882353, 0.20392156862745098, 0.20392156862745098),
        selection="myline")
cmd.set("dash_width", 4)
cmd.delete("mylinepa1")
cmd.delete("mylinepa2")
cmd.pseudoatom(object="myline2pa1", pos=(1, 1, 1), color=(1, 1, 1))

cmd.pseudoatom(object="myline2pa2", pos=(0, 0, 0), color=(1, 1, 1))
예제 #56
0
 def show_cationpi(self):
     """Visualize cation-pi interactions."""
     for i, p in enumerate(self.plcomplex.pication):
         cmd.pseudoatom('ps-picat-1-%i' % i, pos=p.ring_center)
         cmd.pseudoatom('ps-picat-2-%i' % i, pos=p.charge_center)
         if p.protcharged:
             cmd.pseudoatom('Chargecenter-P', pos=p.charge_center)
             cmd.pseudoatom('Centroids-L', pos=p.ring_center)
             pilig_ids = '+'.join(map(str, p.ring_atoms))
             cmd.select('PiCatRing-L', 'PiCatRing-L or (id %s & %s)' % (pilig_ids, self.ligname))
             for a in p.charge_atoms:
                 cmd.select('PosCharge-P', 'PosCharge-P or (id %i & %s)' % (a, self.protname))
         else:
             cmd.pseudoatom('Chargecenter-L', pos=p.charge_center)
             cmd.pseudoatom('Centroids-P', pos=p.ring_center)
             pires_ids = '+'.join(map(str, p.ring_atoms))
             cmd.select('PiCatRing-P', 'PiCatRing-P or (id %s & %s)' % (pires_ids, self.protname))
             for a in p.charge_atoms:
                 cmd.select('PosCharge-L', 'PosCharge-L or (id %i & %s)' % (a, self.ligname))
         cmd.distance('PiCation', 'ps-picat-1-%i' % i, 'ps-picat-2-%i' % i)
     if self.object_exists('PiCation'):
         cmd.set('dash_color', 'orange', 'PiCation')
         cmd.set('dash_gap', 0.3, 'PiCation')
         cmd.set('dash_length', 0.6, 'PiCation')
예제 #57
0
cmd.isosurface(name="surface_acceptor_hotspot",
               map="acceptor_hotspot",
               level="5")

cmd.color("red", "surface_acceptor_hotspot")
cmd.set("transparency", 0.2, "surface_acceptor_hotspot")
cmd.group("hotspot", members="apolar_hotspot")
cmd.group("hotspot", members="surface_apolar_hotspot")
cmd.group("hotspot", members="donor_hotspot")
cmd.group("hotspot", members="surface_donor_hotspot")
cmd.group("hotspot", members="acceptor_hotspot")
cmd.group("hotspot", members="surface_acceptor_hotspot")
cmd.group("hotspot", members="buriedness_hotspot")
cmd.group("hotspot", members="surface_buriedness_hotspot")
cmd.pseudoatom(object="PS_apolar_hotspot_0",
               pos=(31.0, 8.5, 65.5),
               color=(1, 1, 1),
               label=115.1)

cmd.pseudoatom(object="PS_apolar_hotspot_1",
               pos=(27.5, 5.0, 64.5),
               color=(1, 1, 1),
               label=191.4)

cmd.pseudoatom(object="PS_apolar_hotspot_2",
               pos=(25.0, 7.0, 61.5),
               color=(1, 1, 1),
               label=62.2)

cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_0")
cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_0")
cmd.group("label_apolar_hotspot", members="PS_apolar_hotspot_1")
예제 #58
0
def angle_between_helices(selection1,
                          selection2,
                          method='helix',
                          state1=STATE,
                          state2=STATE,
                          visualize=1,
                          quiet=1):
    '''
DESCRIPTION

    Calculates the angle between two helices

USAGE

    angle_between_helices selection1, selection2 [, method [, visualize]]

ARGUMENTS

    selection1 = string: atom selection of first helix

    selection2 = string: atom selection of second helix

    method = string: function to calculate orientation {default: helix_orientation}

    visualize = 0 or 1: show fitted vector as arrow {default: 1}

EXAMPLE

    fetch 2x19, bsync=0
    select hel1, /2x19//B/23-36/
    select hel2, /2x19//B/40-54/
    angle_between_helices hel1, hel2
    angle_between_helices hel1, hel2, cafit

SEE ALSO

    helix_orientation, loop_orientation, cafit_orientation, angle_between_domains
    '''
    import math

    state1, state2 = int(state1), int(state2)
    visualize, quiet = int(visualize), int(quiet)

    try:
        orientation = globals()[methods_sc[str(method)]]
    except KeyError:
        print('no such method:', method)
        raise CmdException

    if not int(quiet):
        print(' Using method:', orientation.__name__)

    cen1, dir1 = orientation(selection1, state1, visualize, quiet=1)
    cen2, dir2 = orientation(selection2, state2, visualize, quiet=1)

    angle = cpv.get_angle(dir1, dir2)
    angle = math.degrees(angle)

    if not quiet:
        print(' Angle: %.2f deg' % (angle))

    if visualize:
        # measurement object for angle
        center = cpv.scale(cpv.add(cen1, cen2), 0.5)
        tmp = get_unused_name('_')
        for pos in [
                center,
                cpv.add(center, cpv.scale(dir1, 5.0)),
                cpv.add(center, cpv.scale(dir2, 5.0))
        ]:
            cmd.pseudoatom(tmp, pos=list(pos), state=1)
        name = get_unused_name('angle')
        cmd.angle(name, *[(tmp, i) for i in [2, 1, 3]])
        cmd.delete(tmp)

        cmd.zoom('(%s) or (%s)' % (selection1, selection2), 2,
                 state1 if state1 == state2 else 0)

    return angle
예제 #59
0
import zipfile
import math
from pymol import cmd, finish_launching, plugins
from pymol.cgo import *

finish_launching()

cmd.load("ligands.mol2", "ligands")
cmd.load("protein.mol2", "protein")
donor_projected_point_0 = [COLOR, 0.0, 0.0, 1.0] +  [ALPHA, 1.0] + [SPHERE, float(27.308), float(3.547), float(65.078), float(0.5)]

cmd.load_cgo(donor_projected_point_0, "donor_projected_point_0_obj", 1)
donor_projected_projection_0 = [COLOR, 0.6, 0.6, 1.0] +  [ALPHA, 1.0] + [SPHERE, float(26.877), float(0.821), float(65.99), float(0.5)]

cmd.load_cgo(donor_projected_projection_0, "donor_projected_projection_0_obj", 1)
cmd.pseudoatom(object="donor_projected_line_0pa1", pos=(27.308, 3.547, 65.078), color=(1, 1, 1))

cmd.pseudoatom(object="donor_projected_line_0pa2", pos=(26.877, 0.821, 65.99), color=(1, 1, 1))

cmd.distance(name="donor_projected_line_0", selection1="donor_projected_line_0pa1", selection2="donor_projected_line_0pa2", width=0.5, gap=0.2, label=0, state=1)

cmd.set("dash_color", (0.6, 0.6, 1.0), selection="donor_projected_line_0")
cmd.set("dash_width", 4.0)
cmd.delete("donor_projected_line_0pa1")
cmd.delete("donor_projected_line_0pa2")
cmd.group("donor_projected_0", members="donor_projected_point_0_obj")
cmd.group("donor_projected_0", members="donor_projected_projection_0")
cmd.group("donor_projected_0", members="donor_projected_line_0")
cmd.select("sele", "resi 81")
cmd.show("sticks", "sele")
acceptor_projected_point_1 = [COLOR, 1.0, 0.0, 0.0] +  [ALPHA, 1.0] + [SPHERE, float(28.364), float(4.137), float(65.698), float(0.5)]
예제 #60
0
 def testGetPdbstr(self):
     cmd.pseudoatom()
     lines = cmd.get_pdbstr().splitlines()
     self.assertTrue(lines[0].startswith('HETATM'))
     self.assertTrue(lines[1].startswith('END'))