Exemplo n.º 1
0
def mutate_atoms(desired_sequence):
    # Acquire the lock once you execute this program
    lock.acquire()
    cmd.reset()
    # Check the length of peptide sequence
    # If the sequence does not match the MHC structure, the program will terminate.
    try:
        if len(desired_sequence) != 9:
            raise AssertionError
    except AssertionError:
        sys.exit(
            "Please input a peptide sequence with exactly 9 residues (in short abbreviation, no space)!"
        )

    # Execute the mutation command based on the PyMOL API.
    # For each round, we construct a new PyMOL object to avoid the problem of different mutation affecting each other.
    cmd.wizard("mutagenesis")
    cmd.load("structures/3pwn_clear_original.pdb")
    new_sequence = translate_sequence(desired_sequence)
    for i in range(len(new_sequence)):
        cmd.refresh_wizard()
        cmd.get_wizard().set_mode(new_sequence[i])
        cmd.get_wizard().do_select("C/%d/" % (i + 1))
        cmd.get_wizard().apply()
    cmd.save("structures/mutated_intermediate/mutated_pmhc_complex.pdb")
    cmd.quit()
    # Release the lock when the program ends
    lock.release()
Exemplo n.º 2
0
def main():
    parser=argparse.ArgumentParser()
    parser.add_argument('-p', action='store', required=True, dest='pdbfile',
                    help='pathfile is a textfile of name of pdb')
    parser.add_argument('-l', action='store', required=True, dest='loop',
                    help='loop is an int number')
    inputs=parser.parse_args()
    pdbfile=inputs.pdbfile
    loop=int(inputs.loop)
    print "loop is %s "% loop
    dirname=os.getcwd()+'/interface_analyzer/pdbdata/'+pdbfile
    pdbfileselect=pdbfile.split('.')
    savefile=os.getcwd()+'/interface_analyzer/pdbdata/'+pdbfileselect[0]+'_antigen.pdb'
    print "remove antibody of complex,so can caculate the value of antigen sasa "
    pymol.finish_launching()
    if loop!=0:
        pymol.cmd.reinitialize()
    cmd.load(dirname)
    cmd.remove('hetatm')
    cmd.select('target1',pdbfileselect[0])
    cmd.save(dirname,(('target1')))
    cmd.delete('target1')
    cmd.remove('solvent')
    cmd.remove('hydrogens')
    cmd.remove('chain L+H')
    cmd.select('target',pdbfileselect[0])
    cmd.save(savefile,(('target')))
    cmd.delete(all)
    cmd.sync()
    cmd.quit()
    print "remove the antibody of complex have done"
Exemplo n.º 3
0
def saveMultiplepng(pnamein, nbstates):

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

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



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

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

    cmd.quit()
Exemplo n.º 4
0
def abl(*files, **kwargs):
    MdsPymol.reset(options)

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

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

    # Process global options.

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

    if options['axes compute']:
        Axes(options)
    if options['base grid compute']:
        BaseGrid(options)
    if options['view']:
        cmd.set_view(options['view'])
    if options['ray']:
        cmd.ray()
    if options['png file']:
        cmd.png(options['png file'])
    if options['quit']:
        cmd.quit()
Exemplo n.º 5
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.º 6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('-p',
                        action='store',
                        required=True,
                        dest='pdbfile',
                        help='pathfile is a textfile of name of pdb')
    parser.add_argument('-l',
                        action='store',
                        required=True,
                        dest='loop',
                        help='loop is an int number')
    parser.add_argument('-c',
                        action='store',
                        required=True,
                        dest='chain',
                        help='the chain number is needed')
    parser.add_argument('-c1',
                        action='store',
                        required=True,
                        dest='chain1',
                        help='the chain number is needed')
    inputs = parser.parse_args()
    pdbfile = inputs.pdbfile
    removechains = 'not chain ' + inputs.chain + '+' + inputs.chain1
    removechain = 'chain ' + inputs.chain
    loop = int(inputs.loop)
    print "loop is %s " % loop
    dirname = os.getcwd() + '/interface_analyzer/pdbdata/' + pdbfile
    pdbfileselect = pdbfile.split('.')
    savefile = os.getcwd(
    ) + '/interface_analyzer/pdbdata/' + pdbfileselect[0] + '_antigen.pdb'
    print "remove antibody of complex,so can caculate the value of antigen sasa "
    pymol.finish_launching()
    if loop != 0:
        pymol.cmd.reinitialize()
    cmd.fetch(pdbfileselect[0], async=0)
    #cmd.select('targetfile',pdbfileselect[0])
    #cmd.save(dirname,(('targetfile')))
    #cmd.delete(all)
    #cmd.load(dirname)
    cmd.remove(removechains)
    cmd.remove('solvent')
    cmd.remove('hydrogens')
    cmd.remove('hetatm')
    cmd.select('target1', pdbfileselect[0])
    cmd.save(dirname, (('target1')))
    cmd.remove('solvent')
    cmd.remove('hydrogens')
    cmd.remove('not ' + removechain)
    cmd.select('target', pdbfileselect[0])
    cmd.save(savefile, (('target')))
    cmd.delete(all)
    cmd.sync()
    cmd.quit()
    print "remove the antibody of complex have done"
