Exemplo n.º 1
0
    def test_color_deep(self):
        cmd.viewport(100, 70)
        self.ambientOnly()

        cmd.fragment('trp', 'm1')
        cmd.orient('m1')
        cmd.show_as('sticks')
        cmd.show('spheres', 'name C')
        cmd.set('stick_color', 'blue', 'm1')
        cmd.set('stick_color', 'red', 'name CH2+CZ3+CE3+CD2')
        cmd.set('sphere_color', 'yellow', 'name C')

        cmd.color('green')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('yellow', img)
        self.assertImageHasNotColor('green', img)

        cmd.color_deep('green')

        img = self.get_imagearray()
        self.assertImageHasNotColor('blue', img)
        self.assertImageHasNotColor('red', img)
        self.assertImageHasNotColor('yellow', img)
        self.assertImageHasColor('green', img)
def show_ligand_interactions(recsel="not hetatm", ligsel="hetatm", cutoff=5):
    """
DESCRIPTION

    Visualize interactions between receptor and ligand.

ARGUMENTS

    recsel = string: atom selection of the receptor {default: "not hetatm"}

    ligsel = string: atom selections of the ligand {default: "hetatm"}

    cutoff = float: show as sticks all receptor residues within this distance from the ligand {default: 5.0}
    """
    cmd.select('ligand', ligsel)
    cmd.select('receptor', recsel)
    cmd.bg_color('white')
    cmd.show_as('cartoon')
    cmd.show_as('sticks', 'hetatm')
    cmd.set('cartoon_transparency', 0.2)
    cmd.spectrum(selection=recsel+" or "+ligsel,byres=1)
    util.cbag('not elem C')
    cmd.set('cartoon_fancy_helices', 1);
    cmd.show("sticks", "(hydro)");
    cmd.select("pocket", "byres (receptor within %s of ligand)" % cutoff);
    cmd.show("sticks", "pocket")
    cmd.hide('(h. and (e. c extend 1))')
    cmd.set('h_bond_max_angle', 30)
    cmd.set('h_bond_cutoff_center', 3.6)
    cmd.set('h_bond_cutoff_edge', 3.2)
    cmd.dist('ligand_Hbonds', 'ligand', 'receptor', 3.5, mode=2)
    cmd.set('dash_radius', 0.15)
    # now set the label options
    cmd.set('label_size', 20)
    cmd.set('label_position', [0,0,10])
Exemplo n.º 3
0
def load():
   try:
      r = 0
      list = glob(ent_dir)
      list.sort()
#      list = [ "pdb/vq" ]
      for dir in list:
         sys.__stdout__.write("\n"+dir)
         sys.__stdout__.flush()
         for file in glob(dir+"/pdb*"):
            name = os.path.split(file)[-1]
            name = string.split(name,'.')[0]
            cmd.disable()
            cmd.load(file,name)
            cmd.show_as("cartoon",name)
            cmd.refresh()
            cmd.dss(name)
            cmd.refresh()
            time.sleep(0.1)
            sys.__stdout__.write(".")
            sys.__stdout__.flush()
         sys.__stdout__.write("("+str(cmd.count_atoms())+")")
         sys.__stdout__.flush()         
         cmd.dss()
         cmd.delete('all')
   except:
      traceback.print_exc()
Exemplo n.º 4
0
def normalmodes_prody(selection, cutoff=15, first=7, last=10, guide=1,
        prefix='prody', states=7, factor=-1, quiet=1):
    '''
DESCRIPTION

    Anisotropic Network Model (ANM) analysis with ProDy.

    Based on:
    http://www.csb.pitt.edu/prody/examples/dynamics/enm/anm.html
    '''
    try:
        import prody
    except ImportError:
        print('Failed to import prody, please add to PYTHONPATH')
        raise CmdException

    first, last, guide = int(first), int(last), int(guide)
    states, factor, quiet = int(states), float(factor), int(quiet)
    assert first > 6

    if guide:
        selection = '(%s) and guide and alt A+' % (selection)
    tmpsele = cmd.get_unused_name('_')
    cmd.select(tmpsele, selection)

    f = StringIO(cmd.get_pdbstr(tmpsele))
    conf = prody.parsePDBStream(f)

    modes = prody.ANM()
    modes.buildHessian(conf, float(cutoff))
    modes.calcModes(last - first + 1)

    if factor < 0:
        from math import log
        natoms = modes.numAtoms()
        factor = log(natoms) * 10
        if not quiet:
            print(' set factor to %.2f' % (factor))

    for mode in range(first, last + 1):
        name = prefix + '%d' % mode
        cmd.delete(name)

        if not quiet:
            print(' normalmodes: object "%s" for mode %d' % (name, mode))

        for state in range(1, states+1):
            xyz_it = iter(modes[mode-7].getArrayNx3() * (factor *
                    ((state-1.0)/(states-1.0) - 0.5)))
            cmd.create(name, tmpsele, 1, state, zoom=0)
            cmd.alter_state(state, name, '(x,y,z) = xyz_it.next() + (x,y,z)',
                    space=locals())

    cmd.delete(tmpsele)

    if guide:
        cmd.set('ribbon_trace_atoms', 1, prefix + '*')
        cmd.show_as('ribbon', prefix + '*')
    else:
        cmd.show_as('lines', prefix + '*')
Exemplo n.º 5
0
def q5():
    '''
    DESCRIPTION

    Question 5:  How many axial stacks of helices does 
    the ribozyme have?
    
    The following commands created the scene for "q5": 
    
    delete all;fetch 3zp8, hammer, async=0;show cartoon, hammer;set_view (-0.5,0.18,-0.85,-0.17,-0.98,-0.11,-0.85,0.09,0.52,0.0,0.0,-167.2,-18.45,10.92,-12.11,126.37,208.02,-20.0);rock;

    To reuse of parts or all of the above commands, copy and paste the commands 
    onto the command line or into a plain text file. 
      
    These commands are sufficient for most editing tasks:  
    To edit code, positon cursor on command line with left mouse button.  
    Control-e moves the cursor to the end of the line, even when it is out of view.
    Control-a moves the cursor to the beginning of the line, even when it is out of view.    
    Up arrow key recalls last line of commands for editing.

    These commands may not be available on all systems:
    Shift-control-a selects everything from the right of the cursor to the end of the line.
    Shift-control-e selects everything to the left of the cursor to the end of the line.
    Command-f moves the cursor to the end of the current word.   
    Command-b moves the cursor to the begining of the current word.
    Control-f moves the cursor to the right by one character.   
    Control-b moves the cursor to the left by one character.
    '''
    cmd.reinitialize()
    cmd.fetch('3zp8', type='pdb', name= 'hammer', async='0')
    cmd.show_as('cartoon','hammer')
    cmd.rock()
    cmd.set_view('(-0.5,0.18,-0.85,-0.17,-0.98,-0.11,-0.85,0.09,0.52,0.0,0.0,-167.2,-18.45,10.92,-12.11,126.37,208.02,-20.0);')
    print('Enter "q5" to make the scene for question 5.')
    print('Enter "help q5" to see question 5 and the commands to make the scene.') 
