コード例 #1
0
def spl(arg=''):
    """
    action='', name=''
    """
    if ' ' in arg:
        action, name = arg.split()
        name = name.lower()
    else:
        action = arg
        name = ''
    #import pandas as pd
    #df = pd.read_excel("/home/magnus/Desktop/pyMoL_colors-EMX.xlsx")
    if not action or action == 'help':
        spl_help()
    elif action == 'color' or arg == 'c':
        code_for_color_spl.spl_color()
        code_for_color_spl_objects.spl_color()
    elif arg == 'extract all' or arg == 'e':
        code_for_spl.spl_extract()
    elif arg == 'align' or arg == 'a':
        cmd.do("""
    align /5gm6//6, /5lj3//V;
    align /5mps//6, /5lj3//V;
    align /6exn//6, /5lj3//V;
    align /5y88//D, /5lj3//V;
    align /5ylz//D, /5lj3//V;
    """)
    else:
        spl_help()
コード例 #2
0
def mutate_peptide( new_seq ):
    '''
    mutate peptide to new_seq starting at second residue in the peptide
    '''

    cmd.copy(new_seq, "peptide_template")

    aa1 = list("ACDEFGHIKLMNPQRSTVWY")
    aa3 = "ALA CYS ASP GLU PHE GLY HIS ILE LYS LEU MET ASN PRO GLN ARG SER THR VAL TRP TYR".split()
    aa123 = dict(zip(aa1,aa3))

    for ind, aa in enumerate(new_seq,2):
	
        cmd.wizard("mutagenesis")
        cmd.do("refresh_wizard")
	print ind
	print aa
        # lets mutate residue 104 to GLN
        cmd.get_wizard().set_mode(aa123[aa])
        cmd.get_wizard().do_select("/{0}//B/{1}".format(new_seq, ind))
        # Select the rotamer
        #cmd.frame(1)

        # Apply the mutation
        cmd.get_wizard().apply()
コード例 #3
0
def main():
    #check wheter environment variables for output are set:
    if not MOVIE_MAKER_PATH:
        raise argparse.ArgumentError(
            "environment variable MOVIE_MAKER_PATH not set, got '%s' instead. Please set MOVIE_MAKER_PATH with directory of this script."
            % MOVIE_MAKER_PATH)
    if not MOVIE_SCRIPT_FILENAME:
        raise argparse.ArgumentError(
            "environment variable MOVIE_SCRIPT_FILENAME not set, got '%s' instead."
            % MOVIE_SCRIPT_FILENAME)
    if not POLAR_INTERACTIONS_FILENAME:
        raise argparse.ArgumentError(
            "environment variable POLAR_INTERACTIONS_FILENAME not set, got '%s' instead."
            % POLAR_INTERACTIONS_FILENAME)

    # run all script components
    commandline_options = parse_commandline_options()
    settings_dict = apply_settings(commandline_options)
    create_selections(settings_dict)
    create_views(settings_dict)
    movie_script_file_path = "%smovie_maker_basic_script.pml" % MOVIE_MAKER_PATH

    #create scenes and frames for movie
    print("create scenes and frames for movie in %s:" % movie_script_file_path)
    generate_movie_script(options=settings_dict,
                          filepath=movie_script_file_path)
    # execute a pymol script with @
    cmd.do("@%s" % movie_script_file_path)
    #Save session
    cmd.save("basic_movie.pse")
コード例 #4
0
	def myalign(method):
		newmobile = cmd.get_unused_name(mobile_obj + '_' + method)
		cmd.create(newmobile, mobile_obj)
		start = time.time()
		cmd.do('%s mobile=%s in %s, target=%s' % (method, newmobile, mobile, target))
		if not quiet:
			print 'Finished: %s (%.2f sec)' % (method, time.time() - start)
コード例 #5
0
ファイル: data2bfactor.py プロジェクト: willsheffler/lib
def data2q_res(mol='',data_file=''):
  """
  usage: data2q_res <mol>, <data_file>

  where <mol> is the molecular object whose occupancy data you wish to modify
  and <data_file> is a file contain the data (one value for each residue)
  The format of <data_file> should be:

     chain resnum resname data
  or
     resnum resname data

  (i.e. "chain" is optional). Lines beginning with '#' are ignored as comments.  
  """
#  call the function to extract the data per residue from 'data_file'
#  alter 'mol' with it.

  from pymol import cmd

  # read the data file and extract the 
  # data to the q_dict and res_dict dictionaries
  q_dict,res_dict = residue_data_extract(data_file)

  # make lists of chains and residues within the chains and sort them
  chain_list = q_dict.keys()
  chain_list.sort()
  for chain in chain_list:
    res_list = q_dict[chain].keys()
    res_list.sort()
    # now do the alteration of the occupancy (q) data
    for resnum in res_list:
      cmd.do("alter /%s//%s/%s/,q=%f" % (mol,chain,resnum,q_dict[chain][resnum]))

    # force a rebuild of the drawing
    cmd.rebuild()
コード例 #6
0
ファイル: stereodemo.py プロジェクト: evonove/pymol
    def medchem(self,cleanup=0):
	if not cleanup:
	    cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/drugdisc.pse"))
	    cmd.set("use_display_lists",0)
	    cmd.do("replace_wizard toggle, Medicinal Chemistry")
	else:
	    cmd.set("sphere_scale",1.0)
コード例 #7
0
def data2q_res(mol='',data_file=''):
  """
  usage: data2q_res <mol>, <data_file>

  where <mol> is the molecular object whose occupancy data you wish to modify
  and <data_file> is a file contain the data (one value for each residue)
  The format of <data_file> should be:

     chain resnum resname data
  or
     resnum resname data

  (i.e. "chain" is optional). Lines beginning with '#' are ignored as comments.  
  """
#  call the function to extract the data per residue from 'data_file'
#  alter 'mol' with it.

  from pymol import cmd

  # read the data file and extract the 
  # data to the q_dict and res_dict dictionaries
  q_dict,res_dict = residue_data_extract(data_file)

  # make lists of chains and residues within the chains and sort them
  chain_list = q_dict.keys()
  chain_list.sort()
  for chain in chain_list:
    res_list = q_dict[chain].keys()
    res_list.sort()
    # now do the alteration of the occupancy (q) data
    for resnum in res_list:
      cmd.do("alter /%s//%s/%s/,q=%f" % (mol,chain,resnum,q_dict[chain][resnum]))

    # force a rebuild of the drawing
    cmd.rebuild()