Exemplo n.º 7
0
    def cli():
        '''
        Test suite client application.
        '''
        if not cliargs.filenames:
            # silently do nothing
            return

        nfail = run_testfiles(**vars(cliargs))
        cmd.quit(nfail)
Exemplo n.º 8
0
    def cli():
        '''
        Test suite client application.
        '''
        if not cliargs.filenames:
            # silently do nothing
            return

        nfail = run_testfiles(**vars(cliargs))
        cmd.quit(nfail)
Exemplo n.º 9
0
def visualize_in_pymol(args,outfolder,clusters,interactions,pdb,cut,freq):

    #(args,outfolder,clusters,interactions,pdb,cut,freq)=input_args
    #print(cut)
    #return
    pymol.finish_launching()
    cmd.reinitialize()
    cmd.load(pdb)
    cmd.hide("everything")
#    cmd.show("ribbon")
    cmd.show("cartoon")
    # Create bindings and selections, and color them
    bond_connections(clusters, interactions)
    selections = select_clusters(clusters)
    colors = color_selections(selections)
    print(colors)

#    colors = color_selections([sele])


    #cmd.color("gray70")
    #cmd.set("sphere_scale",0.75)
    cmd.space("cmyk")
    #cmd.set("ray_shadow","off")
    #cmd.bg_color("white")
    sele = "chain A and resi 131 and not name H*"
    cmd.show("sticks",sele)
    cmd.util.cnc(sele)
    #cmd.center("chain A")
    cmd.deselect()
    ### cut below here and paste into script ###
    cmd.set_view ([\
                   0.185403526,   -0.784912288,   -0.591205537,\
                   -0.726189077,    0.295874894,   -0.620551527,\
                   0.662004888,    0.544381559,   -0.515144050,\
                   -0.001714554,   -0.001769811, -125.023078918,\
                   30.330446243,   78.181671143,  146.038742065,\
                   98.763908386,  151.776306152,  -20.000000000] )
    outfile="{}cluster{}-{}.png".format(outfolder,cut,freq)
    if args.ray or args.generate_all:
        cmd.save(outfile)
### cut above here and paste into script ###

    # Show clusters
    if args.show[0] is None:
        show_cluster(clusters)
    else:
        shw = [int(c) for c in args.show[0].split(',')]
        for c in args.show[0]:
            show_cluster(clusters[c - 1])
    cmd.save(outfile)
    cmd.quit()
Exemplo n.º 10
0
def images(B):
    #cmd.do("cd {}".format(B))
    pdb_list = glob.glob("*.pdb")
    for pdb in pdb_list:
        cmd.load(pdb)
    cmd.run("/usr/local/bin/all_against_all.py")
    cmd.select("all_ps", "name PS1+PS2+PS3")
    cmd.do(
        "align_all_to_all(selection='all_ps',cutoff=0,cycles=0,full_matrix=1,method='align')"
    )
    cmd.remove("het")
    cmd.remove("all_ps")
    cmd.show("sticks", "all")
    cmd.hide("sticks", "all_ps")
    cmd.hide("sphere", "all_ps")
    cmd.set("sphere_scale", 0.30, "all_ps")
    cmd.orient("all")
    cmd.multisave("{}.pdb".format(B))
    cmd.set("ray_opaque_background", 0)
    cmd.ray(2400)
    cmd.set("antialias", 1)
    cmd.png("{}.png".format(B), 1200, 1200, 300)
    cmd.quit()