Exemplo n.º 6
0
    def testStickBall(self, use_shader):
        '''
        Test some stick_ball* settings
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', use_shader)

        self.ambientOnly()

        cmd.set('stick_ball')
        cmd.set('stick_ball_ratio', 2.0)
        cmd.set('stick_ball_color', 'blue')
        cmd.set('stick_color', 'red')

        cmd.fragment('gly')
        cmd.orient()

        cmd.color('green')
        cmd.show_as('sticks')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasNotColor('green', img)
Exemplo n.º 7
0
    def testStickBall(self, use_shader):
        '''
        Test some stick_ball* settings
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', use_shader)

        self.ambientOnly()

        cmd.set('stick_ball')
        cmd.set('stick_ball_ratio', 2.0)
        cmd.set('stick_ball_color', 'blue')
        cmd.set('stick_color', 'red')

        cmd.fragment('gly')
        cmd.orient()

        cmd.color('green')
        cmd.show_as('sticks')

        img = self.get_imagearray()
        self.assertImageHasColor('blue', img)
        self.assertImageHasColor('red', img)
        self.assertImageHasNotColor('green', img)
Exemplo n.º 8
0
    def testTrilines(self, trilines):
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.set('dynamic_width', 0)
        cmd.set('line_width', 5)
        cmd.set('line_smooth', 0)

        cmd.fragment('ethylene')
        cmd.show_as('lines')
        cmd.color('white')
        cmd.orient()

        cmd.set('trilines', trilines)

        # check percentage of covered pixels
        img = self.get_imagearray()
        npixels = img.shape[0] * img.shape[1]
        covered = numpy.count_nonzero(img[..., :3])
        ratio = covered / float(npixels)
        msg = "covered=%d npixels=%d ratio=%f" % (covered, npixels, ratio)
        self.assertTrue(0.14 < ratio < 0.165, msg)
Exemplo n.º 9
0
def load():
   cmd.set("valence")
   r = 0
   list = glob("pdb/*/*")
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      try:
         cmd.delete('pdb')
         cmd.load(file,'pdb')
         cmd.set_title('pdb',1,os.path.split(file)[-1])
         cmd.rewind()
         cmd.orient('pdb')
         cmd.refresh()
         cmd.show_as("ribbon")
         cmd.refresh()
         cmd.show_as("sticks")
         cmd.refresh()
         sys.__stderr__.write(".")
         sys.__stderr__.flush()
         n = cmd.count_states()
         if n>1:
            cmd.rewind()
            sys.__stderr__.write(file+"\n")
            sys.__stderr__.flush()
            for a in range(1,n+1):
               cmd.forward()
               cmd.refresh()
      except:
         traceback.print_exc()
Exemplo n.º 10
0
    def testTrilines(self, trilines):
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.set('dynamic_width', 0)
        cmd.set('line_width', 5)
        cmd.set('line_smooth', 0)

        cmd.fragment('ethylene')
        cmd.show_as('lines')
        cmd.color('white')
        cmd.orient()

        cmd.set('trilines', trilines)

        # check percentage of covered pixels
        img = self.get_imagearray()
        npixels = img.shape[0] * img.shape[1]
        covered = numpy.count_nonzero(img[...,:3])
        ratio = covered / float(npixels)
        msg = "covered=%d npixels=%d ratio=%f" % (covered, npixels, ratio)
        self.assertTrue(0.14 < ratio < 0.165, msg)
Exemplo n.º 11
0
    def testMMTF(self):
        '''Styled MMTF export/import'''
        S = 0b10            # 1 << 1 spheres
        D = 0b1000000000    # 1 << 9 dots
        B = 2 # blue
        R = 4 # red

        cmd.fragment('gly')
        cmd.color(B)
        cmd.color(R, 'elem C')
        cmd.show_as('spheres')
        cmd.show_as('dots', 'elem C')

        with testing.mktemp('.mmtf') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename)

        color_list = []
        reps_list = []

        cmd.iterate('*', 'color_list.append(color)', space=locals())
        cmd.iterate('*', 'reps_list.append(reps)', space=locals())

        self.assertEqual(color_list, [B, R, R, B, B, B, B])
        self.assertEqual(reps_list, [S, D, D, S, S, S, S])
Exemplo n.º 12
0
def example():
    cmd.fetch('1d7q', async=0)
    cmd.show_as('sticks')
    with timing():
        rmsf('all')
    with timing():
        spectrumproperty('rmsf', 'blue white red')
Exemplo n.º 13
0
def paint_vars_f_Bin(vars_a, vars_b):
    cmd.set_view("""0.147443876, -0.624960124, -0.766605735, \
        0.453299403, -0.646183312, 0.613975227, \
        -0.879078567, -0.438027859, 0.188018516, \
        0.000000000, 0.000000000, -252.833984375, \
        30.680297852, 182.966445923, 30.680259705, \
        199.336242676, 306.331726074, -20.000000000""")
    cmd.show_as("cartoon", "all")
    color_sel("grey", "all")
    cmd.select("epi", "resi 62-69+196-212")
    cmd.select("F2", "resi 22-109")
    cmd.select("F1", "resi 160-516")
    with open(vars_a, "r") as _:
        vars_a = _.readline().strip().split()
        freq_a = _.readline().strip().split()
    with open(vars_b, "r") as _:
        vars_b = _.readline().strip().split()
        freq_b = _.readline().strip().split()
    vars_sel = "resi " + "+".join(vars_a + vars_b)
    cmd.select("vars", vars_sel)
    cmd.show_as("spheres", "vars")
    vars_a_sel = "resi " + "+".join(vars_a)
    vars_b_sel = "resi " + "+".join(vars_b)
    color_sel("orange", "F1 and " + vars_a_sel)
    color_sel("green", "F1 and " + vars_b_sel)
    color_sel("yellow", "F2 and " + vars_a_sel)
    color_sel("cyan", "F2 and " + vars_b_sel)
    color_sel("red", "epi")
    set_labels()
    cmd.label("vars and name cb", "'%s'%(resi,)")