コード例 #8
0
    def sculpt(self, cleanup=0):
        if not cleanup:
            cmd.set("suspend_updates", 1, quiet=1)
            cmd.disable()
            cmd.delete("sculpt")
            cmd.set("sphere_scale", "1.0")
            cmd.set("sphere_mode", 5)
            cmd.load("$PYMOL_DATA/demo/pept.pdb", "sculpt")
            cmd.hide("lines", "sculpt")
            #            cmd.show("sticks","sculpt")
            cmd.show("spheres", "sculpt")
            #            cmd.set("sphere_transparency","0.75","sculpt")
            #            cmd.set("sphere_color","grey","sculpt")
            cmd.frame(1)
            cmd.set("auto_sculpt", 1)
            cmd.set("sculpting", 1)
            cmd.sculpt_activate("sculpt")
            cmd.set("sculpting_cycles", "100")
            cmd.do("edit_mode")
            cmd.set("valence", "0.05")
            cmd.set("suspend_updates", 0, quiet=0)
            cmd.sculpt_iterate("sculpt")
            cmd.alter_state(1, "sculpt", "x=x*1.5;y=y*0.1;z=z*1.5")
            cmd.zoom()

            cmd.unpick()
        else:
            cmd.set("valence", "0")
            cmd.set("sculpting", 0)
            cmd.set("auto_sculpt", 0)
            cmd.delete("sculpt")
            cmd.mouse()
コード例 #9
0
    def sculpt(self,cleanup=0):
        if not cleanup:
            cmd.set("suspend_updates",1,quiet=1)
            cmd.disable()
            cmd.delete("sculpt")
            cmd.set("sphere_scale","1.0")
            cmd.set("sphere_mode",5)
            cmd.load("$PYMOL_DATA/demo/pept.pdb","sculpt")
            cmd.hide("lines","sculpt")
#            cmd.show("sticks","sculpt")
            cmd.show("spheres","sculpt")
#            cmd.set("sphere_transparency","0.75","sculpt")
#            cmd.set("sphere_color","grey","sculpt")
            cmd.frame(1)
            cmd.set("auto_sculpt",1)
            cmd.set("sculpting",1)
            cmd.sculpt_activate("sculpt")
            cmd.set("sculpting_cycles","100")
            cmd.do("edit_mode")
            cmd.set("valence","0.05")
            cmd.set("suspend_updates",0,quiet=0)
            cmd.sculpt_iterate("sculpt")
            cmd.alter_state(1,"sculpt","x=x*1.5;y=y*0.1;z=z*1.5")
            cmd.zoom()

            cmd.unpick()
        else:
            cmd.set("valence","0")
            cmd.set("sculpting",0)
            cmd.set("auto_sculpt",0)
            cmd.delete("sculpt")
            cmd.mouse()
コード例 #10
0
 def electro(self,cleanup=0):
     if not cleanup:
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/electro.pse"))
         cmd.do("replace_wizard toggle, Computational Chemistry (Electrostatics)")
         cmd.rock(1)
     else:
         cmd.rock(0)
コード例 #11
0
 def electro(self,cleanup=0):
     if not cleanup:
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/electro.pse"))
         cmd.do("replace_wizard toggle, Computational Chemistry (Electrostatics)")
         cmd.rock(1)
     else:
         cmd.rock(0)
コード例 #12
0
def __spl_color():
    for m in mapping:
        protein = m[0]
        chain = m[1]
        color = m[2]
        print('\_' + ' '.join([protein, chain, color]))
        cmd.do('color ' + color + ', chain ' + chain)
コード例 #13
0
def resicolor(selection='all'):
 
    '''USAGE: resicolor <selection>
    colors all or the given selection with arbitrary
    coloring scheme.
    '''
    cmd.select ('calcium','resn ca or resn cal')
    cmd.select ('acid','resn asp or resn glu or resn cgu')
    cmd.select ('basic','resn arg or resn lys or resn his')
    cmd.select ('nonpolar','resn met or resn phe or resn pro or resn trp or resn val or resn leu or resn ile or resn ala')
    cmd.select ('polar','resn ser or resn thr or resn asn or resn gln or resn tyr')
    cmd.select ('cys','resn cys or resn cyx')
    cmd.select ('backbone','name ca or name n or name c or name o')
    cmd.select ('none')
 
    print selection
    code={'acid'    :  'red'    ,
          'basic'   :  'blue'   ,
          'nonpolar':  'orange' ,
          'polar'   :  'green'  ,
          'cys'     :  'yellow'}
    cmd.select ('none')
    for elem in code:
        line='color '+code[elem]+','+elem+'&'+selection
        print line
        cmd.do (line)
    word='color white,backbone &'+selection
    print word
    cmd.do (word)                  #Used to be in code, but looks like
                                   #dictionnaries are accessed at random
    cmd.hide ('everything','resn HOH')
コード例 #14
0
ファイル: Cycler.py プロジェクト: jackyzhao010/pymol_scripts
    def iter(self, by=1):
        loaded = cmd.get_names('objects')[0]
        choices = self.choices()
        l = len(choices)
        next_file = 0
        next_file_index = 0
        for i in range(l):
            if objname(choices[i]) == loaded:
                next_file_index = (i + by) % l
                next_file = choices[(i + by) % l]
                break
        cmd.delete('all')
        if not os.path.exists(next_file):
            raise ValueError("Can not locate file: %s" % next)
        cmd.load(next_file)
        if self.auto_zoom:
            cmd.zoom()

        if self.onload_command:
            logging.debug("onload_command: %s", self.onload_command)
            cmd.do(self.onload_command)

        #cmd.replace_wizard('message',next_file)
        # to display current pdb index, start at 1
        cmd.replace_wizard(
            'message', next_file + ", %d/%d" %
            (next_file_index + 1, l))  # +1, so the cycler starts at 1
コード例 #15
0
def de(pdbfile1="IL1B.atm",
       pdbfile2="MIM_tor.atm",
       charges=True,
       logscale=True,
       dielectric=80.,
       eps=0.1,
       handle=False):
    # extract names, and create the 'object' name in the pymol menu window
    print('22 apr 2020 add ability to save/restore poses')
    #pdbobj1 = pdbfile1[:-4]
    pdbobj1 = 'dockeye_prt'
    cmd.load(pdbfile1, pdbobj1)
    #pdbobj2 = pdbfile2[:-4]
    #cmd.load(pdbfile2, pdbobj2)
    #
    # Dockeye class reads pdb file upon init
    pdbobj2 = 'dockeye_lig'
    obj = Dockeye(pdbfile1, pdbfile2, pdbobj1, pdbobj2, charges, logscale,
                  dielectric, eps, handle)
    #
    # but pymol also loads first ligand model for display
    cmd.load('dockeye_lig.pdb', pdbobj2)
    os.system('/bin/rm -f dockeye_lig.pdb')
    # remove any previous temporary files
    os.system('/bin/rm -f dockeye_mark.*')
    os.system('/bin/rm -f dockeye_action')
    cmd.zoom()
    cmd.do("set auto_zoom, off", echo=0)
    name = 'dockeye'
    cmd.load_callback(obj, name)
    return obj