Exemplo n.º 11
0
def main():
    from argparse import ArgumentParser
    from sys import argv, stdin
    parser = ArgumentParser(
        description="Display Wordom PSN analysis clusters in PyMOL.")
    parser.add_argument(
        "-c", nargs=1, default=[None], metavar="float", 
        help="Cutoff to use (must be present in AVGfile)" +
        ", default=Use lowest found")
    parser.add_argument(
        "-f", nargs=1, default='50.0', metavar=float, 
        help="frequencey Cutoff to use (must be present in AVGfile)")
    
    parser.add_argument(
        "-show", nargs=1, default=[None], metavar="int[,int[...]]",
        help="Show specified clusters")
    parser.add_argument(
        "-ray", action='store_true', help="raytrace and save fig")
    parser.add_argument(
        "-overwrite", action='store_true', help="overwrite if fig already exists")
    parser.add_argument(
        "-generate_all", action='store_true', help="generate raytraced figs for all cutoffs and frequences")
    parser.add_argument(
        "avg", nargs=1, metavar="AVGfile", type=str,
        help="Wordom PSN avg file")
    parser.add_argument(
        "pdb", nargs=1, metavar="PDBfile", type=str,help="PDB file to draw")
    args = parser.parse_args()
    
    # Finish pymol launch
#    pymol.finish_launching()
#    cmd.feedback("disable","all","actions")
#    cmd.feedback("disable","all","results")
    # Set variables here
    pdb = args.pdb[0]
    avg = args.avg[0]
    cut = args.c[0]
    freq= float(args.f[0])
    shw = args.show[0]
    ray = args.ray or args.generate_all


    outfolder=os.path.abspath(avg)
    outfile = "{}cluster{}-{}.png".format(outfolder, cut, freq)
    if not args.overwrite and os.path.exists(outfile):
        print("\n{} already exist.\nUse -overwrite if you want to overwrite the existing file.\n".format(outfile))
        sys.exit()
    interactions = {}
    clusters_all = {}
    with open(avg, 'r') as infile:
        interactions = read_avg_strength(infile)
        #print(interactions)
        #sys.exit()
        infile.seek(0)
        clusters_all = read_avg_clusters(infile)
        #print(clusters)
        #sys.exit()
#    print("Hello")
    #sys.exit(1)
    # Select the cutoff
    #with open("cutoffs", 'wb') as f:
    #        pickle.dump(list(clusters.keys()), f)
    if cut is not None:
        # If provided
        cut = float(cut)
    else:
        # Default
        cutoffs = list(clusters_all.keys())
        cutoffs.sort()
        cut = cutoffs[0]

    cuts_to_sweep=[cut]
    freq_to_sweep=[freq]

    if args.generate_all:
        cuts_to_sweep=clusters_all.keys()
        freq_to_sweep=clusters_all[cut].keys()

    todo=[]
    for cut_ in cuts_to_sweep:
        for freq_ in freq_to_sweep:
            print("{} {}".format(cut_,freq_))
            todo.append((args,outfolder,clusters_all[cut_][freq_],interactions,pdb,cut_,freq_))
    #print(len(todo))
    #sys.exit()
    #pool = Pool(processes=8)
    #pool.map(visualize_in_pymol,todo)
    #print(todo)
    #visualize_in_pymol((todo))
    visualize_in_pymol(args,outfolder,clusters_all[cut][freq],interactions,pdb,cut,freq)
    #for cut_ in cuts_to_sweep:
    #    for freq_ in freq_to_sweep:


    if 1==0:
        # Select clusters
        print("Running for {} {}".format(cut_,freq_))
    #    clusters_freq = clusters_all[cut_]
    #    print(clusters_freq)
        clusters = clusters_all[cut_][freq_]
        #print(type(clusters_freq))
        #print(clusters_freq.keys())
        #with open("freq", 'wb') as f:
        #        pickle.dump(list(clusters_freq.keys()), f)
        #print(type(freq))
        #clusters = clusters_freq[80.0]
    #    print(clusters_freq)
    #    print(interactions)
         #ys.exit()
    #    print(clusters)
        cmd.reinitialize()
        cmd.load(pdb)
        cmd.hide("everything")
    #    cmd.show("ribbon")
        cmd.show("cartoon")

        # Create bindings and selections, and color them
        bond_connections(clusters, interactions)
        selections = select_clusters(clusters)
        colors = color_selections(selections)
        print(colors)

    #    colors = color_selections([sele])


        #cmd.color("gray70")
        #cmd.set("sphere_scale",0.75)
        cmd.space("cmyk")
        #cmd.set("ray_shadow","off")
        #cmd.bg_color("white")
        sele = "chain A and resi 131 and not name H*"
        cmd.show("sticks",sele)
        cmd.util.cnc(sele)
        #cmd.center("chain A")
        cmd.deselect()
        ### cut below here and paste into script ###
        cmd.set_view ([\
                       0.185403526,   -0.784912288,   -0.591205537,\
                       -0.726189077,    0.295874894,   -0.620551527,\
                       0.662004888,    0.544381559,   -0.515144050,\
                       -0.001714554,   -0.001769811, -125.023078918,\
                       30.330446243,   78.181671143,  146.038742065,\
                       98.763908386,  151.776306152,  -20.000000000] )
        outfile = "{}cluster{}-{}.png".format(outfolder, cut, freq)
        if args.ray:
            cmd.save(outfile)
    ### cut above here and paste into script ###

        # Show clusters
        if shw is None:
            show_cluster(clusters)
        else:
            shw = [int(c) for c in shw.split(',')]
            for c in shw:
                show_cluster(clusters[c - 1])
        cmd.save(outfile)
        cmd.quit()