Exemplo n.º 14
0
    def testMMTF(self):
        '''Styled MMTF export/import'''
        S = 0b10            # 1 << 1 spheres
        D = 0b1000000000    # 1 << 9 dots
        B = 2 # blue
        R = 4 # red

        cmd.fragment('gly')
        cmd.color(B)
        cmd.color(R, 'elem C')
        cmd.show_as('spheres')
        cmd.show_as('dots', 'elem C')

        with testing.mktemp('.mmtf') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename)

        color_list = []
        reps_list = []

        cmd.iterate('*', 'color_list.append(color)', space=locals())
        cmd.iterate('*', 'reps_list.append(reps)', space=locals())

        self.assertEqual(color_list, [B, R, R, B, B, B, B])
        self.assertEqual(reps_list, [S, D, D, S, S, S, S])
Exemplo n.º 15
0
def findSurfaceResidues(objSel="(all)",
                        cutoff=2.5,
                        doShow=False,
                        verbose=False):
    tmpObj = "__tmp"
    cmd.create(tmpObj, objSel + " and polymer")
    if verbose != False:
        print("WARNING: I'm setting dot_solvent.  You may not care for this.")
    cmd.set("dot_solvent")
    cmd.get_area(selection=tmpObj, load_b=1)
    cmd.remove(tmpObj + " and b < " + str(cutoff))

    stored.tmp_dict = {}
    cmd.iterate(tmpObj, "stored.tmp_dict[(chain,resv)]=1")
    exposed = stored.tmp_dict.keys()
    exposed.sort()

    randstr = str(random.randint(0, 10000))
    selName = "exposed_atm_" + randstr
    if verbose != False:
        print("Exposed residues are selected in: " + selName)
    cmd.select(selName, objSel + " in " + tmpObj)
    selNameRes = "exposed_res_" + randstr
    cmd.select(selNameRes, "byres " + selName)

    if doShow != False:
        cmd.show_as("spheres", objSel + " and poly")
        cmd.color("white", objSel)
        cmd.color("red", selName)
    cmd.delete(tmpObj)
    return exposed
Exemplo n.º 16
0
def load():
    cmd.set("valence")
    r = 0
    list = glob("pdb/*/*")
    #   while list[0]!="pdb/f8/pdb1f8u":
    #      list.pop(0)
    for file in list:
        try:
            cmd.delete('pdb')
            cmd.load(file, 'pdb')
            cmd.set_title('pdb', 1, os.path.split(file)[-1])
            cmd.rewind()
            cmd.orient('pdb')
            cmd.refresh()
            cmd.show_as("ribbon")
            cmd.refresh()
            cmd.show_as("sticks")
            cmd.refresh()
            sys.__stderr__.write(".")
            sys.__stderr__.flush()
            n = cmd.count_states()
            if n > 1:
                cmd.rewind()
                sys.__stderr__.write(file + "\n")
                sys.__stderr__.flush()
                for a in range(1, n + 1):
                    cmd.forward()
                    cmd.refresh()
        except:
            traceback.print_exc()
Exemplo n.º 17
0
    def testAA(self):
        '''
        Make a black/white image and check if gray pixels are found with
        antialias_shader=1/2
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.fragment('gly')
        cmd.show_as('spheres')
        cmd.color('white')
        cmd.zoom()

        # b/w image, we expect only two color values
        img = self.get_imagearray()
        self.assertTrue(len(numpy.unique(img[...,:3])) == 2)

        for aa in (1, 2):
            cmd.set('antialias_shader', aa)

            # smoothed edges, we expect more than two color values
            img = self.get_imagearray()
            self.assertTrue(len(numpy.unique(img[...,:3])) > 2)
Exemplo n.º 18
0
    def plot(self, outfile):
        ctrl_id, case_id, snp_df_sub = self.score_on_var()
        df = pd.merge(snp_df_sub, self.snps2aa, on='id')

        #pymol.finish_launching()
        cmd.reinitialize()
        cmd.fetch(self.pdb)
        cmd.alter(self.pdb, 'b = 0.5')
        cmd.show_as('cartoon', self.pdb)
        cmd.color('white', self.pdb)

        for i, row in df.iterrows():
            resi = row['structure_position']
            chain = row['chain']
            pheno = row['es']
            selec = 'snp%s' % i
            selec_atom = 'snp_atom%s' % i
            cmd.select(selec,
                       'name ca and resi %s and chain %s' % (resi, chain))
            cmd.create(selec_atom, selec)
            cmd.set("sphere_scale", 0.8)
            cmd.show('sphere', selec_atom)
            cmd.alter(selec_atom, 'b=%s' % pheno)
            cmd.spectrum("b",
                         "blue_white_red",
                         selec_atom,
                         maximum=1.0,
                         minimum=0.0)
        cmd.bg_color("white")
        cmd.zoom()
        cmd.orient()
        cmd.save('%s.pse' % outfile)
        cmd.png('%s.png' % outfile, width=2400, height=2400, dpi=300, ray=1)
Exemplo n.º 19
0
    def testRepsExist(self):
        cmd.viewport(200, 150)
        cmd.load(self.datafile('1oky-frag.pdb'), 'm1')

        # make some nonbonded
        cmd.unbond('resi 115-', 'resi 115-')

        # labels
        cmd.label('all', 'name')

        # measurements
        cmd.distance('measure1', 'index 1', 'index 10')
        cmd.angle('measure1', 'index 1', 'index 10', 'index 20')
        cmd.dihedral('measure1', 'index 1', 'index 10', 'index 20', 'index 30')

        # color test setup
        cmd.color('white', '*')
        cmd.set('ambient', 1)
        cmd.set('depth_cue', 0)
        cmd.set('antialias', 0)
        cmd.set('line_smooth', 0)
        cmd.orient()

        # test most reps
        for rep in REPS:
            cmd.show_as(rep)
            self.assertImageHasColor('white', msg='rep missing: ' + rep)

        # test cartoon
        cmd.show_as('cartoon')
        for cart in CARTOONS:
            cmd.cartoon(cart)
            self.assertImageHasColor('white', msg='cartoon missing: ' + cart)
Exemplo n.º 20
0
    def testAA(self):
        '''
        Make a black/white image and check if gray pixels are found with
        antialias_shader=1/2
        '''
        cmd.viewport(100, 100)

        cmd.set('use_shaders', True)

        self.ambientOnly()

        cmd.fragment('gly')
        cmd.show_as('spheres')
        cmd.color('white')
        cmd.zoom()

        # b/w image, we expect only two color values
        img = self.get_imagearray()
        self.assertNumColorsEqual(img, 2)

        for aa in (1, 2):
            cmd.set('antialias_shader', aa)

            # smoothed edges, we expect more than two color values
            img = self.get_imagearray()
            self.assertTrue(len(numpy.unique(img[..., :3])) > 2)
Exemplo n.º 21
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)
Exemplo n.º 22
0
def load():
    cmd.set("valence")
    r = 0
    list = glob("pdb/*/*")
    (x, y, z) = (0, 0, 0)
    start = time.time()
    count = 1
    scale = 100.0
    for file in list:
        cmd.load(file, str(count), quiet=1)
        cmd.translate([x * scale, y * scale, z * scale], object=str(count))
        #      cmd.disable(str(count))
        atoms = cmd.count_atoms()
        passed = time.time() - start
        print "%3d structures/%5.1f sec = %8.1f atom/sec over %6d atoms" % (
            count, passed, atoms / passed, atoms)
        count = count + 1
        if count > 100: break
        x = x + 1
        if x > 7:
            x = 0
            y = y + 1
            if y > 7:
                y = 0
                z = z + 1
                if z > 9:
                    y = 0
                    z = z + 1
    cmd.zoom()
    cmd.set("sphere_mode", 1)
    cmd.show_as("spheres")
    cmd.rebuild()
    cmd.set("hash_max", 250)
Exemplo n.º 23
0
Arquivo: nma.py Projeto: BILAB/psico
def normalmodes_prody(selection, cutoff=15, first=7, last=10, guide=1,
        prefix='prody', states=7, factor=-1, quiet=1):
    '''