コード例 #16
0
def resicolor(selection='all', scale=False):
    '''USAGE: resicolor <selection>
    colors all or the given selection with arbitrary
    coloring scheme.
    '''
    cmd.select('calcium', 'resn ca or resn cal')
    cmd.select('acid', 'resn asp or resn glu or resn cgu')
    cmd.select('basic', 'resn arg or resn lys or resn his')
    cmd.select(
        'nonpolar',
        'resn met or resn phe or resn pro or resn trp or resn val or resn leu or resn ile or resn ala'
    )
    cmd.select('polar',
               'resn ser or resn thr or resn asn or resn gln or resn tyr')
    cmd.select('cys', 'resn cys or resn cyx')
    cmd.select('backbone', 'name ca or name n or name c or name o')
    cmd.select('none')

    code = {
        'acid': 'red',
        'basic': 'blue',
        'nonpolar': 'orange',
        'polar': 'green',
        'cys': 'yellow'
    }

    code2 = {'acid': 2, 'basic': 2, 'nonpolar': 4, 'polar': 2.5, 'cys': 3}

    for elem in code:
        line = 'color ' + code[elem] + ',' + elem + '&' + selection
        cmd.do(line)
        if scale:
            print(elem)
            cmd.set('sphere_scale', code2[elem], elem + '&' + selection)
    cmd.hide('everything', 'resn HOH')
コード例 #17
0
def _showpoc(pjid,pdbfile,pocfile):
    # Load the file
    cmd.load(pdbfile, pjid)
    with open(pocfile) as f:
        lines = f.readlines()
    
    pocdict = {}
    for line in lines:
        if not line.strip():
            continue
        atmid = line[6:11].strip()
        pocid = int(line[67:70].strip())
        if pocid not in pocdict:
            pocdict[pocid] = []
        pocdict[pocid].append(atmid)
    
    for pocid in sorted(pocdict.keys()):
        atomlist = pocdict[pocid]
        subsize = 20
        prefix = ''
        while len(atomlist)>0:
            sublist = atomlist[:min(subsize,len(atomlist))]
            atomlist = atomlist[min(subsize,len(atomlist)):]
            cmd.do("select {selid}, {prefix} id {sele},1,1".format(selid='Poc'+str(pocid).zfill(4), sele='+'.join(sublist), prefix=prefix))
            prefix = selid='Poc'+str(pocid).zfill(4) + ' or '
コード例 #18
0
ファイル: fitting.py プロジェクト: speleo3/pymol-psico
 def myalign(method):
     newmobile = cmd.get_unused_name(mobile_obj + '_' + method)
     cmd.create(newmobile, mobile_obj)
     start = time.time()
     cmd.do('%s mobile=%s in %s, target=%s' % (method, newmobile, mobile, target))
     if not quiet:
         print('Finished: %s (%.2f sec)' % (method, time.time() - start))
コード例 #19
0
ファイル: stereodemo.py プロジェクト: jchodera/pymol
    def medchem(self,cleanup=0):
	if not cleanup:
	    cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/drugdisc.pse"))
	    cmd.set("use_display_lists",0)
	    cmd.do("replace_wizard toggle, Medicinal Chemistry")
	else:
	    cmd.set("sphere_scale",1.0)
コード例 #20
0
def surfback(width,height,color="gray",showcartoon=True,dname=""):
    #if (cmd.get("bg_image_filename")==None):
    cmd.set("bg_image_filename",None)
    cmd.hide("")
    cmd.set("fog", 0)
    cmd.set("reflect", 0)
    cmd.set("ambient",1)
    cmd.set("ray_trace_mode", 0)
    cmd.show("surface")
    cmd.set("surface_color",color)
    cmd.set("spec_reflect",0)
    cmd.ray(width,height)
    # I want below to work with tmpdir but, it fails. So this script makes unwanted tmpfile to dir named as dname
    cmd.png(dname+"surf.png")
    cmd.do("ls " + dname)
    cmd.do("ls " + dname+"surf.png")
    #cmd.load_png(dname+"surf.png")
    time.sleep(0.01)
    cmd.set("bg_image_filename",dname+"surf.png")
    cmd.set("bg_image_mode",0)
    if (showcartoon):
        cmd.hide("")
        cmd.show("cartoon")
        cmd.color("white")
        cmd.set("ray_trace_mode", 3)
        cmd.set("ambient", 1)
        cmd.set("reflect",0)
        cmd.set("valence", 0)
        cmd.set("spec_reflect",0)
        cmd.set("ray_trace_color", "gray0")
    #cmd.ray(n,n)
    #cmd.png("/
    print("Ray your image in the same aspect ratio as you specified in surfback")
コード例 #21
0
def de(pdbfile1="IL1B.atm",
       pdbfile2="MIM_tor.atm",
       charges=True,
       logscale=True,
       dielectric=80.,
       eps=0.1):
    # extract names, and create the 'object' name in the pymol menu window
    #pdbobj1 = pdbfile1[:-4]
    pdbobj1 = 'dockeye_prt'
    cmd.load(pdbfile1, pdbobj1)
    #pdbobj2 = pdbfile2[:-4]
    #cmd.load(pdbfile2, pdbobj2)
    #
    # Dockeye class reads pdb file upon init
    pdbobj2 = 'dockeye_lig'
    obj = Dockeye(pdbfile1, pdbfile2, pdbobj1, pdbobj2, charges, logscale,
                  dielectric, eps)
    #
    # but pymol also loads first ligand model for display
    cmd.load('dockeye_lig.pdb', pdbobj2)
    os.system('rm -f dockeye_lig.pdb')
    cmd.zoom()
    cmd.do("set auto_zoom, off", echo=0)
    name = 'dockeye'
    cmd.load_callback(obj, name)
    return obj
コード例 #22
0
ファイル: DNAselections.py プロジェクト: asford/pymol-home
def DNA_selections(display='all'):
	bbatoms = 'name C2\*+C3\*+C4\*+C5\*+P+O3\*+O4\*+O5\*+O1P+O2P+H1\*+1H2\*+2H2\*+H3\*+H4\*+1H5\*+2H5\*+c2\'+c3\'+c4\'+c5\'+o3\'+o4\'+o5\'+op2+op1+h1\'+1h2\'+2h2\'+h3\'+h4\'+1h5\'+2h5\''
	waters = 'n. wo6+wn7+wn6+wn4+wo4 or r. hoh'
	cmd.select('DNA', 'r. g+a+c+t+gua+ade+cyt+thy+da+dc+dg+dt+5mc',enable=0)
	cmd.select('notDNA','not DNA',enable=0)
	cmd.select('DNAbases','DNA and not %s' % bbatoms ,enable=0)
	cmd.select('DNAbb','DNA and %s' % bbatoms ,enable=0)
	cmd.select('sc_base','byres notDNA w. 7 of DNAbases',enable=0)
	cmd.select('sc_base','sc_base and not n. c+n+o',enable=0)
	cmd.select('dna_h2o','%s w. 3.6 of DNAbases' %waters ,enable=0)
	cmd.set('sphere_transparency','0.5'); cmd.color('marine','dna_h2o')
	cmd.do('selectPolarProtons')