Exemplo n.º 12
0
def pytest_unconfigure(config):
    if not config.getoption("--keep-pymol"):
        cmd.quit()
def loop_model_analysis(pdbs=None,align_file=None,name='n. ca',cycles=5,cutoff=2.0):
  """
  Calculates backbone and all atom rmsd for the modeled loop region,obtains model score and modeled loop structural characteristics
  SCRIPT methodology:
  inputs pdbs in the current directory,reads each pdb file filtered by the cluster it belongs to and extracts the score.
  Creates a sorted by score cluster dictionary.The lowest scoring decoy from each cluster is then used as the target for backbone and all atom rmsd calculations based on the modeled loop region only
  Generates an output file containing decoys with helical, strand or mixed conformation, with their score, rmsd, and modeled loop secondary structure 
  Calculates statistics for each cluster and overall loop modeling  
  Defaults:
	pymol alignment cutoff and cycles. 
  Needed
    At least one selection 
    Alignment file path
    Decoys
  Example
    pymol -cqd "run path to analysis file;analysis pdbs= *.pdb,cutoff,cycles,..."
    """    
  help='Usage:pymol -cqd "run analysis.py;analysis pdbs= path_to_pdbs or tar zipped pdb file,align_file=path_to_alignment_file, name=n. ca, cutoff=2.0, cycles=5"\nNote: Default alignment cutoff and cycles can be changed if necessary'
  print ''
  if not pdbs:
    print 'Missing pdb files or zipped pdb file.See Usage'
    print ''
    print help
    cmd.quit()
  if pdbs.split('.')[1]=='pdb' and os.path.exists('c.0.0.pdb'):
     files=glob.glob(pdbs)
  elif pdbs.split('.')[1]=='pdb' and not os.path.exists('c.0.0.pdb'):
     print 'tarred file exist.Using it instead of given pdbs argument'
     pdbs='*.tgz'
     print 'untarring file...'
     call('tar -zxf %s' %pdbs,shell=True)
     files=glob.glob('*.pdb')
  elif pdbs.split('.')[1]=='tgz' and not os.path.exists('c.0.0.pdb'):
     print 'untarring file ...'
     call('tar -zxf %s' %pdbs,shell=True)
     files=glob.glob('*.pdb')
  else:
     files=glob.glob('*.pdb')
  if not align_file:
    print 'Target-template alignment file missing.See Usage'
    print ''
    print help
    cmd.quit()
  ali_file=glob.glob(align_file) # alignment file with gaps
  extension = re.compile( '(^.*[\/]|\.(pdb|ent|brk))' )
    # dictionary to hold decoy and score
  #Create dictionary to sequester different clusters
  clust0_dic={};clust1_dic={};clust2_dic={};clust3_dic={};clust4_dic={}
  # sort by energy variables
  cluster0="";cluster1="";Cluster2="";cluster3="";cluster4="";energy=[]
  # create model sel1 and sel2 files from alignment file
  beg=[] # Modeled loop region beginning index
  end=[] # Modeled loop region end index
  # open the file and extract beginning and end of gaps and append
  with open(ali_file[0],'r') as f:
    for line in f:
      if '-' in line:
        for m in re.finditer('-+',str(line)):
          beg.append(m.start()+1)
          end.append(m.end())
  if len(beg)==2 and len(end)==2: # check if more than one loop was modeled
      sel1='i. %s-%s' %(beg[0],end[0])
      sel2='i. %s-%s' %(beg[1],end[1])
  elif len(beg)==1 and len(end)==1: # check if one loop was modeled and whether V1 or V2
    if beg[0]<34:
      sel1='i. %s-%s' %(beg[0],end[0])
      sel2=None
    elif beg[0]>34:
      sel2='i. %s-%s' %(beg[0],end[0])
      sel1=None
    # obtain modeled residues from modeling selection 
  print 'Selection 1: %s' %sel1
  print 'Selection 2: %s\n' %sel2