DESCRIPTION

    Anisotropic Network Model (ANM) analysis with ProDy.

    Based on:
    http://www.csb.pitt.edu/prody/examples/dynamics/enm/anm.html
    '''
    try:
        import prody
    except ImportError:
        print('Failed to import prody, please add to PYTHONPATH')
        raise CmdException

    first, last, guide = int(first), int(last), int(guide)
    states, factor, quiet = int(states), float(factor), int(quiet)
    assert first > 6

    if guide:
        selection = '(%s) and guide and alt A+' % (selection)
    tmpsele = cmd.get_unused_name('_')
    cmd.select(tmpsele, selection)

    f = StringIO(cmd.get_pdbstr(tmpsele))
    conf = prody.parsePDBStream(f)

    modes = prody.ANM()
    modes.buildHessian(conf, float(cutoff))
    modes.calcModes(last - first + 1)

    if factor < 0:
        from math import log
        natoms = modes.numAtoms()
        factor = log(natoms) * 10
        if not quiet:
            print(' set factor to %.2f' % (factor))

    for mode in range(first, last + 1):
        name = prefix + '%d' % mode
        cmd.delete(name)

        if not quiet:
            print(' normalmodes: object "%s" for mode %d' % (name, mode))

        for state in range(1, states+1):
            xyz_it = iter(modes[mode-7].getArrayNx3() * (factor *
                    ((state-1.0)/(states-1.0) - 0.5)))
            cmd.create(name, tmpsele, 1, state, zoom=0)
            cmd.alter_state(state, name, '(x,y,z) = next(xyz_it) + (x,y,z)',
                    space={'xyz_it': xyz_it, 'next': next})

    cmd.delete(tmpsele)

    if guide:
        cmd.set('ribbon_trace_atoms', 1, prefix + '*')
        cmd.show_as('ribbon', prefix + '*')
    else:
        cmd.show_as('lines', prefix + '*')
Exemplo n.º 24
0
def loadFitnessFactors (mol,startaa=1,source="/Users/student/Box Sync/PUBS/Pymol-practice.txt", visual="Y"):
        # adapted from http://www.pymolwiki.org/index.php/Load_new_B-factors
        """
        Replaces B-factors with a list of fitness factor values contained in a plain txt file
 
        usage: loadFitnessFactors mol, [startaa, [source, [visual]]]
 
        mol = any object selection (within one single object though)
        startaa = number of first amino acid in 'new Fitness-factors' file (default=1)
        source = name of the file containing new Fitness-factor values (default=newFitnessFactors.txt)
        visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)
 
        example: loadFitnessFactors 1LVM and chain A
        """
        obj=cmd.get_object_list(mol)[0]
        cmd.alter(mol,"b=-1.0")
        inFile = open(source, 'r')
        counter=int(startaa)
        fitnessFacts=[]
        for line in inFile.readlines():
                fitnessFact=float(line)
                fitnessFacts.append(fitnessFact)
                cmd.alter("%s and resi %s and n. CA"%(mol,counter), "b=%s"%fitnessFact)
                counter=counter+1
        if visual=="Y":
                cmd.show_as("cartoon",mol)
                cmd.cartoon("putty", mol)
#                cmd.set("cartoon_putty_scale_min", min(fitnessFacts),obj)
#                cmd.set("cartoon_putty_scale_max", max(fitnessFacts),obj)
                cmd.set("cartoon_putty_transform", 0,obj)
                cmd.set("cartoon_putty_radius", 0.2,obj)
                cmd.spectrum("b","red_white_blue", "%s and n. CA " %mol)
                cmd.ramp_new("count", obj, [min(fitnessFacts), (min(fitnessFacts)+max(fitnessFacts))/2, max(fitnessFacts)], color = ["blue", "white", "red"])
                cmd.recolor()
Exemplo n.º 25
0
def loadBfacts (mol,startaa=1,source="/Users/student/Box Sync/PUBS/Pymol-practice.txt", visual="Y"):
	"""
	Replaces B-factors with a list of values contained in a plain txt file
 
	usage: loadBfacts mol, [startaa, [source, [visual]]]
 
	mol = any object selection (within one single object though)
	startaa = number of first amino acid in 'new B-factors' file (default=1)
	source = name of the file containing new B-factor values (default=newBfactors.txt)
	visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)
 
	example: loadBfacts 1LVM and chain A
	"""
	obj=cmd.get_object_list(mol)[0]
	cmd.alter(mol,"b=-1.0")
	inFile = open(source, 'r')
	counter=int(startaa)
	bfacts=[]
	for line in inFile.readlines():	
		bfact=float(line)
		bfacts.append(bfact)
		cmd.alter("%s and resi %s and n. CA"%(mol,counter), "b=%s"%bfact)
		counter=counter+1
	if visual=="Y":
		cmd.show_as("cartoon",mol)
		cmd.cartoon("putty", mol)
		cmd.set("cartoon_putty_scale_min", min(bfacts),obj)
		cmd.set("cartoon_putty_scale_max", max(bfacts),obj)
		cmd.set("cartoon_putty_transform", 0,obj)
		cmd.set("cartoon_putty_radius", 0.2,obj)
		cmd.spectrum("b","rainbow", "%s and n. CA " %mol)
		cmd.ramp_new("count", obj, [min(bfacts), max(bfacts)], "rainbow")
		cmd.recolor()
Exemplo n.º 26
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)
Exemplo n.º 27
0
def option2():

	vinacomd = str(checkutilities())
	A = inputdata2()

	global proteinfile, ligandfile

	import addwater
	addwater.main(ligandfile)

	waterfile()
	#Writes the water.pdbqt file

	import dockcheck
	dockcheck.main(proteinfile, ligandfile, vinacomd)

	os.remove('waterdetails.txt')
	os.remove('placedwaters.pdb')
	os.remove('water.pdbqt')


	cmd.set("retain_order", 1)
	cmd.set("pdb_use_ter_records", 0)
	cmd.load(proteinfile, 'pro')
	cmd.show_as('cartoon', 'pro')
	cmd.color('blue','pro')
	cmd.load('predictedwaters.pdb','wats')
	cmd.color('red','wats')
	cmd.load(ligandfile,'lig')
	cmd.show_as('sticks','lig')
	cmd.center('lig')
def preProcessPDB(fname):
        stored.residues = []
        stored.chains = []
        cmd.iterate('(name ca)', 'stored.residues.append(resi)')
        cmd.iterate('(name ca)', 'stored.chains.append(chain)')
        cmd.show_as("cartoon", '(all)')
        cmd.color("white", '(all)')
Exemplo n.º 29
0
def loadBfacts(mol, startaa=1, source="newBfactors.txt", visual="Y"):
    """
	Replaces B-factors with a list of values contained in a plain txt file
	
	usage: loadBfacts mol, [startaa, [source, [visual]]]
 
	mol = any object selection (within one single object though)
	startaa = number of first amino acid in 'new B-factors' file (default=1)
	source = name of the file containing new B-factor values (default=newBfactors.txt)
	visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)
 
	example: loadBfacts 1LVM and chain A
	"""
    obj = cmd.get_object_list(mol)[0]
    cmd.alter(mol, "b=-1.0")
    inFile = open(source, 'r')
    counter = int(startaa)
    bfacts = []
    for line in inFile.readlines():
        bfact = float(line)
        bfacts.append(bfact)
        cmd.alter("%s and resi %s and n. CA" % (mol, counter), "b=%s" % bfact)
        counter = counter + 1
    if visual == "Y":
        cmd.show_as("cartoon", mol)
        cmd.cartoon("putty", mol)
        cmd.set("cartoon_putty_scale_min", min(bfacts), obj)
        cmd.set("cartoon_putty_scale_max", max(bfacts), obj)
        cmd.set("cartoon_putty_transform", 0, obj)
        cmd.set("cartoon_putty_radius", 0.2, obj)
        cmd.spectrum("b", "rainbow", "%s and n. CA " % mol)
        cmd.ramp_new("count", obj, [min(bfacts), max(bfacts)], "rainbow")
        cmd.recolor()
Exemplo n.º 30
0
def option2():

    vinacomd = str(checkutilities())
    A = inputdata2()

    global proteinfile, ligandfile

    import addwater
    addwater.main(ligandfile)

    waterfile()
    #Writes the water.pdbqt file

    import dockcheck
    dockcheck.main(proteinfile, ligandfile, vinacomd)

    os.remove('waterdetails.txt')
    os.remove('placedwaters.pdb')
    os.remove('water.pdbqt')

    cmd.set("retain_order", 1)
    cmd.set("pdb_use_ter_records", 0)
    cmd.load(proteinfile, 'pro')
    cmd.show_as('cartoon', 'pro')
    cmd.color('blue', 'pro')
    cmd.load('predictedwaters.pdb', 'wats')
    cmd.color('red', 'wats')
    cmd.load(ligandfile, 'lig')
    cmd.show_as('sticks', 'lig')
    cmd.center('lig')
Exemplo n.º 31
0
    def testRepsExist(self):
        cmd.viewport(200, 150)
        cmd.load(self.datafile('1oky-frag.pdb'), 'm1')

        # make some nonbonded
        cmd.unbond('resi 115-', 'resi 115-')

        # labels
        cmd.label('all', 'name')

        # measurements
        cmd.distance('measure1', 'index 1', 'index 10')
        cmd.angle('measure1', 'index 1', 'index 10', 'index 20')
        cmd.dihedral('measure1', 'index 1', 'index 10', 'index 20', 'index 30')

        # color test setup
        cmd.color('white', '*')
        cmd.set('ambient', 1)
        cmd.set('depth_cue', 0)
        cmd.set('antialias', 0)
        cmd.set('line_smooth', 0)
        cmd.orient()

        # test most reps
        for rep in REPS:
            cmd.show_as(rep)
            self.assertImageHasColor('white', msg='rep missing: ' + rep)

        # test cartoon
        cmd.show_as('cartoon')
        for cart in CARTOONS:
            cmd.cartoon(cart)
            self.assertImageHasColor('white', msg='cartoon missing: ' + cart)
def findSurfaceResidues(objSel="(all)", cutoff=2.5, doShow=False, verbose=True):
	"""
	findSurfaceResidues
		finds those residues on the surface of a protein
		that have at least 'cutoff' exposed A**2 surface area.
 
	PARAMS
		objSel (string)
			the object or selection in which to find
			exposed residues
			DEFAULT: (all)
 
		cutoff (float)
			your cutoff of what is exposed or not. 
			DEFAULT: 2.5 Ang**2
 
		asSel (boolean)
			make a selection out of the residues found
 
	RETURNS
		(list: (chain, resv ) )
			A Python list of residue numbers corresponding
			to those residues w/more exposure than the cutoff.
 
	"""
	tmpObj="__tmp"
	cmd.create( tmpObj, objSel + " and polymer");
	if verbose!=False:
		print "WARNING: I'm setting dot_solvent.  You may not care for this."
	cmd.set("dot_solvent");
	cmd.get_area(selection=tmpObj, load_b=1)
 
	# threshold on what one considers an "exposed" atom (in A**2):
	cmd.remove( tmpObj + " and b < " + str(cutoff) )
 
	stored.tmp_dict = {}
	cmd.iterate(tmpObj, "stored.tmp_dict[(chain,resv)]=1")
	exposed = stored.tmp_dict.keys()
	exposed.sort()
 
        randstr = str(random.randint(0,10000))
	selName = "exposed_atm_" + randstr
	if verbose!=False:
		print "Exposed residues are selected in: " + selName
	cmd.select(selName, objSel + " in " + tmpObj ) 
        selNameRes = "exposed_res_" + randstr
        cmd.select(selNameRes, "byres " + selName )
 
 
	if doShow!=False:
		cmd.show_as("spheres", objSel + " and poly")
		cmd.color("white", objSel)
		cmd.color("red", selName)
 
	cmd.delete(tmpObj)
	
	print exposed
 
	return exposed
Exemplo n.º 33
0
def findSurfaceResidues(objSel="(all)",
                        cutoff=2.5,
                        doShow=False,
                        verbose=False):
    """
	findSurfaceResidues
		finds those residues on the surface of a protein
		that have at least 'cutoff' exposed A**2 surface area.

	PARAMS
		objSel (string)
			the object or selection in which to find
			exposed residues
			DEFAULT: (all)

		cutoff (float)
			your cutoff of what is exposed or not. 
			DEFAULT: 2.5 Ang**2

		asSel (boolean)
			make a selection out of the residues found

	RETURNS
		(list: (chain, resv ) )
			A Python list of residue numbers corresponding
			to those residues w/more exposure than the cutoff.

	"""
    tmpObj = "__tmp"
    cmd.create(tmpObj, objSel + " and polymer")
    if verbose != False:
        print "WARNING: I'm setting dot_solvent.  You may not care for this."
    cmd.set("dot_solvent")
    cmd.get_area(selection=tmpObj, load_b=1)

    # threshold on what one considers an "exposed" atom (in A**2):
    cmd.remove(tmpObj + " and b < " + str(cutoff))

    stored.tmp_dict = {}
    cmd.iterate(tmpObj, "stored.tmp_dict[(chain,resv)]=1")
    exposed = stored.tmp_dict.keys()
    exposed.sort()

    randstr = str(random.randint(0, 10000))
    selName = "exposed_atm_" + randstr
    if verbose != False:
        print "Exposed residues are selected in: " + selName
    cmd.select(selName, objSel + " in " + tmpObj)
    selNameRes = "exposed_res_" + randstr
    cmd.select(selNameRes, "byres " + selName)

    if doShow != False:
        cmd.show_as("spheres", objSel + " and poly")
        cmd.color("white", objSel)
        cmd.color("red", selName)

    cmd.delete(tmpObj)

    return exposed
Exemplo n.º 34
0
 def _testSpectrum_setup(self):
     cmd.pseudoatom('m1', pos=(-2, 0, 0))
     cmd.pseudoatom('m2', pos=(0, 0, 0))
     cmd.pseudoatom('m3', pos=(2, 0, 0))
     cmd.show_as('spheres')
     self.ambientOnly()
     cmd.viewport(40, 20)
     cmd.zoom()
Exemplo n.º 35
0
 def photo_pdb(pdb_file, out_file):
     pymol.finish_launching(['pymol', '-qc'])
     cmd.reinitialize()
     cmd.load(pdb_file)
     cmd.show_as('cartoon', 'all')
     cmd.util.cbc()
     cmd.png(filename=out_file, width=350, height=350, ray=0, dpi=300)
     cmd.quit()
Exemplo n.º 36
0
 def testCOLLADA(self):
     cmd.fragment('gly')
     for rep in ['spheres', 'sticks', 'surface']:
         cmd.show_as(rep)
         with testing.mktemp('.dae') as filename:
             cmd.save(filename)
             contents = file_get_contents(filename)
             self.assertTrue('<COLLADA' in contents)
Exemplo n.º 37
0
 def testVRML(self):
     cmd.fragment('gly')
     for rep in ['spheres', 'sticks', 'surface']:
         cmd.show_as(rep)
         with testing.mktemp('.wrl') as filename:
             cmd.save(filename)
             contents = file_get_contents(filename)
             self.assertTrue(contents.startswith('#VRML V2'))
Exemplo n.º 38
0
 def testGetPovray(self):
     cmd.fragment('gly')
     cmd.show_as('sticks')
     pov = cmd.get_povray()
     self.assertTrue(isinstance(pov, tuple))
     self.assertEqual(len(pov), 2)
     self.assertTrue(pov[0].startswith('camera {direction<0.0,0.0'))
     self.assertTrue(pov[1].startswith('cylinder{<'))
Exemplo n.º 39
0
def show_as(show, selection):
    '''`as` is a reserved word as of python 2.6
    pymol used cmd.as before this and
    had to change to cmd.show_as'''
    try:
        cmd.show_as(show, selection)
    except AttributeError:
        getattr(cmd, 'as')(show, selection)
Exemplo n.º 40
0
 def _testSpectrum_setup(self):
     cmd.pseudoatom('m1', pos=(-2,0,0))
     cmd.pseudoatom('m2', pos=(0,0,0))
     cmd.pseudoatom('m3', pos=(2,0,0))
     cmd.show_as('spheres')
     self.ambientOnly()
     cmd.viewport(40,20)
     cmd.zoom()
Exemplo n.º 41
0
def dehydron(selection='all', angle_range=40, max_distance=3.5, desolv=6.5, min_wrappers=19, quiet=0):
    '''