#	color_by_chains()
	cmd.color('gray','e. c')

	cmd.select('pbb','notDNA and n. c+n+ca',enable=0)

	if display != 'none':
		cmd.label('n. c1\*+c1\' and DNA','\'%s%s(%s)\' % (chain,resi,resn)')
		cmd.set('label_color','white')

	if display == 'all':
		# display things
		cmd.show('sticks','DNAbases or sc_base')
		cmd.show('ribbon','DNAbb')
		cmd.show('cartoon','notDNA')
		cmd.show('spheres','dna_h2o')
		cmd.hide('everything','e. h and not polar_protons')
コード例 #23
0
ファイル: PYMOL-3171.py プロジェクト: av-hub/pymol-testing
    def test(self):
        # basic
        stored.x = []
        cmd.do(
            'cmd.do("'
            '  stored.x.append(1);'
            '  stored.x.append(2)'
            '");'
            'stored.x.append(3)',
            echo=0)
        self.assertEqual(stored.x, [1, 2, 3])

        # extra level of nesting
        stored.x = []
        cmd.do(
            'cmd.do("'
            '  stored.x.append(1);'
            "  cmd.do('"
            '    stored.x.append(2);'
            '    stored.x.append(3)'
            "  ');"
            '  stored.x.append(4)'
            '");'
            'stored.x.append(5)',
            echo=0)
        self.assertEqual(stored.x, [1, 2, 3, 4, 5])
コード例 #24
0
def mutate_peptide(new_seq):
    '''
    mutate peptide to new_seq starting at second residue in the peptide
    '''

    cmd.copy(new_seq, "peptide_template")

    aa1 = list("ACDEFGHIKLMNPQRSTVWY")
    aa3 = "ALA CYS ASP GLU PHE GLY HIS ILE LYS LEU MET ASN PRO GLN ARG SER THR VAL TRP TYR".split(
    )
    aa123 = dict(zip(aa1, aa3))

    for ind, aa in enumerate(new_seq, 2):

        cmd.wizard("mutagenesis")
        cmd.do("refresh_wizard")
        print ind
        print aa
        # lets mutate residue 104 to GLN
        cmd.get_wizard().set_mode(aa123[aa])
        cmd.get_wizard().do_select("/{0}//B/{1}".format(new_seq, ind))
        # Select the rotamer
        #cmd.frame(1)

        # Apply the mutation
        cmd.get_wizard().apply()
コード例 #25
0
    def run():
        global dialog
        cmd.reinitialize()
        cmd.do('set retain_order,1')
        ErrorGenerated = 0
        # cmd.do('set pdb_retain_ids,1')
        # InfoArray = TabInfo()
        alpha = 0
        if form.Alignalpha.isChecked():
            alpha = 1
        nonidentical = 0
        if form.Nonchains.isChecked():
            nonidentical = 1
        try:
            files, UNK, cur_dir, pname = FileGeneration()
        except Exception as e:
            print("Error: please check input files.")
            ErrorGenerated = 1

            f2 = open('ErrorLog.txt', 'w')
            f2.write(str(e))
            f2.close()

        if ErrorGenerated == 0:
            files = natural_sort(files)
            CreateRMS(files, form.PDBCODE.text(), form.RMSCutoff.text(), UNK,
                      alpha, nonidentical, cur_dir, pname)
コード例 #26
0
 def testLog(self):
     with testing.mktemp('.pml') as logfile:
         cmd.log_open(logfile)
         cmd.do('_ color blue')
         cmd.log('hello world')
         cmd.log_close()
         lines = [_f for _f in map(str.strip, open(logfile)) if _f]
         self.assertEqual(lines, ['color blue', 'hello world'])
コード例 #27
0
def hot_spot_spheres(dist=4, sele='sele'):
    cmd.select('hot-spot', sele)
    cmd.select("sele", "(sele around " + str(dist) + ")", enable=1)
    cmd.show("spheres", 'sele')
    cmd.show("spheres", sele)
    cmd.show("spheres", "hot-spot")
    cmd.do('set sphere_transparency, 0.6, sele')
    cmd.select('around_hot-spot', 'sele')
コード例 #28
0
def remred():
    pdb_list = glob.glob("*.pdb")
    for pdb in pdb_list:
        cmd.load(pdb)
    cmd.run("/usr/local/bin/all_against_all.py")
    cmd.do(
        "align_all_to_all(selection='all',cutoff=0,cycles=0,full_matrix=1,method='align')"
    )
コード例 #29
0
 def testLog(self):
     with testing.mktemp('.pml') as logfile:
         cmd.log_open(logfile)
         cmd.do('_ color blue')
         cmd.log('hello world')
         cmd.log_close()
         lines = filter(None, map(str.strip, open(logfile)))
         self.assertEqual(lines, ['color blue', 'hello world'])
コード例 #30
0
ファイル: pmlrc.py プロジェクト: handreazz/Pawel_PhD_Scripts
def Run(filename):
    for Path in ['',
os.path.expanduser('~/c/scripts/pymol/')]:
        full = os.path.join(Path, filename)
        if os.path.exists(full):
            cmd.do('run ' + full)
            return
    print ' Error: no such file: {0}'.format(filename)