# extract score for each decoy create a dictionary and sort it
  for pdb in files:
    obj_name=extension.sub('',pdb)
    cmd.load(pdb,obj_name)    
    with open(pdb,'r') as f:
      for line in f:
        if line.startswith('pose'):
          score=float('%0.2f'%float(line.split()[-1]))
          energy.append(int(score))
          if pdb[2]=='0':
            clust0_dic[pdb]= score
            cluster0=sorted(clust0_dic.items(),key=operator.itemgetter(1))
          elif pdb[2]=='1':
            clust1_dic[pdb]=score
            cluster1=sorted(clust1_dic.items(),key=operator.itemgetter(1))
          elif pdb[2]=='2':
              clust2_dic[pdb]= score
              Cluster2=sorted(clust2_dic.items(),key=operator.itemgetter(1))

            cluster3=sorted(clust3_dic.items(),key=operator.itemgetter(1))
          elif pdb[2]=='4':
            clust4_dic[pdb]= score
            cluster4=sorted(clust4_dic.items(),key=operator.itemgetter(1))
          else:
            print 'No file with decoys found or clusters exceed set limit'
            print help
Exemplo n.º 14
0
from pymol import cmd
import sys

def pdb_to_mol(pdb_file):
    cmd.load(pdb_file)
    cmd.h_add()
    cmd.save("%s_ligand.mol" % (pdb_file[0:4]))

#cmd.extend("pdb_to_mol", pdb_to_mol)

pdb_lig_file = sys.argv[1]
pdb_to_mol(pdb_lig_file)
cmd.quit()
Exemplo n.º 15
0
 def __init__(self, *args):
     try:
         SimpleXMLRPCServer.__init__(self, *args)
     except:
         cmd.quit(1)