DESCRIPTION

    dehydron calculator

USAGE

    dehydron [ selection [, angle_range [, max_distance [, desolv [, min_wrappers ]]]]]
    '''

    angle, max_distance = float(angle_range), float(max_distance)
    desolv, min_wrappers = float(desolv), int(min_wrappers)
    quiet = int(quiet)


    name = cmd.get_legal_name('DH_%s' % selection)
    cmd.delete(name)

    selection_hb = '((%s) and polymer)' % (selection)
    hb = cmd.find_pairs("((byres "+selection_hb+") and n. n)","((byres "+selection_hb+") and n. o)",mode=1,cutoff=max_distance,angle=angle_range)

    if not quiet:
        hb.sort(lambda x,y:(cmp(x[0][1],y[0][1])))
        print "--------------------------------------------------------------------"
        print "--------------------------Dehydron Results--------------------------"
        print "--------------------------------------------------------------------"
        print "            Donor            |            Aceptor          |"
        print "     Object   Chain Residue  |     Object   Chain Residue  | # wrappers"

    cmd.select('_nonpolar', '(elem C) and not (solvent or (elem N+O) extend 1)', 0)
    try:
        cmd.select('_selection', '%s' % selection, 0)
    except:
        pass

    sel = []
    for pairs in hb:
        wrappers = cmd.count_atoms('((%s and _nonpolar and _selection) within %f of byca (%s`%d %s`%d))' % 
                ((pairs[0][0], desolv) + pairs[0] + pairs[1]))
        if wrappers < min_wrappers:
            cmd.distance(name, pairs[0], pairs[1])
            if not quiet:
                cmd.iterate(pairs[0], 'stored.nitro = chain, resi, resn')
                cmd.iterate(pairs[1], 'stored.oxy = chain, resi, resn')
                print ' %12s%4s%6s%5d | %12s%4s%6s%5d |%7s' % (pairs[0][0], stored.nitro[0], stored.nitro[2], int(stored.nitro[1]), pairs[1][0], stored.oxy[0], stored.oxy[2], int(stored.oxy[1]), wrappers)
            sel.append(pairs[0])
            sel.append(pairs[1])
    cmd.delete('_nonpolar')
    cmd.delete('_selection')

    if len(sel) > 0:
        cmd.show_as('dashes', name)
    elif not quiet and len(hb) != 0:
        print ' - no dehydrons were found - '
    else:
        print ' - no hydrogen bonds were found - '
Exemplo n.º 42
0
 def launchPyMol(self, pdbfile):
     """Open pdb in PyMOL"""
     import pymol
     # Call the function below before using any PyMOL modules.
     pymol.finish_launching()
     from pymol import cmd
     cmd.load(pdbfile)
     cmd.show_as('sticks')
     return
Exemplo n.º 43
0
 def testGetIdtf(self):
     cmd.fragment('gly')
     cmd.show_as('surface')
     r = cmd.get_idtf()
     self.assertTrue(isinstance(r, tuple))
     self.assertEqual(len(r), 2)
     self.assertTrue(r[0].startswith('FILE_FORMAT "IDTF"'))
     self.assertTrue('MODEL_POSITION_LIST' in r[1])
     self.assertTrue('MODEL_NORMAL_LIST' in r[1])
Exemplo n.º 44
0
 def launchPyMol(self, pdbfile):
     """Open pdb in PyMOL"""
     import pymol
     # Call the function below before using any PyMOL modules.
     pymol.finish_launching()
     from pymol import cmd
     cmd.load(pdbfile)
     cmd.show_as('sticks')
     return
def colour_by_heatmap(colour_data,
                      structure_path,
                      molecule_name="protein",
                      output_path="colour_by_heatmap",
                      view=None):
    '''