コード例 #31
0
ファイル: propka.py プロジェクト: 8848/Pymol-script-repo
def propka(molecule="NIL",chain="*",resi="0",resn="NIL",method="upload",logtime=time.strftime("%m%d",time.localtime()),server_wait=3.0,version="v3.1",verbose="no",showresult="no",pkafile="NIL",makebonds="yes"):
	Script_Version="20110823"
	### First we have to be sure, we give reasonable arguments
	if pkafile!="NIL":
		method='file'
	assert method in ['upload', 'file'], "'method' has to be either: method=upload or method=file"
	### If molecule="all", then try to get the last molecule
	##assert molecule not in ['NIL'], "You always have to provide molecule name. Example: molecule=4ins"
	if molecule=="NIL":
		assert len(cmd.get_names())!=0, "Did you forget to load a molecule? There are no objects in pymol."
		molecule=cmd.get_names()[-1]
	### To print out to screen for selected residues. Can be separated with "." or make ranges with "-". Example: resi="4-8.10"
	if resi != "0": resi_range = ResiRange(resi)
	else: resi_range=[]
	### Also works for residue names. They are all converted to bigger letters. Example: resn="cys.Tyr"
	if resn != "NIL": resn_range = ResnRange(resn)
	else: resn_range = resn
	### Make chain range, and upper case.
	chain = ChainRange(chain)
	### Make result directory. We also the absolut path to the new directory.
	Newdir = createdirs()
	if method=="upload":
		### We try to load mechanize. If this fail, one can always get the .pka file manual and the run: method=file
		try: from modules import mechanize; importedmechanize='yes'
		except ImportError: print("Import error. Is a module missing?"); print(sys.exc_info()); print("Look if missing module is in your python path\n%s")%sys.path;importedmechanize='no'; import modules.mechanize as mechanize
		### The name for the new molecule
		newmolecule = "%s%s"%(molecule,logtime)
		### Create the new molecule from original loaded and for the specified chains. Save it, and disable the old molecule.
		cmd.create("%s"%newmolecule, "%s and chain %s"%(molecule,chain))
		cmd.save("%s%s.pdb"%(Newdir,newmolecule), "%s"%newmolecule)
		cmd.disable("%s"%molecule)
		if molecule=="all": cmd.enable("%s"%molecule); cmd.show("cartoon", "%s"%molecule)
		### Let the new molecule be shown in cartoon.
		cmd.hide("everything", "%s"%newmolecule)
		cmd.show("cartoon", "%s"%newmolecule)
		### Make the absolut path to the newly created .pdb file.
		PDB="%s%s.pdb"%(Newdir,newmolecule);source="upload"; PDBID=""
		### Request server, and get the absolut path to the result file.
		pkafile = getpropka(PDB,chain,resi,resn,source,PDBID,logtime,server_wait,version,verbose,showresult)
		### Open the result file and put in into a handy list.
		list_results,ligands_results = importpropkaresult(pkafile)
	if method=="file":
		assert pkafile not in ['NIL'], "You have to provide path to file. Example: pkafile=./Results_propka/4ins_2011.pka"
		assert ".pka" in pkafile, 'The propka result file should end with ".pka" \nExample: pkafile=./Results_propka/4ins_2011.pka \npkafile=%s'%(pkafile)
		### The name for the molecule we pass to the writing script of pymol commands
		newmolecule = "%s"%molecule
		cmd.hide("everything", "%s"%newmolecule)
		cmd.show("cartoon", "%s"%newmolecule)
		### We open the result file we have got in the manual way and put in into a handy list.
		list_results,ligands_results = importpropkaresult(pkafile)
		### Then we print the interesting residues to the screen.
		printpropkaresult(list_results, resi, resi_range, resn, resn_range, showresult, ligands_results)
	### Now create the pymol command file. This should label the protein. We get back the absolut path to the file, so we can execute it.
	result_pka_pymol_name = writepymolcmd(newmolecule,pkafile,verbose,makebonds)
	### Now run our command file. But only if we are running pymol.
	if runningpymol=='yes': cmd.do("run %s"%result_pka_pymol_name)
	##if runningpymol=='yes': cmd.do("@%s"%result_pka_pymol_name)
	return(list_results)
コード例 #32
0
 def structure(self,cleanup=0):
     if not cleanup:
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/structure.pse"))
         cmd.do("replace_wizard toggle, Structure Alignment")
         cmd.set("seq_view_label_mode",1)
         cmd.set("seq_view",1)
     else:
         cmd.set("seq_view_label_mode",0)
         cmd.set("seq_view",0)
コード例 #33
0
 def structure(self,cleanup=0):
     if not cleanup:
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/structure.pse"))
         cmd.do("replace_wizard toggle, Structure Alignment")
         cmd.set("seq_view_label_mode",1)
         cmd.set("seq_view",1)
     else:
         cmd.set("seq_view_label_mode",0)
         cmd.set("seq_view",0)
コード例 #34
0
ファイル: CollabMol_Plugin.py プロジェクト: abryden/CollabMol
	def __init__(self):
		#self.bms = Bookmarks.Bookmarks()
		cmd.do("set label_color, yellow")
		cmd.do("set label_font_id, 4")
	#lock = allocate_lock()
		recievingThread = recieving_Thread()
		print "thread allocated"
		recievingThread.start()
		print "thread started"
コード例 #35
0
ファイル: pymol_util.py プロジェクト: mattragoza/liGAN
def mutate(protein, resi, mode='ALA', chain='A'):
    cmd.wizard('mutagenesis')
    cmd.do("refresh_wizard")
    cmd.get_wizard().set_mode(mode.upper())
    selection = f'/{protein}//{chain}/{resi}'
    cmd.get_wizard().do_select(selection)
    cmd.frame(str(1))
    cmd.get_wizard().apply()
    cmd.set_wizard('done')
    cmd.refresh()
コード例 #36
0
def show_chain_in_PDB(entry):
    PDB = entry[:4]
    chain = entry[-1:]
    cmd.reinitialize('everything')
    cmd.do('@~/.pymolrc')
    cmd.set("bg_rgb", "white")
    cmd.run("%s/strands_%s.py" % (PyMOL_script_dir, PDB))
    cmd.show("cartoon", "all")
    cmd.set("cartoon_transparency", .85, PDB)
    cmd.set("cartoon_transparency", 0.05, "%s_barrel" % PDB)
コード例 #37
0
def calcRMSD_pymol(uf, bf):
    """
    Given two pdb files of the same protein, this function calculates the
    rmsd, asa for each and the molecular weight of each using Pymol
    """
    # Call the function below before using any PyMOL modules.
    #time.sleep(random.random())
    cmd.set("dot_solvent", 1)
    cmd.load(uf)
    cmd.load(bf)
    #cmd.h_add()
    #cmd.remove('het')
    _, un, _ = getFileParts(uf)
    _, bn, _ = getFileParts(bf)
    asa_u = cmd.get_area(un)
    asa_b = cmd.get_area(bn)

    umass = cmd.get_model(un).get_mass()
    bmass = cmd.get_model(bn).get_mass()
    #rms=cmd.super(un,bn,transform=1)[0]
    #time.sleep(random.random())
    bv0 = []
    cmd.iterate('all', 'bv0.append(b)', space=locals())
    cmd.do('run colorbyrmsd.py; colorbyrmsd \'' + un + '\',\'' + bn +
           '\',guide = 0,doAlign=1, doPretty=1')
    while True:  # synchronization
        bv1 = []
        cmd.iterate('all', 'bv1.append(b)', space=locals())
        if bv0 != bv1:
            time.sleep(0.1)
            break

    out_file = tempfile.NamedTemporaryFile(suffix='.pdb')
    out_file.close()
    tmp_pdb = out_file.name
    updb = tmp_pdb + 'u'
    bpdb = tmp_pdb + 'b'
    cmd.save(updb, un)
    cmd.save(bpdb, bn)
    (_, uR, _, _, _) = readPDB(updb)
    urmsd = getBvalues(uR)
    os.remove(updb)
    (_, bR, _, _, _) = readPDB(bpdb)
    brmsd = getBvalues(bR)
    os.remove(bpdb)
    rms = np.sqrt(np.mean(
        np.array([v for V in urmsd for v in V if v >= 0])**2))
    #(_,urx,_,_,_)=readPDB(uf); ux=getBvalues(urx);
    #    if np.abs(rms-rmsd)>0.1:
    #        print "RMSD =",rms,rmsd
    #        pdb.set_trace()

    cmd.reinitialize()
    pdb.set_trace()
    return rms, asa_u, asa_b, umass, bmass, urmsd, brmsd