Exemplo n.º 16
0
def pyFunc(in_file_name):
    #cmd.set max_threads, 1
    in_file = open(in_file_name, 'r')
    print(in_file_name)

    count_file_name = in_file_name + '_count.txt'
    count_file_len = 0
    if os.path.exists(count_file_name) == False:
        count_file = open(count_file_name, 'w')
    else:

        count_file_len = file_len(count_file_name)

        count_file = open(count_file_name, 'a')
    err_file_name = in_file_name + '_' + str(count_file_len) + '_err.txt'
    out_file_name = in_file_name + '_' + str(
        count_file_len) + '_out.txt'  #_'+in_file_name.split('.')[1]+'.txt'
    out_file = open(out_file_name, 'w')
    err_file = open(err_file_name, 'w')

    #out_file.write('Sourec\tTarget\tSl\tTl\tLigand\tRMSD\tAlign CA\tRaw alignment score\tAligned Residues\tLigand center distance'+'\t'+'Structural Distance'+'\n')

    t = 0
    for i in xrange(count_file_len):
        in_file.next()
    start = time.time()
    print('start align from line: ' + str(count_file_len))
    for line in in_file:
        #print(line)
        try:
            #s=time.time()
            count_file.write(str(t + count_file_len) + '\n')
            t = t + 1
            #if t>200:
            #   break
            cmd.reinitialize()
            line = line.split('\t')
            microen1 = line[0][:-4]
            microen2 = line[1][:-6]

            #PDB2='3cw9.01A_B_991'
            lig1 = line[0].split('_')[0]
            lig1 = lig1.split('.')[1]
            PDB1 = lig1.split('.')[0]

            lig2 = line[1].split('_')[0]
            lig2 = lig2.split('.')[1]
            PDB2 = lig2.split('.')[0]

            Fldr1 = microen_dir + lig1 + '/'
            Fldr2 = microen_dir + lig2 + '/'
            pdbFile_1 = str(Fldr1) + microen1 + ".pdb"
            pdbFile_2 = str(Fldr2) + microen2 + ".pdb"
            cmd.load(pdbFile_1, 'PDB1')
            cmd.load(pdbFile_2, 'PDB2')
            #print('load')
            Ql = cmd.count_atoms('PDB1 and name CA')
            Tl = cmd.count_atoms('PDB2 and name CA')
            #print('count')
            if Ql < 10 or Tl < 10:
                continue
            #print('Ql,Tl:'+str(Ql)+str(Tl))
            res_num1 = microen1.split('_')
            res_num2 = microen2.split('_')

            res_num1 = res_num1[2]
            res_num2 = res_num2[2]
            #print('res_num1:',res_num1)
            #print('res_num2:',res_num2)

            x = cmd.align('PDB1 and name CA',
                          'PDB2 and name CA',
                          quiet=1,
                          cycles=5)
            #print('align')
            align_out = [x[0], x[1], x[5], x[6]]
            #print(align_out)
            atomlist = []
            #print(PDB1,PDB2)
            if lig1 not in al_dict:
                center1 = get_center(
                    cmd.get_model('PDB1 and resi ' + res_num1,
                                  1).get_coord_list())
            else:
                if lig1 == 'ADE':
                    for atom in al_dict.get(lig1)[1].split(';'):
                        atomlist = atomlist + (cmd.get_model(
                            'PDB1 and resi ' + res_num1 + ' and name ' + atom,
                            1).get_coord_list())
                else:
                    for atom in al_dict.get(lig1)[0].split(';'):
                        atomlist = atomlist + (cmd.get_model(
                            'PDB1 and resi ' + res_num1 + ' and name ' + atom,
                            1).get_coord_list())
                center1 = get_center(atomlist)

            if center1 == 'NA':

                continue
            atomlist = []

            if lig2 not in al_dict:
                center2 = get_center(
                    cmd.get_model('PDB2 and resi ' + res_num2,
                                  1).get_coord_list())
            else:
                if lig2 == 'ADE':
                    for atom in al_dict.get(lig2)[1].split(';'):
                        atomlist = atomlist + (cmd.get_model(
                            'PDB2 and resi ' + res_num2 + ' and name ' + atom,
                            1).get_coord_list())
                else:
                    for atom in al_dict.get(lig2)[0].split(';'):
                        atomlist = atomlist + (cmd.get_model(
                            'PDB2 and resi ' + res_num2 + ' and name ' + atom,
                            1).get_coord_list())
                center2 = get_center(atomlist)

            if center2 == 'NA':

                continue
            #print(center1,center2)
            Dis = math.sqrt((pow((center1[0] - center2[0]), 2)) +
                            (pow((center1[1] - center2[1]), 2)) +
                            (pow((center1[2] - center2[2]), 2)))
            #print(Dis)
            if Dis > 15:
                #print('large distance')
                continue
            #print(x)
            D = Ql + Tl - (2 * x[6])  #was x[1] in all last runs before 4.7.16
            align_out = str(Ql) + '\t' + str(
                Tl) + '\t' + lig1 + '_' + lig2 + '\t' + str(x[0]) + '\t' + str(
                    x[1]) + '\t' + str(x[5]) + '\t' + str(
                        x[6]) + '\t' + str(Dis) + '\t' + str(D)
            out_file.write(microen1 + '\t' + microen2 + '\t' + align_out +
                           '\n')
            #e=time.time()
            #out_file.write(str(e-s)+'\n')

        except:
            err_file.write('\t'.join(line))
            continue

    end = time.time()
    print('Run time is:' + str(end - start))
    #out_file.write('Run time is:'+str(end - start)+'/n')
    out_file.close()
    err_file.close()
    end = time.time()
    cmd.quit()
    #print ('Run time is:'+str(end - start))

    return  # (str(end - start))
Exemplo n.º 17
0
Arquivo: rpc.py Projeto: jandom/rdkit
def rpcQuit():
  """ causes PyMol to quit """
  cmd.quit()
  return 1
Exemplo n.º 18
0
def rpcQuit():
    """ causes PyMol to quit """
    cmd.quit()
    return 1
Exemplo n.º 19
0
for i in range(5):
    cmd.load("./PDBs-%d/State%d-%d.pdb" % (p_id, stateid, i))

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