DESCRIPTION

    Colours PDB structure by colour map data.
    output_filepath
    >>> colour_by_heatmap(df, structure_filepath="xxxx.pdb", mol_name="protein", out_dir='.')
    '''

    # if not (isinstance(colour_data, pd.core.series.Series) or isinstance(colour_data, dict)):
    #     print('''
    #             Passed data must be either dictionary or Pandas Series object.
    #             Key = residue number
    #             Value = PyMOL hex code
    #             ''')
    #     return None

    cmd.load(structure_path, object=molecule_name)

    # Set view
    if view == None:
        cmd.reset()
        cmd.orient()
    else:
        cmd.set_view(view)

    cmd.viewport(width=1200, height=1200)
    cmd.zoom(complete=1)

    cmd.set('cartoon_discrete_colors', 1)
    cmd.set('sphere_scale', 1)

    cmd.show_as('cartoon', molecule_name)
    cmd.color('white', molecule_name)

    # Iterate over the alpha-carbons
    # residue_numbers = []
    # cmd.iterate('{} and name CA'.format(molecule_name) , 'residue_numbers.append(resi)')

    # Colour the structure
    for residue_number in colour_data.columns:
        # print(colour_data[residue_number].item())
        cmd.color(colour_data[residue_number].item(),
                  '{0} and resi {1}'.format(molecule_name, residue_number))

    png_out_path = output_path + ".png"
    pse_out_path = output_path + ".pse"

    cmd.save(pse_out_path)

    cmd.set('ray_opaque_background', 0)
    cmd.png(png_out_path, width=1200, height=1200, ray=1, quiet=0)