コード例 #38
0
def setup(obj):

    # Various set up
    pwd = os.getcwd()
    # print "os.getcwd()", os.getcwd()
    cmd.do("wizard mutagenesis")
    cmd.do("refresh_wizard")

    # Save residue names and numbers.
    orig_sequence = setNames(obj)
    # print orig_sequence

    # Keeping track of the mutations
    # Example: '42':  ['GLY', 'ASN', 'VAL', 'ALA']
    # Important: Trailing commata.
    all_side_chains = [
        "ALA",
        "ARG",
        "ASN",
        "ASP",
        "CYS",
        "GLU",
        "GLN",
        "GLY",
        "HIS",
        "ILE",
        "LEU",
        "LYS",
        "MET",
        "PHE",
        "PRO",
        "SER",
        "THR",
        "TRP",
        "TYR",
        "VAL",
    ]
    phe = ["PHE"]
    do_not_mutate = ["78", "172"]
    positions_in_selection = get_positions_in_selection(sub, distance)
    mutations = {}
    # mutations = {'115': all_side_chains}
    # mutations = {'115': ['ALA', 'SER']}
    for i in positions_in_selection:
        if i[0] not in do_not_mutate:
            mutations[i[0]] = []
            # Prevent mutating from WT to WT.
            # for mut in all_side_chains:
            for mut in phe:
                if i[1] != mut:
                    mutations[i[0]].append(mut)
    # for i in mutations.keys():
    #    print i, mutations[i]
    return pwd, mutations, orig_sequence
コード例 #39
0
def mutate(molecule, chain, resi, target="CYS", mutframe="1"):
    target = target.upper()
    cmd.wizard("mutagenesis")
    cmd.do("refresh_wizard")
    cmd.get_wizard().set_mode("%s" % target)
    selection = "/%s//%s/%s" % (molecule, chain, resi)
    cmd.get_wizard().do_select(selection)
    cmd.frame(str(mutframe))
    cmd.get_wizard().apply()
    # cmd.set_wizard("done")
    cmd.set_wizard()
コード例 #40
0
    def fingerprint():
        cmd.reinitialize()
        cmd.do('set retain_order,1')
        ErrorGenerated = 0

        AnyChecked = 0
        IText = []

        if form.SPLIF.isChecked():
            IText.append("SPLIF")
            AnyChecked = 1

        if form.Simple_Interaction.isChecked() or AnyChecked == 0:
            IText.append("SInteraction")

        TextInteraction = 0
        if form.Prox_check.isChecked():
            TextInteraction = 1

        FP_SI = form.FP_SICutoff.text()
        FP_SPLIF = form.FP_SPLIFCutoff.text()

        try:
            files, UNK, cur_dir, pname = FileGeneration()
        except Exception as e:
            print("Error: please check file inputs.")
            ErrorGenerated = 1

            f2 = open('ErrorLog.txt', 'w')
            f2.write(str(e))
            f2.close()

        if ErrorGenerated == 0:
            files = natural_sort(files)
            try:
                Fingerprint_Wrapper(files, IText, form.PDBCODE.text(), FP_SI,
                                    FP_SPLIF, TextInteraction, cur_dir, pname)
            except Exception as e:
                print(
                    "Error with fingerprint generation. Please check input files, required packages (specifically ODDT and rdkit builds"
                    " specified in installation), then try again.")

                f2 = open('ErrorLog.txt', 'w')
                f2.write(str(e))
                f2.close()

        form.dir_select.setText("")
        form.file_select.setText("")
        form.PDBCODE.setText("")
        form.Ligandkeyword.setText("")
        form.file_select.setText("")
        form.crystal_structure.setText("")
        form.complexid.setText("")
        form.resInput.setText("")
コード例 #41
0
 def electomo(self,cleanup=0):
     if not cleanup:
         cmd.feedback("disable","objectsurface","actions")
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/flagellar.pse"))
         cmd.set("sweep_mode",3)
         cmd.set("sweep_angle",3)
         cmd.rock()
         cmd.do("replace_wizard toggle, Electron Tomography")
     else:
         cmd.mstop()
         cmd.rock(0)
コード例 #42
0
def mutate(molecule,chain,resi,target="CYS",mutframe="1"):
	target = target.upper()
	cmd.wizard("mutagenesis")
	cmd.do("refresh_wizard")
	cmd.get_wizard().set_mode("%s"%target)
	selection="/%s//%s/%s"%(molecule,chain,resi)
	cmd.get_wizard().do_select(selection)
	cmd.frame(str(mutframe))
	cmd.get_wizard().apply()
	#cmd.set_wizard("done")
	cmd.set_wizard()
コード例 #43
0
 def electomo(self,cleanup=0):
     if not cleanup:
         cmd.feedback("disable","objectsurface","actions")
         cmd.set_session(self.get_sess("$PYMOL_DATA/big_demo/flagellar.pse"))
         cmd.set("sweep_mode",3)
         cmd.set("sweep_angle",3)
         cmd.rock()
         cmd.do("replace_wizard toggle, Electron Tomography")
     else:
         cmd.mstop()
         cmd.rock(0)
コード例 #44
0
    def clearH(self):
        if reduceExe:
            seles = self.h_sel.getvalue()
            seleStr = " or ".join(seles)

            if seleStr:
                cmd.do('remove (hydro and (' + seleStr + '))')
            else:
                print 'Could not find selection'
        else:
            print reduceError
コード例 #45
0
def setup(obj):

    # Various set up
    pwd = os.getcwd() 
    #print "os.getcwd()", os.getcwd()
    cmd.do('wizard mutagenesis')
    cmd.do('refresh_wizard')

    # Save residue names and numbers.
    orig_sequence = setNames(obj)
    return pwd, orig_sequence
コード例 #46
0
ファイル: util.py プロジェクト: jonathaw/fleishman_pymol
def alignall(sel="", obj=None):
    l = cmd.get_object_list()
    if not obj: obj = l[0]
    if obj not in l:
        print "ERROR object", obj, "not found!!!"
        return
    for o in l:
        if o == obj: continue
        cmd.do("align " + o + " and (" + sel + ")," + obj + " and (" + sel +
               ")")
    return
コード例 #47
0
def convert_that_file_mol(file):
    'Takes a chemical structure file and uses pymol to save it as a mol file'
    try:
        print "Reading %s to convert to mol format \n" %file
        path = os.path.abspath(file)
        name = path.split('/')[-1].split('.')[0]

        cmd.load(file)
        cmd.save("%s.mol" %name,name)
        cmd.do("reinitialize")
    except:
        print "I can't open pymol or convert the file"
コード例 #48
0
ファイル: pymol_util.py プロジェクト: willsheffler/lib
def alignall(sel="all", obj=None):
    l = cmd.get_object_list()
    if not obj:
        obj = l[0]
    if obj not in l:
        print "ERROR object", obj, "not found!!!"
        return
    for o in l:
        if o == obj:
            continue
        cmd.do("align " + o + " and (" + sel + "), " + obj + " and (" + sel + ")")
    return