#alignto does the same thing as the above loop, but it sometimes could cause problem
#cmd.alignto("State%d-0"%stateid)
cmd.show("cartoon")
cmd.hide("lines", "!State%d-%d" % (stateid, ref_state_id))
cmd.center("all")
cmd.set("cartoon_transparency", 0.7, "all")
cmd.set("cartoon_transparency", 0, "State%d-%d" % (stateid, ref_state_id))
cmd.util.chainbow("all")
cmd.util.cnc("all")
cmd.orient()
cmd.util.performance(0)
cmd.set("ray_opaque_background", "off")
cmd.ray()
png_fn = os.path.join(outdir, "image-p%d-state-%d.png" % (p_id, stateid))
high_res_state = [0, 1, 2, 4, 11, 12, 13, 20, 28, 30]
if stateid in high_res_state:
    png_fn = os.path.join(outdir,
                          "image-p%d-state-%d-highres.png" % (p_id, stateid))
    cmd.ray(2400, 1800)
    cmd.png(png_fn, dpi=300)
else:
    cmd.png(png_fn)
cmd.quit()
Exemplo n.º 20
0
def main():
    parser = argparse.ArgumentParser(
        description='visualising path from psnpath')
    parser.add_argument('-psnpath',
                        default=None,
                        type=str,
                        nargs=1,
                        required=True,
                        help='log file from psnpath')
    parser.add_argument("-pdb", nargs=1, type=str, help="PDB file to draw")

    parser.add_argument("-minlen",
                        type=int,
                        default=1,
                        help="minimum path length to consider")
    parser.add_argument("-minfreq",
                        type=float,
                        default=0.0,
                        help="minimum path freq to consider")

    parser.add_argument("-overwrite",
                        action='store_true',
                        help="overwrite if fig already exists")
    #pymol.finish_launching()
    args = parser.parse_args()
    logfile = args.psnpath[0]
    pdb = args.pdb[0]
    #print args
    #print args.minlen
    #sys.exit()
    df = pd.read_csv(logfile, sep='\s+', index_col=0)
    #print df.sort_values('HighFreqLen', ascending=False)
    # print df.HighFreqPath
    #column header gets shiften one to the right
    #Skip first column
    columns = df.columns[1:]
    #drop last empty column
    df.drop(df.columns[-1], axis=1, inplace=True)
    #shift the columns...
    df.columns = columns
    rows = df.NullFrames != '***SKIPPED***'
    count = {}
    jobs = []
    for index, row in df[rows].sort_values('HighFreqLen',
                                           ascending=False).iterrows():
        #print row

        if row.HighFreqLen >= args.minlen and row.HighFreqVal >= args.minfreq:
            # print row.HighFreqPath
            #print row
            #continue
            dirname = os.path.dirname(logfile)
            basename = os.path.basename(logfile)
            basename_noext = re.sub('.log$', '', basename)
            #print row
            name1 = row.Res1.replace(':', '_')
            name2 = row.Res2.replace(':', '_')
            if not name1 in count:
                count[name1] = 1
            name_prefix = "{}/PSNPath-{}-{}-{}".format(dirname, basename_noext,
                                                       name1, name2)
            name_prefix_count = "{}/{}PSNPath-{}-{}-{}".format(
                dirname, count[name1], basename_noext, name1, name2)
            frame_file = name_prefix + ".frame"
            #stat_file=name_prefix + ".stat"

            #continue
            #stat=get_stat(stat_file)
            outfile = "{}.freq{}.len{}.png".format(name_prefix_count,
                                                   row.HighFreqVal,
                                                   row.HighFreqLen)
            infofile = re.sub('.png', '.info', outfile)

            res_freq = get_res_freq(frame_file)
            if not os.path.exists(outfile) or args.overwrite:
                print outfile
                jobs.append((row.HighFreqPath, row.HighFreqVal, pdb, outfile))
                #visualize_path((row.HighFreqPath,row.HighFreqVal,pdb,outfile))
                visualize_path((row.HighFreqPath, res_freq, pdb, outfile))
            if not os.path.exists(infofile) or args.overwrite:
                print infofile
                write_info(row.HighFreqPath, res_freq, infofile)
                #sys.exit()
            count[name1] += 1
            #sys.exit()
        #print row['HighFreqPath']

    #pool = Pool(processes=1)
    #pool.map(visualize_path,jobs)


#print df.HighFreqPath
#print df
#pymol.finish_launching()
#cmd.reinitialize()
#cmd.load(pdb)
#cmd.hide("everything")
#    cmd.show("ribbon")
#cmd.show("cartoon")
    cmd.quit()