Exemplo n.º 46
0
def Mutagenesis(kinase1, model, template,peptide_instance):
    """superposition the model and template, remove template and leave peptide behind """

    """replace peptide with instance peptide"""
    list_name = peptide_instance
    with open(input_data_folder+list_name,'r') as f:
        instances = f.readlines()
    instance = [x.strip() for x in instances]
    print "your peptide: ", instance 
    
    for pep in instance:
        cmd.delete('all')
        cmd.fetch(model)  # model_candidate, ex.chk1,chk2...
        cmd.remove("hetatm") #remove the nonstandard residues
        cmd.fetch(template)  #mutagenesis template, ex.2phk
        peptide_template = cmd.get_fastastr( "/"+template+'//B') #get the peptide from the template and generate another one for mutagenesis 
        peptide_template = peptide_template + 'G' #peptide of 2phk is 7 amino acid long, when our input peptide is 8 aa, we need to plus one character
        
        
        for aa in peptide_template[6:].lower(): #creat template_peptide for mutagenesis

            cmd._alt(aa)
        
        
        firstaa = AAcode_1_to_3(peptide_template[6]) #translate template_peptide to 3 letter
        low_firstaa = firstaa[0].lower()

        cmd.alter(low_firstaa, 'chain = "B"') #select this template_peptide        
        cmd.show_as("cartoon")
        cmd.align(model, template) #superpostion of model and template
        cmd.align(low_firstaa,template) #superpostion of template_peptide and template

        remove_part = "("+template+" and not resn ATP"+")" 
        cmd.select("remove_part",remove_part) 

        
        cmd.remove("remove_part") #remove the template except for ATP, there are only model and template_peptide
        cmd.remove("resn hoh") #remove water
        cmd.wizard("mutagenesis")
        peptide_position = 0

        for i in pep:
            #the peptide_position starting point depends the first position of mutagenesis peptide
            #pymol's peptide start from 1, not 0
            mutagenesis_template = '/'+low_firstaa+ '///' + str(peptide_position + 2) # because of 2phk start at 2nd of peptide
            #mutagenesis_template = '/' + template + '//B/' + str(peptide_position + 2)
            cmd.get_wizard().do_select(mutagenesis_template)  # select peptide position of mutation
            replace_aminoacid = AAcode_1_to_3(pep)[peptide_position]
            cmd.get_wizard().set_mode(replace_aminoacid)  # select which residue want to mutate to
            cmd.get_wizard().apply()
            peptide_position += 1
        filename = kinase1 + '_' + model + 'model_' + template + 'muta_' + pep + '.pdb' #build the canonical name
        cmd.save(filename)
        ATPchange(filename) #change ATP naming to the format of ATP.params
    cmd.wizard(None)
    return