コード例 #49
0
ファイル: ex.py プロジェクト: JiankunLyu/Pymol-script-repo
def ex(filename=''):
    if os.path.splitext(filename)[1] == '':
        filename = os.path.splitext(filename)[0] + '.pml'
        print(("filename is: %s" % filename))
    if 'PYMOL_GIT_EX' in os.environ:
        expath = os.environ['PYMOL_GIT_EX']
        cmdrun = os.path.join(expath, filename)
        cmd.do("@%s" % cmdrun)
    else:
        cmdrun = filename
        cmd.do("@%s" % cmdrun)
    return(cmdrun)
コード例 #50
0
def setNames(obj):
    orig_sequence = {}
    cmd.load(obj)
    cmd.select("prot", "name ca")
    cmd.do("stored.names = []")
    cmd.do("iterate (prot), stored.names.append((resi, resn))")
    for i in stored.names:
        orig_sequence[i[0]] = i[1]
    # Now in 'get_all_positions_in_selection'
    # cmd.do('delete all')
    # print stored.names
    return orig_sequence
コード例 #51
0
ファイル: stride_ss.py プロジェクト: willsheffler/lib
def stride2pymol(mol='',sel=''):
  """
  usage: stride2pymol object, [selection]

  where the object name is required, but the selection is optional 
  (defaults to all of the object).  
  
  e.g. stride2pymol prot, i. 1-300 and c. a
  """
  #Save the specified molecule (and optional selection sel) to a temporary 
  #PDB format file and call stride_extract on it

  from pymol import cmd

  # map stride's secondary structure alphabet onto pymol's
  # strides definitions:
  # G = 3/10 helix
  # B = Bridge
  # C = coil
  # T = turn
  # H = helix
  # E = strand/sheet

  # create tmpfile from the selection name and the current time in seconds since the epoch
  ext = str(int(time.time()))
  tmpfile=mol + '.pdb_' + ext
  if sel:
    # make sure that selection forces the molecule name to be included in the selection
    # (i.e. is 'and'-ed with the rest of the selection)
    sel = mol + ' and ' + sel
    cmd.save(tmpfile,sel,1,'pdb')
  else:
    cmd.save(tmpfile,mol,1,'pdb')
  # run stride on the saved pdb file and read the standard output to extract the 
  # data to the sec_dict and res_dict dictionaries
  sec_dict,res_dict = stride_extract(tmpfile)
  os.remove(tmpfile)

  # make lists of chains and residues within the chains and sort them
  chain_list = sec_dict.keys()
  chain_list.sort()
  for chain in chain_list:
    res_list = sec_dict[chain].keys()
    res_list.sort()
    # now do the alteration of the secondary structure.
    for resnum in res_list:
      cmd.do("alter /%s//%s/%s,ss='%s'" % (mol,chain,resnum,stride_2_pymol[sec_dict[chain][resnum]]))

    # make sure that cartoon automatic is set for this molecule
    cmd.cartoon('automatic',mol)
    # force a rebuild of the drawing
    cmd.rebuild()
コード例 #52
0
ファイル: vsc-set.py プロジェクト: mzhKU/Enzyme-Screening
def set_names(obj):
    """
    Return dictionary of {resi:resn} pairs.
    Loaded object is deleted in 'get_all_positions_in_selection'.
    """
    orig_sequence = {}
    cmd.load(obj) 
    cmd.select("prot", "name ca")
    cmd.do("stored.names = []")
    cmd.do("iterate (prot), stored.names.append((resi, resn))")
    for i in stored.names:
        orig_sequence[i[0]] = i[1] 
    return orig_sequence
コード例 #53
0
    def _gpssLoadPdb(pdbCode,reinitialize):

        pdbCode = pdbCode.lower()
        
        GPSSpdbCode = 'GPSS_' + pdbCode

        _gpssVersionCheck('0.3');

        if cmd.get_names().count(GPSSpdbCode) < 1:
                
            if reinitialize==1:
                cmd.do('reinitialize')
                
            pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                      'gpssServerPymol.php?pdbId='+
                                      pdbCode + '&mode=pdbFile').read()
            
            
            if pdbFile:
                pdbFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                          'gpssServerPymol.php?pdbId='+
                                          pdbCode + '&mode=pdbFile')
                cmd.read_pdbstr(pdbFile.read(),GPSSpdbCode)
            
                # Make structure pretty
                # David Borhani, 14-JAN-2009
                # Changed to color by chain, show lines only, keep user's bg color.
                #cmd.do('set bg_rgb=[1,1,1]')
                #cmd.do('hide everything')
                cmd.hide('everything', GPSSpdbCode)
                #cmd.do('dss')
                cmd.dss(GPSSpdbCode)
                #util.cbc(selection='(GPSS-' + pdbCode + ')',first_color=7,quiet=1,legacy=1,_self=cmd)
                #sel_string = '("' + GPSSpdbCode + '")'
                #cmd.do('util.cbc(selection=' + sel_string + ',first_color=9,quiet=1,legacy=1)')
                cmd.do('util.cbc(selection=("' + GPSSpdbCode + '"),first_color=9,quiet=1,legacy=1)')
                #cmd.do('show lines, ' + GPSSpdbCode)
                cmd.show('lines', GPSSpdbCode)
                #cmd.do('show cartoon, ' + GPSSpdbCode)
                #cmd.do('color gray')
                return True
            else:
                tkMessageBox.showerror('GPSS                                    ',
                                       pdbCode + ' was not found on the GPSS server.')

            #cmd.do('zoom GPSS-'+pdbCode)
            cmd.zoom(GPSSpdbCode, animate=0)

        else:

            return True
コード例 #54
0
    def gpssPeptide(pdbCode, reinitialize):

        if _gpssLoadPdb(pdbCode, reinitialize):

            # Get ligand surfaces
            peptideInfo = urllib2.urlopen(
                "http://gpss.mcsg.anl.gov/webservices/" + "gpssServerPymol.php?pdbId=" + pdbCode + "&mode=peptideInfo"
            )
            # Get pocket atoms
            for peptideSurface in peptideInfo:
                peptideSurfaceFile = urllib2.urlopen(
                    "http://gpss.mcsg.anl.gov/webservices/"
                    + "gpssServerPymol.php?pdbId="
                    + pdbCode
                    + "&surfaceId="
                    + peptideSurface
                    + "&mode=peptideSurface"
                )
                peptideId = peptideSurface.split(".")
                objectId = "Peptide-" + peptideId[1]
                cmd.read_pdbstr(peptideSurfaceFile.read(), objectId)
                cmd.do("hide everything," + objectId)
                cmd.do("show surface," + objectId)
                cmd.do("set transparency=0.2," + objectId)
            cmd.do("zoom GPSS-" + pdbCode)
コード例 #55
0
    def gpssMetal(pdbCode, reinitialize):

        if _gpssLoadPdb(pdbCode, reinitialize):

            # Get ligand surfaces
            metalInfo = urllib2.urlopen(
                "http://gpss.mcsg.anl.gov/webservices/" + "gpssServerPymol.php?pdbId=" + pdbCode + "&mode=metalInfo"
            ).read()

            if metalInfo:
                metalInfoArray = metalInfo.split(":")

                # Get pocket atoms
                for metalSurface in metalInfoArray:
                    metalSurfaceFile = urllib2.urlopen(
                        "http://gpss.mcsg.anl.gov/webservices/"
                        + "gpssServerPymol.php?pdbId="
                        + pdbCode
                        + "&surfaceId="
                        + metalSurface
                        + "&mode=metalSurface"
                    )
                    metalId = metalSurface.split(".")
                    objectId = "Metal-" + metalId[1] + "." + metalId[2] + "." + metalId[3]
                    cmd.read_pdbstr(metalSurfaceFile.read(), objectId)
                    cmd.do("hide everything," + objectId)
                    cmd.do("show surface," + objectId)
                    cmd.do("show sphere," + objectId + " and resn " + metalId[1])

                    cmd.do("zoom GPSS-" + pdbCode)
コード例 #56
0
ファイル: vsc-set.py プロジェクト: mzhKU/Enzyme-Screening
def frag(state=state, obj=obj): 
    pwd, mutations, orig_sequence = setup(obj)

    #get_positions_in_selection(sub, distance)
    
    # Run over all sites where to mutate, optionally add and retain hydrogens.
    for site in mutations.keys():
        variants = mutations[site]
        # Run over all variants.
        for variant in variants:
            cmd.load(obj) 
            cmd.do('wizard mutagenesis')
            cmd.do('refresh_wizard')
            cmd.get_wizard().set_hyd("keep") 
            cmd.get_wizard().set_mode(variant)
            #cmd.get_wizard().do_select(site + '/')
            
            # Get the number of available rotamers at that site.
            # Introduce a condition here to check if rotamers are requested.
            # <<OPTIONAL>>
            nRots = getRots(site, variant)
            #if nRots > 3:
            #    nRots = 3
            nRots=1

            cmd.rewind()
            for i in range(1, nRots + 1): 
                cmd.get_wizard().do_select("(" + site + "/)")
                cmd.frame(i)
                cmd.get_wizard().apply()

                # Optimize the mutated sidechain
                #<<OPTION>>
                #print "Sculpting."
                local_sculpt(obj, variant, site)

                # Protonation of the N.
                #cmd.do("select n%d, name n and %d/" % (int(site), int(site)))
                #cmd.edit("n%d" % int(site), None, None, None, pkresi=0, pkbond=0)
                #cmd.do("h_fill")

                # Protonation of the C.
                #cmd.do("select c%d, name c and %d/" % (int(site), int(site)))
                #cmd.edit("c%d" % int(site), None, None, None, pkresi=0, pkbond=0)
                #cmd.do("h_fill") 

                # Definition of saveString
                #saveString  = '%s/' % pwd
                #saveString += 'frag-' + get_one(orig_sequence[site]).lower() +\
                #               site + get_one(variant).lower() + '-%s.pdb, ' % state +\
                #               '((%s/))' % site
                save_string_rot  = '%s/' % pwd
                save_string_rot += 'frag-' + get_one(orig_sequence[site]).lower() +\
                                  site + get_one(variant).lower() + '-%02d-%s.pdb, ' % (i, state) +\
                                  '((%s/))' % site
                #print saveString 
                #cmd.do('save %s' % saveString.lower())
                cmd.do('save %s' % save_string_rot.lower())
            cmd.do('delete all') 
            cmd.set_wizard('done')
コード例 #57
0
    def gpssLigand(pdbCode,reinitialize):
        
        if _gpssLoadPdb(pdbCode,reinitialize):

            # Get ligand surfaces
            ligandInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                          'gpssServerPymol.php?pdbId='+
                                          pdbCode + '&mode=ligandInfo').read()
            if ligandInfo:
                ligandInfoArray = ligandInfo.split(':')

                # Get pocket atoms
                for ligandSurface in ligandInfoArray:
                    ligandSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                                        'gpssServerPymol.php?pdbId='+ pdbCode +
                                                        '&surfaceId=' + ligandSurface +
                                                        '&mode=ligandSurface')
                    ligandId = ligandSurface.split('.')
                    objectId = 'Ligand-' + ligandId[1] + '.' + ligandId[2] + '.' + ligandId[3]
                    cmd.read_pdbstr(ligandSurfaceFile.read(),objectId)
                    cmd.do('hide everything,' + objectId)
                    cmd.do('show surface,' + objectId)
                    cmd.do('show sticks,' + objectId + ' and resn ' + ligandId[1])
                    
                cmd.do('zoom GPSS-'+pdbCode)
コード例 #58
0
    def gpssMetal(pdbCode,reinitialize):
        
        if _gpssLoadPdb(pdbCode,reinitialize):

            # Get ligand surfaces
            metalInfo = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                        'gpssServerPymol.php?pdbId='+
                                        pdbCode + '&mode=metalInfo').read()

            if metalInfo:
                metalInfoArray = metalInfo.split(':')

                # Get pocket atoms
                for metalSurface in metalInfoArray:
                    metalSurfaceFile = urllib2.urlopen('http://gpss.mcsg.anl.gov/webservices/'+
                                                       'gpssServerPymol.php?pdbId='+ pdbCode +
                                                       '&surfaceId=' + metalSurface +
                                                       '&mode=metalSurface')
                    metalId = metalSurface.split('.')
                    objectId = 'Metal-' + metalId[1] + '.' + metalId[2] + '.' + metalId[3]
                    cmd.read_pdbstr(metalSurfaceFile.read(),objectId)
                    cmd.do('hide everything,' + objectId)
                    cmd.do('show surface,' + objectId)
                    cmd.do('show sphere,' + objectId + ' and resn ' + metalId[1])

                    cmd.do('zoom GPSS-'+pdbCode)
コード例 #59
0
    def testSetKey(self):
        if testing.PYMOL_VERSION[1] > 1.84:
            cmd.set('auto_show_classified', 0)

        cmd.fragment('gly')
        N = cmd.count_atoms()
        self.assertEqual(0, cmd.count_atoms('rep sticks | rep spheres'))
        cmd.set_key('F3', cmd.show, ('sticks',))
        cmd._special(3, 0, 0)
        self.assertEqual(N, cmd.count_atoms('rep sticks'))
        cmd.do('set_key F3, hide sticks; show spheres')
        cmd._special(3, 0, 0)
        self.assertEqual(0, cmd.count_atoms('rep sticks'))
        self.assertEqual(N, cmd.count_atoms('rep spheres'))