Exemplo n.º 47
0
 def testGetVrml(self):
     cmd.fragment('gly')
     cmd.show_as('sticks')
     s = cmd.get_vrml()
     self.assertTrue(s.startswith('#VRML V'))
     self.assertTrue('geometry Cylinder' in s)
     cmd.show_as('spheres')
     s = cmd.get_vrml()
     self.assertFalse('geometry Cylinder' in s)
     self.assertTrue('geometry Sphere' in s)
Exemplo n.º 48
0
 def testSTL(self):
     cmd.fragment('gly')
     for rep in ['spheres', 'sticks', 'surface']:
         cmd.show_as(rep)
         with testing.mktemp('.stl') as filename:
             cmd.save(filename)
             contents = file_get_contents(filename, 'rb')
             # 80 bytes header
             # 4 bytes (uint32) number of triangles
             self.assertTrue(len(contents) > 84)
Exemplo n.º 49
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])
Exemplo n.º 50
0
 def _testSpectrum_setup(self):
     cmd.pseudoatom('m1', pos=(-2,0,0))
     cmd.pseudoatom('m2', pos=(0,0,0))
     cmd.pseudoatom('m3', pos=(2,0,0))
     cmd.show_as('spheres')
     cmd.set('ambient', 1)
     cmd.set('specular', 0)
     cmd.set('reflect', 0)
     cmd.set('direct', 0)
     cmd.viewport(40,20)
     cmd.zoom()
Exemplo n.º 51
0
 def testSpheresForSpheroidTrajectory(self, use_shader):
     pdbfile = self.datafile("sampletrajectory.pdb")
     dcdfile = self.datafile("sampletrajectory.dcd")
     cmd.load(pdbfile)
     cmd.load_traj(dcdfile)
     cmd.set('use_shaders', use_shader)
     cmd.spheroid("sampletrajectory", 3)
     self.ambientOnly()
     cmd.color('blue')
     cmd.show_as('spheres')
     self.assertImageHasColor('blue')
Exemplo n.º 52
0
    def _load_example(self):
        # object in hidden group
        cmd.fragment('ile', 'm1')
        cmd.fragment('his', 'm2')
        cmd.group('g1', 'm1')
        cmd.disable('g1')

        # testable styling
        self.ambientOnly()
        cmd.orient()
        cmd.color('red', 'm1')
        cmd.color('blue', 'm2')
        cmd.show_as('spheres')
def InitPymol():
    '''
    setup pymol so that it works right and plays nice with this program
    '''
    import pymol
    pymol.pymol_argv = ['pymol', '-q'] #c=command line (no gui), q=quiet (no messages)
    pymol.finish_launching()
    from pymol import cmd
    for switchon in ['retain_order','pdb_no_end_record','cartoon_cylindrical_helices']: #'pdb_retain_ids',
        cmd.set(switchon, 1)
    for switchoff in ['pdb_use_ter_records']:
        cmd.set(switchoff, 0)
    cmd.show_as('cartoon')
Exemplo n.º 54
0
    def test(self, ribbon_as_cylinders):
        cmd.set('ribbon_as_cylinders', ribbon_as_cylinders)
        cmd.set('ribbon_width', 8)
        cmd.fab('AG')
        cmd.color('red', 'resn ALA')
        cmd.color('blue', 'resn GLY')
        cmd.show_as('ribbon')
        cmd.orient()

        self.ambientOnly()
        cmd.viewport(100, 100)
        cmd.draw(100, 100)
        img = self.get_imagearray()
        self.assertImageHasColor('red', img)
        self.assertImageHasColor('blue', img)
Exemplo n.º 55
0
    def testAsyncBuilds(self, rep, async_builds):
        target = "1aon"
        if async_builds:
            msg = '%s cpus' % max_threads
        else:
            msg = '1 cpu'
        cmd.set("async_builds", async_builds)
    
        cmd.load(self.datafile('1aon.pdb.gz'), target)
        for x in cmd.get_chains():
            cmd.create("Chain_%s" % x, target + " & c. " + x)
        cmd.delete(target)

        with self.timing('%s' % msg):
            cmd.show_as(rep)
            cmd.draw()
Exemplo n.º 56
0
def disp_ball_stick( selection='all' , hydrogens=0, only=False):
    '''
DESCRIPTION

    Formats the passed object into ball and stick

USEAGE

    disp_ball_stick [ selection [, hydrogens [, only ]]]

EXAMPLE

    fetch 1hpv, async=0
    disp_ball_stick
    util.cbaw

PARAMETERS

    NAME=DEFAULT       TYPE    FUNCTION
    selection='all'    <str>   input selection
    hydrogens          <int>   -1: remove; 1: add; else: as is
    only=False         <bool>  if True will use show_as; else show

    '''
    try:
        selection='('+selection+')'
        hydrogens=int(hydrogens)
        only=bool(str(only)!='False')
    except:
        print "Input error"
        return False

    if hydrogens==1:
        cmd.h_add('%s' %selection)
    if hydrogens==-1:
        cmd.remove('%s and elem H' %selection)
  
    for p in cmd.get_object_list(selection):
        cmd.set('valence', 'on', p)
        cmd.set('stick_ball', 'on', p)
        cmd.set('stick_ball_ratio', 3, p)
        cmd.set('stick_radius', 0.12, p)

    if only:
        cmd.show_as('sticks', '%s' %(selection))
    else:
        cmd.show('sticks', '%s' %(selection))