Ejemplo n.º 1
0
    def set_and_display(self, flag, id):

        # Set search
        cmd.get_wizard().set_search(int(id[-1])-1)

        # Show logo
        cmd.get_wizard().launch_logo_search(flag)
Ejemplo n.º 2
0
    def launch_logo_search(self, flag):
        """
        launches the show logo operation in the separate thread
        does some basic checking and gets selection
        """

        if self.win.search is None:
            print 'please select target search'
            return
        
        else:
            
            cmd.get_wizard().status = 'logo request launched'
            cmd.refresh_wizard()
            
            self.stop_logo()
            self.win.logoThread = LogoThread(
                self.win.jobIDs[self.win.search],
                int(flag),
                self.win.serverURL,
                cmd)
            self.win.logoThread.start()
            self.win.logoThread.join()
           
            cmd.get_wizard().status = 'logo request finished'
            cmd.refresh_wizard()

            query = self.win.jobIDs[self.win.search]
            residues = self.win.qSeqs[self.win.search]
            cmd.get_wizard().makeLogo = 0
            
            self.display_menu_logo(cmd.get_wizard().app, query, residues, self.win.rmsd.get(), flag, cmd.get_wizard())
Ejemplo n.º 3
0
    def set_and_search(self):

        # Set RMSD cutoff
        if self.is_num(self.win.rmsd.get()):
            #cmd.get_wizard().set_rmsd(float(self.win.rmsd.get()))
            self.win.rmsd.set(float(self.win.rmsd.get()))
        else:
            cmd.get_wizard().status = 'rmsd not number'
            cmd.refresh_wizard()
            return

        # Set number of structures
        if self.is_num(self.win.num_structs.get()):
            #cmd.get_wizard().set_num_structures(float(self.win.num_structs.get()))
            self.win.num_structs.set(float(self.win.num_structs.get()))
        else:
            cmd.get_wizard().status = 'num matches not number'
            cmd.refresh_wizard()
            return

        # Set Database
        if self.win.db.get() == "Test DB":
            self.win.datab = DATABASE_TEST
        elif self.win.db.get() == "Full DB":
            self.win.datab = DATABASE_FULL

        # Set Full matches
        if self.win.fm.get() == "Region":
            self.win.full_match = False
        elif self.win.fm.get() == "Full":
            self.win.full_match = True

        # Launch the search
        self.launch_search()
Ejemplo n.º 4
0
    def set_and_display(self, flag, id):

        # Set search
        cmd.get_wizard().set_search(int(id[-1])-1)

        # Show logo
        cmd.get_wizard().launch_logo_search(flag)
Ejemplo n.º 5
0
    def launch_logo_search(self, flag):
        """
        launches the show logo operation in the separate thread
        does some basic checking and gets selection
        """

        if self.win.search is None:
            print 'please select target search'
            return

        else:

            cmd.get_wizard().status = 'logo request launched'
            cmd.refresh_wizard()

            self.stop_logo()
            self.win.logoThread = LogoThread(self.win.jobIDs[self.win.search],
                                             int(flag), self.win.serverURL,
                                             cmd)
            self.win.logoThread.start()
            self.win.logoThread.join()

            cmd.get_wizard().status = 'logo request finished'
            cmd.refresh_wizard()

            query = self.win.jobIDs[self.win.search]
            residues = self.win.qSeqs[self.win.search]
            cmd.get_wizard().makeLogo = 0

            self.display_menu_logo(cmd.get_wizard().app, query, residues,
                                   self.win.rmsd.get(), flag, cmd.get_wizard())
Ejemplo n.º 6
0
    def set_and_search(self):

        # Set RMSD cutoff
        if self.is_num(self.win.rmsd.get()):
        #cmd.get_wizard().set_rmsd(float(self.win.rmsd.get()))
            self.win.rmsd.set(float(self.win.rmsd.get()))
        else:
            cmd.get_wizard().status = 'rmsd not number'
            cmd.refresh_wizard()
            return

        # Set number of structures
        if self.is_num(self.win.num_structs.get()):
        #cmd.get_wizard().set_num_structures(float(self.win.num_structs.get()))
            self.win.num_structs.set(float(self.win.num_structs.get()))
        else:
            cmd.get_wizard().status = 'num matches not number'
            cmd.refresh_wizard()
            return

        # Set Database
        if self.win.db.get() == "Test DB":
            self.win.datab = DATABASE_TEST
        elif self.win.db.get() == "Full DB":
            self.win.datab = DATABASE_FULL

        # Set Full matches
        if self.win.fm.get() == "Region":
            self.win.full_match = False
        elif self.win.fm.get() == "Full":
            self.win.full_match = True

        # Launch the search
        self.launch_search()
Ejemplo n.º 7
0
    def testScene(self):
        cmd.fragment('ala', 'm1')
        cmd.fragment('gly', 'm2')
        cmd.create('m2', 'm2', 1, 2)
        cmd.create('m2', 'm2', 1, 3)
        cmd.create('m2', 'm2', 1, 4)

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

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

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

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

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

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

        # rename and delete
        cmd.scene('F2', 'store')
        cmd.scene(names[0], 'rename', new_key='F1')
        cmd.scene(names[1], 'delete')
        self.assertEqual(cmd.get_scene_list(), ['F1', 'F2'])
Ejemplo n.º 8
0
    def testScene(self):
        cmd.fragment('ala', 'm1')
        cmd.fragment('gly', 'm2')
        cmd.create('m2', 'm2', 1, 2)
        cmd.create('m2', 'm2', 1, 3)
        cmd.create('m2', 'm2', 1, 4)

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

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

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

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

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

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

        # rename and delete
        cmd.scene('F2', 'store')
        cmd.scene(names[0], 'rename', new_key='F1')
        cmd.scene(names[1], 'delete')
        self.assertEqual(cmd.get_scene_list(), ['F1', 'F2'])
Ejemplo n.º 9
0
 def test_CanMutateNonCanonicalNucleo(self):
     cmd.load(self.datafile("1k5e.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1k5e/A/A/6")
     cmd.get_wizard().mode = "Adenine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1k5e/A/A").splitlines()[1]
     self.assertEqual(seq, "CGGACAAGAAG")
Ejemplo n.º 10
0
 def test_CanGetNewDNASequence(self):
     cmd.load(self.datafile("1bna.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1bna/A/A/1")
     cmd.get_wizard().mode = "Adenine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1bna/A/A").splitlines()[1]
     self.assertEqual(seq, "AGCGAATTCGCG")
Ejemplo n.º 11
0
 def test_CanGetNewRNASequence(self):
     cmd.load(self.datafile("1rna.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1rna/A/A/14")
     cmd.get_wizard().mode = "Guanine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1rna/A/A").splitlines()[1]
     self.assertEqual(seq, "UUAUAUAUAUAUAG")
Ejemplo n.º 12
0
 def test_CanGetNewRNASequence(self):
     cmd.load(self.datafile("1rna.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1rna/A/A/14")
     cmd.get_wizard().mode = "Guanine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1rna/A/A").splitlines()[1]
     self.assertEqual(seq, "UUAUAUAUAUAUAG")
Ejemplo n.º 13
0
 def test_CanGetNewDNASequence(self):
     cmd.load(self.datafile("1bna.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1bna/A/A/1")
     cmd.get_wizard().mode = "Adenine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1bna/A/A").splitlines()[1]
     self.assertEqual(seq, "AGCGAATTCGCG")
Ejemplo n.º 14
0
 def test_CanMutateNonCanonicalNucleo(self):
     cmd.load(self.datafile("1k5e.cif"))
     cmd.wizard("nucmutagenesis")
     cmd.select("/1k5e/A/A/6")
     cmd.get_wizard().mode = "Adenine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     seq = cmd.get_fastastr("/1k5e/A/A").splitlines()[1]
     self.assertEqual(seq, "CGGACAAGAAG")
Ejemplo n.º 15
0
 def residue_select(self, i):
     
     # Show selection message
     cmd.get_wizard().res_info = 'click search chain '+self.win.residue_list[i][1]+' num '+self.win.residue_list[i][2]
     cmd.get_wizard().status = 'residue selected'
     cmd.refresh_wizard()
     
     # Select residues
     cmd.select("curPos", "curPos or (chain " + self.win.residue_list[i][1] + " and resi " + self.win.residue_list[i][2] + ")")
     sys.stdout.flush()
Ejemplo n.º 16
0
def getRots(site, variant): 
    cmd.get_wizard().set_mode(variant)
    # Key lines 
    # I dont know how they work, but they make it possible.
    # Jason wrote this: If you just write "site" instead of
    #                   "(site)", PyMOL will delete your
    #                   residue. "(site)" makes it an
    #                   anonymous selection.
    #print 'getRots'
    cmd.get_wizard().do_select("(" + str(site) + "/)")
    nRot = cmd.count_states("mutation") 
    return nRot 
Ejemplo n.º 17
0
    def complete_search(self, numMatches = -1):
        """
        callback called by FragmentThread when the
        search is complete
        """

        if (numMatches >= 0):
            print "number of matches = ", numMatches
            cmd.get_wizard().set_status('search complete', 'Search complete, %d matches' % numMatches)
        else:
            cmd.get_wizard().set_status('search complete')
        
        cmd.get_wizard().makeLogo = 7; # add search to menu
Ejemplo n.º 18
0
def mutXYZposition(residues):
    cmd.hide("everything")
    cmd.show("sticks")
    for resi in residues:
        for caa in residues[resi]:
            print(resi, caa)
            filename = "residue" + str(resi) + "to" + caa + ".csv"
            outfile = open(filename, "w")
            row = ("rotamer" + "," + "X" + "," + "Y" + "," + "Z" + "\n")
            cmd.wizard("mutagenesis")
            cmd.do("refresh_wizard")
            cmd.get_wizard().set_mode(caa)
            sel = "/test//A/" + str(resi)
            cmd.get_wizard().do_select(sel)
            fram = cmd.count_states("mutation")
            stored.pos = []
            cmd.iterate_state(0,
                              'mutation',
                              'stored.pos.append((x,y,z))',
                              atomic=0)
            counter = 1
            state = 1
            natom = int(len(stored.pos) / fram)
            for po in stored.pos:
                if counter < natom:
                    row = (str(state) + "," + str(po[0]) + "," + str(po[1]) +
                           "," + str(po[2]) + "\n")
                    outfile.write(row)
                    counter += 1
                elif counter == natom:
                    row = (str(state) + "," + str(po[0]) + "," + str(po[1]) +
                           "," + str(po[2]) + "\n")
                    outfile.write(row)
                    counter = 1
                    state += 1
            outfile.close()
            cmd.frame(fram)
            cmd.get_wizard().apply()
            cmd.set_wizard("done")
            cmd.save("residue" + str(resi) + "to" + caa + "rotamer" +
                     str(fram) + ".pdb")
            for f in range(1, fram):
                fra = fram - f
                cmd.wizard("mutagenesis")
                cmd.do("refresh_wizard")
                cmd.get_wizard().do_select(sel)
                cmd.frame(fra)
                cmd.get_wizard().apply()
                cmd.set_wizard("done")
                cmd.save("residue" + str(resi) + "to" + caa + "rotamer" +
                         str(fra) + ".pdb")
Ejemplo n.º 19
0
    def make_ids(self):
        
        if cmd.get_wizard().done_adding == True:

            # Set search options and current search
            searches = cmd.get_wizard().searches[0:]
            searches.insert(0, 'Search IDs: ')
            self.win.search_id.set(searches[0])
            
            # Remake window
            search_id = tk.OptionMenu(self.win, self.win.search_id, *searches).grid(row=10, column=0, rowspan=2, sticky=N+E+S+W)
            
            # Reset flag
            cmd.get_wizard().done_adding = False
Ejemplo n.º 20
0
    def complete_search(self, numMatches=-1):
        """
        callback called by SearchThread when the
        search is complete
        """

        if (numMatches >= 0):
            print "number of matches = ", numMatches
            cmd.get_wizard().set_status(
                'search complete', 'Search complete, %d matches' % numMatches)
            #            self.set_status('search complete')
        else:
            cmd.get_wizard().set_status('search complete')
        cmd.get_wizard().makeLogo = 1
Ejemplo n.º 21
0
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')
Ejemplo n.º 22
0
def pymol_mutate(file_name, chain, res_index):
    pymol.finish_launching()
    cmd.delete('all')
    selection = chain + '/' + res_index + '/'
    mutant = 'CYS'
    cmd.wizard("mutagenesis")
    pdb = file_name[:-4]
    cmd.load(file_name)
    cmd.remove('not (alt ''+A)')

    cmd.select('mut', 'resi ' + res_index + ' and chain ' + chain)
    if cmd.count_atoms('mut') == 0:
        return False

    cmd.refresh_wizard()
    cmd.get_wizard().set_mode(mutant)
    cmd.get_wizard().do_select(selection)
    nStates = cmd.count_states("mutation")
    for i in range(1, nStates + 1):
        cmd.get_wizard().do_select(selection)
        cmd.frame(i)
        cmd.get_wizard().apply()
        cmd.save("rec_" + str(res_index) + "_" + str(i) + ".pdb")

    cmd.set_wizard()
    cmd.remove(file_name[:-4])
    return True
Ejemplo n.º 23
0
 def test_CorrectChiDihedral(self):
     cmd.load(self.datafile("1rna.cif"))
     src_dihedral = cmd.get_dihedral("/1rna/A/A/14 & name O4'",
                                     "/1rna/A/A/14 & name C1'",
                                     "/1rna/A/A/14 & name N9",
                                     "/1rna/A/A/14 & name C4'")
     cmd.wizard("nucmutagenesis")
     cmd.select("/1rna/A/A/14")
     cmd.get_wizard().mode = "Guanine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     des_dihedral = cmd.get_dihedral("/1rna/A/A/14 & name O4'",
                                     "/1rna/A/A/14 & name C1'",
                                     "/1rna/A/A/14 & name N9",
                                     "/1rna/A/A/14 & name C4'")
     self.assertAlmostEqual(src_dihedral, des_dihedral, delta = 2.0)
Ejemplo n.º 24
0
 def test_CorrectChiDihedral(self):
     cmd.load(self.datafile("1rna.cif"))
     src_dihedral = cmd.get_dihedral("/1rna/A/A/14 & name O4'",
                                     "/1rna/A/A/14 & name C1'",
                                     "/1rna/A/A/14 & name N9",
                                     "/1rna/A/A/14 & name C4'")
     cmd.wizard("nucmutagenesis")
     cmd.select("/1rna/A/A/14")
     cmd.get_wizard().mode = "Guanine"
     cmd.get_wizard().do_select("sele")
     cmd.get_wizard().apply()
     des_dihedral = cmd.get_dihedral("/1rna/A/A/14 & name O4'",
                                     "/1rna/A/A/14 & name C1'",
                                     "/1rna/A/A/14 & name N9",
                                     "/1rna/A/A/14 & name C4'")
     self.assertAlmostEqual(src_dihedral, des_dihedral, delta=2.0)
Ejemplo n.º 25
0
    def make_ids(self):
        
        if cmd.get_wizard().done_adding == True:

            # Set search options and current search
            searches = cmd.get_wizard().searches[0:]
            searches.insert(0, 'Search IDs: ')
            self.win.search_id.set(searches[0])
            
            # Remake window
            search_id = tk.OptionMenu(self.win, self.win.search_id, *searches).grid(row=10, column=0, rowspan=2, sticky=N+E+S+W)
            
            # Reset flag
            cmd.get_wizard().done_adding = False
        
        # Repeat
        cmd.get_wizard().app.root.after(100, self.make_ids)
Ejemplo n.º 26
0
    def launch_search(self):
        """
        launches the search in the separate thread
        does some basic checking and gets selection
        """
        
        # gets the active selections from pymol
        active_selections = cmd.get_names('selections', 1)
        if len(active_selections) == 0:
            cmd.get_wizard().set_status('no selection')
        else:

            selection = active_selections[0]
            print "The active selections are " + str(selection)
            pdbstr = cmd.get_pdbstr(selection)
            print 'pdbstr is', pdbstr
            self.stop_search()
            
#            print cmd.get_wizard(), self.win.rmsd.get(), self.win.num_structs.get(), self.win.full_match, self.win.datab, pdbstr, self.win.serverURL, cmd.get_wizard().cmd, self.win.jobIDs

            self.win.searchThread = SearchThread(cmd.get_wizard(), self.win.rmsd.get(),
                                self.win.num_structs.get(), self.win.full_match,
                                self.win.datab, pdbstr, self.win.serverURL, cmd.get_wizard().cmd, self.win.jobIDs)
            self.win.searchThread.start()
            cmd.get_wizard().set_status('search launched')
            cmd.get_wizard().searchProgress = 0
        
        cmd.refresh_wizard()
Ejemplo n.º 27
0
    def launch_search(self):
        """
        launches the search in the separate thread
        does some basic checking and gets selection
        """

        # gets the active selections from pymol
        active_selections = cmd.get_names('selections', 1)
        if len(active_selections) == 0:
            cmd.get_wizard().set_status('no selection')
        else:

            selection = active_selections[0]
            print "The active selections are " + str(selection)
            pdbstr = cmd.get_pdbstr(selection)
            print 'pdbstr is', pdbstr
            self.stop_search()

            #            print cmd.get_wizard(), self.win.rmsd.get(), self.win.num_structs.get(), self.win.full_match, self.win.datab, pdbstr, self.win.serverURL, cmd.get_wizard().cmd, self.win.jobIDs

            self.win.searchThread = SearchThread(cmd.get_wizard(),
                                                 self.win.rmsd.get(),
                                                 self.win.num_structs.get(),
                                                 self.win.full_match,
                                                 self.win.datab, pdbstr,
                                                 self.win.serverURL,
                                                 cmd.get_wizard().cmd,
                                                 self.win.jobIDs)
            self.win.searchThread.start()
            cmd.get_wizard().set_status('search launched')
            cmd.get_wizard().searchProgress = 0

        cmd.refresh_wizard()
Ejemplo n.º 28
0
    def getLogoFile(self, filepath):
        cmd.get_wizard().status = 'vector graphic requested'
        cmd.refresh_wizard()

        ext = filepath.split(".")[-1]

        cmd.get_wizard().status = 'logo file request launched'
        cmd.refresh_wizard()
        self.win.logoThread = LogoThread(self.win.jobIDs[self.win.search],
                                         int(self.win.logo_flag),
                                         self.win.serverURL,
                                         cmd.get_wizard().cmd, filepath, ext)

        self.win.logoThread.start()
        self.win.logoThread.join()

        cmd.get_wizard().status = 'vector graphic received'
        cmd.refresh_wizard()
Ejemplo n.º 29
0
def doubleMut(original, positions, residues):
    cmd.hide("everything")
    cmd.show("sticks")

    posone = positions[0][0]
    chainone = positions[0][1]
    postwo = positions[1][0]
    chaintwo = positions[1][1]

    outfile = open("forheatmap.csv", "w")

    #generate the protein with one mutation
    for a in residues:
        cmd.create(a, original)
        cmd.wizard("mutagenesis")
        cmd.do("refresh_wizard")
        cmd.get_wizard().set_mode(a)
        sel = "/" + a + "//" + str(chainone) + "/" + str(posone)
        cmd.get_wizard().do_select(sel)
        cmd.get_wizard().apply()

    for m in residues:  #for all the mutations generated
        for i in residues:  #for each residue to which will be mutated
            name = m + "2"
            cmd.create(name, m)
            cmd.wizard("mutagenesis")
            cmd.do("refresh_wizard")
            cmd.get_wizard().set_mode(i)
            se = "/" + name + "//" + str(chaintwo) + "/" + str(postwo)
            cmd.get_wizard().do_select(se)
            mut_name = "mutation"
            if cmd.count_states(mut_name) != 1:
                bump_name = "_bump_check"
                cmd.sculpt_activate(bump_name)
                scores = []
                for rotamer in range(1, 1 + cmd.count_states(bump_name)):
                    score = cmd.sculpt_iterate(bump_name, rotamer, 1)
                    scores.append(score)
                scores.sort(reverse=True)
                row = (i + "," + m + "," + str(scores[0]) + "\n")
            else:
                row = (i + "," + m + "," + "?" + "\n")
            outfile.write(row)
    outfile.close()
Ejemplo n.º 30
0
    def saveFile(self):

        extensions = [('PDF', '.pdf'), ('EPS', '.eps'), ('GIF', '.gif'), ('PNG', '.png')]
        f = tkFileDialog.asksaveasfile(mode='w', defaultextension=".pdf", filetypes=extensions)

        # the user cancelled the save
        if f is None:
            cmd.get_wizard().status = 'Save Cancelled'
            cmd.refresh_wizard()
            return

        # get the EPS file from the server and write it
        self.getLogoFile(f.name)
        
        cmd.get_wizard().filename = f.name
        
        f.close()
        cmd.get_wizard().status = 'SequenceLogo saved'
        cmd.refresh_wizard()
Ejemplo n.º 31
0
def check_disulphide(pdb, resnum_i, resnum_j, f):

	selection_i = "resi " + str(resnum_i)
	selection_j = "resi " + str(resnum_j)

	# cmd.wizard("mutagenesis")

	# cmd.get_wizard().set_mode("CYS")

	cmd.do("refresh_wizard")
	# Select the rotamer
	for frame_i in [1, 2, 3]:
		# cmd.do("refresh_wizard")

		cmd.get_wizard().do_select(selection_i)
		cmd.frame(frame_i)
		cmd.create("rotamer_i_" + str(frame_i), "mutation", frame_i, 1)
		rotamer_i_pymol_prefix = "/" + "rotamer_i_" + str(frame_i) + "///" + resnum_i + "/"


	for frame_j in [1, 2, 3]:

		# cmd.do("refresh_wizard")

		cmd.get_wizard().do_select(selection_j)
		cmd.frame(frame_j)
		cmd.create("rotamer_j_" + str(frame_j), "mutation", frame_j, 1)
		rotamer_j_pymol_prefix = "/" + "rotamer_j_" + str(frame_j) + "///" + resnum_j + "/"

		# s_gamma_distance = cmd.get_distance(rotamer_i_pymol_prefix + "SG", rotamer_j_pymol_prefix + "SG")
		# print s_gamma_distance

	cmd.set_wizard("clear")

	for frame_i in [1, 2, 3]:
		rotamer_i_pymol_prefix = "/" + "rotamer_i_" + str(frame_i) + "///" + resnum_i + "/"
		for frame_j in [1, 2, 3]:
			rotamer_j_pymol_prefix = "/" + "rotamer_j_" + str(frame_j) + "///" + resnum_j + "/"

			s_gamma_distance = cmd.get_distance(rotamer_i_pymol_prefix + "SG", rotamer_j_pymol_prefix + "SG")

			print s_gamma_distance
Ejemplo n.º 32
0
    def add_new_graft(self, search_id):
        '''
        add current search to search history after it finishes
        '''
        # print 'add new search'
        self.grafts.append(graft_id)
        cmd.refresh_wizard()

        # Trip flag for window
        self.done_adding = True
        cmd.get_wizard().makeLogo = 7
Ejemplo n.º 33
0
    def add_new_search(self, search_id):
        '''
        add current search to search history after it finishes
        '''
        # print 'add new search'
        self.win.searches.append(search_id)
        cmd.refresh_wizard()

        # Trip flag for window
        self.win.done_adding = True
        cmd.get_wizard().makeLogo = 1
Ejemplo n.º 34
0
    def getLogoFile(self, filepath):
        cmd.get_wizard().status = 'vector graphic requested'
        cmd.refresh_wizard()

        ext = filepath.split(".")[-1]
            
        cmd.get_wizard().status = 'logo file request launched'
        cmd.refresh_wizard()
        self.win.logoThread = LogoThread(
            self.win.jobIDs[self.win.search],
            int(self.win.logo_flag),
            self.win.serverURL,
            cmd.get_wizard().cmd,
            filepath,
            ext)
            
        self.win.logoThread.start()
        self.win.logoThread.join()

        cmd.get_wizard().status = 'vector graphic received'
        cmd.refresh_wizard()
Ejemplo n.º 35
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()
Ejemplo n.º 36
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()
Ejemplo n.º 37
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()
Ejemplo n.º 38
0
    def saveFile(self):

        extensions = [('PDF', '.pdf'), ('EPS', '.eps'), ('GIF', '.gif'),
                      ('PNG', '.png')]
        f = tkFileDialog.asksaveasfile(mode='w',
                                       defaultextension=".pdf",
                                       filetypes=extensions)

        # the user cancelled the save
        if f is None:
            cmd.get_wizard().status = 'Save Cancelled'
            cmd.refresh_wizard()
            return

        # get the EPS file from the server and write it
        self.getLogoFile(f.name)

        self.win.filename = f.name

        f.close()
        cmd.get_wizard().status = 'SequenceLogo saved'
        cmd.refresh_wizard()
Ejemplo n.º 39
0
    def residue_select(self, i):

        # Show selection message
        self.win.res_info = 'click search chain ' + self.win.residue_list[i][
            1] + ' num ' + self.win.residue_list[i][2]
        cmd.get_wizard().status = 'residue selected'
        cmd.refresh_wizard()

        # Select residues
        cmd.select(
            "curPos", "curPos or (chain " + self.win.residue_list[i][1] +
            " and resi " + self.win.residue_list[i][2] + ")")
        sys.stdout.flush()
Ejemplo n.º 40
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
Ejemplo n.º 41
0
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()
Ejemplo n.º 42
0
def mutate_one(selection, aa):
    """
    Selection must be one residue
    """
    assert is_one_residue(selection)
    cmd.select(selection)
    cmd.get_wizard().do_select('''sele''')
    cmd.get_wizard().set_mode(aa)
    cmd.get_wizard().apply()
    print(f"Mutated {selection} to {aa}")
Ejemplo n.º 43
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()
Ejemplo n.º 44
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()
Ejemplo n.º 45
0
def pymol_mutate(file_name, chain, res_index, number, mutant):
    pymol.finish_launching()
    cmd.delete(file_name[:-4])
    selection = chain + '/' + res_index + '/'
    cmd.wizard("mutagenesis")
    pdb = file_name[:-4]
    cmd.load(file_name)
    cmd.refresh_wizard()
    cmd.get_wizard().set_mode(mutant)
    cmd.get_wizard().do_select(selection)
    nStates = cmd.count_states("mutation")
    for i in range(1, nStates + 1):
        cmd.get_wizard().do_select(selection)
        cmd.frame(i)
        cmd.get_wizard().apply()
        cmd.save("rec_" + str(res_index) + "_" + str(i) + ".pdb")

    cmd.set_wizard()
    cmd.remove(file_name[:-4])
Ejemplo n.º 46
0
    def getLogoFile(self, filepath):
        cmd.get_wizard().status = 'vector graphic requested'
        cmd.refresh_wizard()

        ext = filepath.split(".")[-1]

        logoThread = LogoThread(
            cmd.get_wizard().rmsd_cutoff,
            cmd.get_wizard().dictionary[cmd.get_wizard().search],
            int(cmd.get_wizard().logo_flag),
            cmd.get_wizard().LOGOurl,
            cmd.get_wizard().cmd,
            filepath,
            ext)
            
        logoThread.start()
        logoThread.join()

        cmd.get_wizard().status = 'vector graphic received'
        cmd.refresh_wizard()
Ejemplo n.º 47
0
def pymutate(pdb, new_seq, nametag, ter = [-1]):
    ''' Mutate a pymol pdb object according to a new sequence.
        Terminals are charged by default (-1 value) '''
    
    cmd.load(pdb)
    orig_sequence = setNames(pdb)
   
    if len(new_seq) != len(orig_sequence):
        raise ValueError('Length of mutated sequence not matching original one')
        
    cmd.do('wizard mutagenesis')
    cmd.do('refresh_wizard')

    for new in range(len(orig_sequence)):
    
        if new_seq[new] != orig_sequence[new][1]:
            if new+1 in ter:
                cmd.get_wizard().set_n_cap("posi")
            cmd.get_wizard().set_mode(new_seq[new])
            cmd.get_wizard().do_select(str(orig_sequence[new][0])+'/')
            cmd.frame(1)
            cmd.get_wizard().apply()
    
    # Protonation of the N.
    #cmd.edit("n%d" % int(site), None, None, None, pkresi=0, pkbond=0)
    
     #           # 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") 

    seq_onelett = ''
    for lett in range(len(orig_sequence)):
        seq_onelett = seq_onelett + getOne(new_seq[lett])

    name = "./%s_%s.pdb" % (seq_onelett, nametag)
    cmd.save(name)
    cmd.do('delete all') 
    cmd.set_wizard('done')
    
    return name
Ejemplo n.º 48
0
def pymol_mutate(file_name, chain, res_index, number):
    pymol.finish_launching()
    cmd.delete(file_name[:-4])
    selection = chain + '/' + res_index + '/'
    mutant = 'CYS'
    cmd.wizard("mutagenesis")
    pdb = file_name[:-4]
    cmd.load(file_name)
    cmd.refresh_wizard()
    cmd.get_wizard().set_mode(mutant)
    cmd.get_wizard().do_select(selection)
    nStates = cmd.count_states("mutation")

    for i in range(1, nStates + 1):
        cmd.get_wizard().do_select(selection)
        cmd.frame(i)
        cmd.get_wizard().apply()
        cmd.save("rec_" + str(res_index) + "_" + str(i) + ".pdb")

    cmd.set_wizard()
    cmd.remove(file_name[:-4])
Ejemplo n.º 49
0
def mutate_to_cys(pdb, resnum_i):
	selection_i = "resi " + str(resnum_i)
	cmd.wizard("mutagenesis")

	cmd.get_wizard().set_mode("CYS")

	cmd.do("refresh_wizard")

	cmd.get_wizard().do_select(selection_i)
	cmd.get_wizard().do_select(selection_i)

	for frame_i in [1, 2, 3]:
		cmd.frame(frame_i)
		cmd.create("rotamer_" + str(resnum_i) + "_" + str(frame_i), "mutation", frame_i, 1)
		rotamer_i_pymol_prefix = "/" + "rotamer_" + str(resnum_i) + "_" + str(frame_i) + "///" + resnum_i + "/"

	cmd.set_wizard("done")
Ejemplo n.º 50
0
def extractStrain(residues):
    cmd.hide("everything")
    cmd.show("sticks")
    for resi in residues:
        for caa in residues[resi]:
            filename = "residue" + str(resi) + "to" + caa + ".csv"
            outfile = open(filename, "w")
            print(resi, caa)
            cmd.wizard("mutagenesis")
            cmd.do("refresh_wizard")
            cmd.get_wizard().set_mode(caa)
            sel = "/test//A/" + str(resi)
            cmd.get_wizard().do_select(sel)
            bump_name = "_bump_check"
            cmd.sculpt_activate(bump_name)
            cmd.set("sculpt_vdw_vis_mode", 1, bump_name)
            for rotamer in range(1, 1 + cmd.count_states(bump_name)):
                score = cmd.sculpt_iterate(bump_name, rotamer, 1)
                row = (str(rotamer) + "," + str(score) + "\n")
                outfile.write(row)
            outfile.close()
            cmd.get_wizard().clear()
def thread_onto_backbone(backbone_object, backbone_selection, aaString):
#
# 
#  
# create a new temporary dictionary
  stored.tmp_res_dict = {}
  
# store residue indices(=key) and chain(=value)
  cmd.iterate(backbone_selection, "stored.tmp_res_dict[resi] = chain")
  
# create a sorted list of all indices as integers  
  sorted_keys_list = []
  for index_string in stored.tmp_res_dict.keys(): 
    sorted_keys_list.append(int(index_string))
  sorted_keys_list.sort()
  
# set up the mutagenesis wizard
  cmd.wizard("mutagenesis")
  cmd.refresh_wizard()
  
  count = 0
 
  for residue_index in range(sorted_keys_list[0], sorted_keys_list[0] + len(sorted_keys_list) ):
    # get a selection string representation of our current residue
    # e.g. /HPG-3//A/12
    index_string = "%d" %(residue_index)
    selection_str = "/" + backbone_object + "//"+ stored.tmp_res_dict[index_string] + "/%d/" %(residue_index)
    
    # perform the desired mutagenesis
    cmd.get_wizard().do_select(selection_str)
    cmd.get_wizard().set_mode(aaName(aaString[count]))
    cmd.get_wizard().apply()
    
    count = count + 1
    
# close up the mutagenesis wizard    
  cmd.set_wizard()
Ejemplo n.º 52
0
def display_logo(app, query, residues, search_id, flag):

    window = Toplevel(app.root)

    if flag == 1:
        logo_filepath = LOGO_CACHE + str(query)+"s.gif"
    elif flag == 2:
        logo_filepath = LOGO_CACHE + str(query)+"f.gif"

    img = PhotoImage(file = logo_filepath)

    logo = Label(window, image=img)
    logo.photo = img;
    logo.pack(fill = BOTH, expand = 1, side = TOP)

    window.update()

    # parse query, add residues to a list for later reference
    residues_str = residues.split()
    residue_list = []

    # selected list lets us check if the residue is selected or not
    selected_list = []

    for residue_str in residues_str:
        residue = residue_str.split(',')
        residue_list.append(residue)
        selected_list.append(False)

    # some temporary values to play around with
    total_width = 1.5*(len(residue_list)) + 1.905
    left_margin = 53
    right_margin = 14

    total_num_residues = len(residue_list)

    # set up empty initial selection object
    cmd.select("curPos", "none")

    # create the textbox with the residue names
    textview = Text(window, height = 1, width = int(total_width), font=("Courier",15))
    textview.config(cursor="left_ptr")
    textview.config(background = "black")
    textview.config(foreground = "green2")
    textview.pack(side = BOTTOM, fill = BOTH, expand = 1, padx = (left_margin, right_margin))

    # set up the indices that will change on click down and up, respectively
    start = -1

    for i in range(0, total_num_residues):

        # add the residue character into the string, with the associated tag
        textview.tag_configure(str(i))
        textview.insert(END, residue_list[i][0], str(i))

    textview.config(state=DISABLED)

    def mouse_down(event):
        global start

        # try to get the index based on the click coordinates
        i = int(math.ceil((event.x-3)/9))

        # make sure you are in the window
        if(event.y>20 or event.y<2):
            return

        # must be a valid index
        if(i >= total_num_residues):
            return

        # set the start index of the dragging
        start = i

        # handle selection/deselection
        if(selected_list[i]):
            textview.tag_configure(str(i), background ='black')
            textview.tag_configure(str(i), foreground = "green2")
            residue_deselect(i)
            selected_list[i] = False

        else:
            textview.tag_configure(str(i), background ='green2')
            textview.tag_configure(str(i), foreground = "black")
            residue_select(i)
            selected_list[i] = True

    def mouse_drag(event):
        # try to get the index of the selected characters, and look up residue for selection
        global start
        i = int(math.ceil((event.x-3)/9))

        # make sure you are in the window
        if(event.y>20 or event.y<2):
            return

        # must be a valid index
        if(i >= total_num_residues):
            return

        # don't worry about the one you just selected
        if start != i:

            # handle selection/deselection
            if(selected_list[i]):
                textview.tag_configure(str(i), background ='black')
                textview.tag_configure(str(i), foreground = "green2")
                residue_deselect(i)
                selected_list[i] = False
                start = i

            else:
                textview.tag_configure(str(i), background ='green2')
                textview.tag_configure(str(i), foreground = "black")
                residue_select(i)
                selected_list[i] = True
                start = i

    def residue_select(i):
        print 'click search chain '+residue_list[i][1]+' num '+residue_list[i][2]
        cmd.select("curPos", "curPos or (chain " + residue_list[i][1] + " and resi " + residue_list[i][2] + ")")
        sys.stdout.flush()

    def residue_deselect(i):
        cmd.select("curPos", "curPos and not (chain " + residue_list[i][1] + " and resi " + residue_list[i][2] + ")")

    # this should bind the highlight event to the test event
    textview.bind("<Button-1>", mouse_down)
    textview.bind("<B1-Motion>", mouse_drag)

    window.after(100, cmd.get_wizard().update())
    window.mainloop()
Ejemplo n.º 53
0
# pymol -qc mutate.py pdb selection new_residue
# example: pymol -qc mutate.py 0.pdb C/1/ ALA 0_mutated.pdb

# run for all the confs in the ensemble
# append all to one using mdconvert

from pymol import cmd
import sys

pdb, selection, mutant, output_name = sys.argv[-4:]
print("file:", pdb)
print("selection:", selection)
print("mutating to:", mutant)
print("output name:", output_name)

cmd.load(pdb, "file")

cmd.wizard("mutagenesis")
cmd.refresh_wizard()
cmd.get_wizard().do_select(selection)
cmd.get_wizard().set_mode(mutant)
cmd.get_wizard().apply()
cmd.set_wizard()

cmd.save(output_name, "file")
Ejemplo n.º 54
0
def mutate(selection, new_resn, inplace=0, sculpt=0, hydrogens='auto', mode=0, quiet=1):
    '''
DESCRIPTION

    Mutate a single residue. Does call the mutagenesis wizard non-interactively
    and tries to select the best rotamer. Can do some sculpting in the end to
    the best rotamer.

USAGE

    mutate selection, new_resn [, inplace [, sculpt [, hydrogens]]]

ARGUMENTS

    selection = string: atom selection of single residue

    new_resn = string: new residue name (3-letter or 1-letter)

    inplace = 0 or 1: work on copy of input object if 0 {default: 0}

    sculpt = 0: no sculpting {default}
    sculpt = 1: do sculpting on best rotamer
    sculpt = 2: do sculpting with neighbors

    hydrogens = string: keep, auto or none {default: auto}

    mode = 0: select rotamer with best clash score {default}
    mode = 1: take chi angles from original residue
    mode = 2: first rotamer

EXAMPLE

    fetch 2x19, async=0
    select x, A/CYS`122/
    zoom x
    mutate x, LYS
    '''
    from pymol.wizard import mutagenesis
    from . import three_letter

    inplace, sculpt = int(inplace), int(sculpt)
    mode = int(mode)
    quiet = int(quiet)
    org = cmd.get_object_list(selection)[0]
    tmp = cmd.get_unused_name()
    new_resn = new_resn.upper()
    new_resn = three_letter.get(new_resn, new_resn)

    if inplace:
        cpy = org
    else:
        cpy = cmd.get_unused_name(org + '_cpy')
        cmd.create(cpy, org, -1, 1, zoom=0)

    scr = []
    cmd.iterate('first (%s)' % selection, 'scr[:] = (segi,chain,resi,resn)', space={'scr': scr})
    res = '/%s/%s/%s/%s' % tuple([cpy] + scr[:3])

    if mode == 1:
        old_resn = scr[3]
        chi_atoms = {
            'ALA': [],
            'ARG': ['C','CA','CB','CG','CD','NE','CZ'],
            'ASN': ['C','CA','CB','CG','OD1'],
            'ASP': ['C','CA','CB','CG','OD1'],
            'CYS': ['C','CA','CB','SG'],
            'GLN': ['C','CA','CB','CG','CD','OE1'],
            'GLU': ['C','CA','CB','CG','CD','OE1'],
            'GLY': [],
            'HIS': ['C','CA','CB','CG','ND1'],
            'ILE': ['C','CA','CB','CG1','CD1'],
            'LEU': ['C','CA','CB','CG','CD1'],
            'LYS': ['C','CA','CB','CG','CD','CE','NZ'],
            'MET': ['C','CA','CB','CG','SD','CE'],
            'MSE': ['C','CA','CB','CG','SE','CE'],
            'PHE': ['C','CA','CB','CG','CD1'],
            'PRO': [],
            'SER': ['C','CA','CB','OG'],
            'THR': ['C','CA','CB','OG1'],
            'TRP': ['C','CA','CB','CG','CD2'],
            'TYR': ['C','CA','CB','CG','CD1'],
            'VAL': ['C','CA','CB','CG2'],
        }
        atoms = [res + '/' + name for name in chi_atoms.get(old_resn, [])]
        old_chi = []
        for args in zip(atoms, atoms[1:], atoms[2:], atoms[3:]):
            try:
                old_chi.append(cmd.get_dihedral(*args))
            except:
                break

    cmd.remove('%s and not name CA+C+N+O+OXT' % (res))

    # start the wizard to count the number of rotamers for this residue
    cmd.wizard("mutagenesis")
    cmd.get_wizard().set_mode(new_resn)
    cmd.get_wizard().set_hyd(hydrogens)
    cmd.get_wizard().do_select("("+res+")")

    def get_best_state_bump():
        best_state = (1, 1e9)
        cmd.create(tmp, '%s and not name CA+C+N+O or (%s within 8.0 of (%s and name CB))' % \
                (mutagenesis.obj_name, cpy, mutagenesis.obj_name), zoom=0, singletons=1)
        cmd.bond('name CB and %s in %s' % (tmp, mutagenesis.obj_name),
                'name CA and %s in %s' % (tmp, res))
        cmd.sculpt_activate(tmp)
        for i in range(1, cmd.count_states(tmp)+1):
            score = cmd.sculpt_iterate(tmp, state=i)
            if not quiet:
                print('Frame %d Score %.2f' % (i, score))
            if score < best_state[1]:
                best_state = (i, score)
        cmd.delete(tmp)
        if not quiet:
            print(' Best: Frame %d Score %.2f' % best_state)
        return best_state

    if cmd.count_states(mutagenesis.obj_name) < 2 or mode > 0:
        best_state = (1, -1.0)
    else:
        best_state = get_best_state_bump()
    cmd.frame(best_state[0])
    cmd.get_wizard().apply()
    cmd.wizard()

    if mode == 1:
        atoms = [res + '/' + name for name in chi_atoms.get(new_resn, [])]
        for args in zip(atoms, atoms[1:], atoms[2:], atoms[3:], old_chi):
            cmd.set_dihedral(*args)
        cmd.unpick()

    if sculpt > 0:
        sculpt_relax(res, 0, sculpt == 2, cpy)

    return cpy
Ejemplo n.º 55
0
    def set_and_search(self):

        # Set RMSD cutoff
        if self.is_num(self.win.rmsd.get()):
            cmd.get_wizard().set_rmsd(float(self.win.rmsd.get()))
        else:
            cmd.get_wizard().status = 'rmsd not number'
            cmd.refresh_wizard()
            return

        # Set number of structures
        if self.is_num(self.win.num_structs.get()):
            cmd.get_wizard().set_num_structures(self.win.num_structs.get())
        else:
            cmd.get_wizard().status = 'num matches not number'
            cmd.refresh_wizard()
            return

        # Set Database
        if self.win.db == "Test DB":
            cmd.get_wizard().set_database("Test")
        elif self.win.db == "Full DB":
            cmd.get_wizard().set_database("Full")

        # Set Full matches
        if self.win.fm == "Region":
            cmd.get_wizard().set_full_matches(False)
        elif self.win.fm == "Full":
            cmd.get_wizard().set_full_matches(True)

        # Launch the search
        cmd.get_wizard().launch_search()
Ejemplo n.º 56
0
 def callback(self):
     
     # Reset flag for making popup
     cmd.get_wizard().live_app = False
     self.win.destroy()
Ejemplo n.º 57
0
 def callback(self):
     cmd.refresh_wizard()
     # Reset flag for making popup
     cmd.get_wizard().fuser_app = False
     self.win.destroy()
Ejemplo n.º 58
0
    def display_menu_logo(self, app, query, residues, rmsd_cutoff, LOGOurl, flag, plugin):
        """
        This method handles creating a SequenceLogo UI with Tkinter
        author = Ben + Nick
        """
        
        # placeholder for logo graphic
        placeholder = tk.Label(self.win, background='white', text = "                                                                                                                 ").grid(row=0, column=2, rowspan=14, columnspan=5, sticky=N+E+S+W)

        # Create the filepath name
        if flag == 1:
            logo_filepath = LOGO_CACHE + str(query)+"s.gif"
        elif flag == 2:
            logo_filepath = LOGO_CACHE + str(query)+"f.gif"
        
        # Set permanent flag (1/2)
        cmd.get_wizard().logo_flag = flag
        
        # Get the coordinates of the image
        self.win.coords = self.get_image_size(logo_filepath)
        self.win.width = self.win.coords[0]

        # Get the image
        self.win.img = tk.PhotoImage(file=logo_filepath)

        # Make a canvas, display the image, and save a reference
        self.win.canvas = tk.Canvas(self.win)
        self.win.canvas.create_image(self.win.width/2, 100, image=self.win.img)
        self.win.canvas.photo = self.win.img

        # Make the whole area scrollable
        self.win.canvas.config(bg='white', scrollregion = self.win.canvas.bbox("all"))

        # Place the canvas
        self.win.canvas.grid(row=0, column=2, rowspan=13, columnspan=4, sticky=N+E+S+W)
        
        #  Make window rescalable
        for p in range(13):
            self.win.grid_rowconfigure(p, weight=1)
        
        for q in range(2, 6):
            self.win.grid_columnconfigure(q, weight=1)
        
        # Create a scrollbar and link it with the canvas
        self.win.sb = AutoScrollbar(self.win, orient=tk.HORIZONTAL)
        self.win.sb.grid(row=13, column=2, columnspan=4, sticky=E+W)
        self.win.sb.config(bg='white', command=self.win.canvas.xview)
        
        self.win.sbv = AutoScrollbar(self.win, orient=tk.VERTICAL)
        self.win.sbv.grid(row=0, column=6, rowspan=12, sticky=N+S)
        self.win.sbv.config(bg='white', command=self.win.canvas.yview)
        
        #link scrollbars
        self.win.canvas.config(xscrollcommand=self.win.sb.set, yscrollcommand=self.win.sbv.set)
    
        # parse query, add residues to a list for later reference
        residues_str = residues.split()
        self.win.residue_list = []

        # Create residue list
        for residue_str in residues_str:
            residue = residue_str.split(',')
            self.win.residue_list.append(residue)
        
        # Write characters and underbar under residue
        x = 68
        for each_char in range(len(self.win.residue_list)):
            self.win.canvas.create_text(x, 180, text=str(self.win.residue_list[each_char][0]))
            self.win.linelist.append(self.win.canvas.create_line(x-4, 190, x+5.4, 190, width=2, fill='black'))
            self.binder(each_char)
            x += 18.8

        # set up empty initial selection object used by PyMol to group selections
        cmd.select("curPos", "none")
def frag(state=state, obj=obj3): 
    pwd, orig_sequence = setup(obj)
    stored.rotamerDict = {}
    # Add and retain hydrogens
    cmd.get_wizard().set_hyd("keep") 

    # Run over all sites where to mutate
    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().do_select("(%s/)" % site)
            cmd.do("cmd.get_wizard().set_mode('%s')"%variant)

            # Get the number of available rotamers at that site
            # Introduce a condition here to check if 
            # rotamers are requested. 
            # <<OPTION>>
            print variant, "variant"
            nRots = getRots(site, variant)
            nRots = 2
            stored.rotamerDict[str(site)+getOne(variant)] = nRots

            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."
                localSculpt(obj, 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-' + getOne(orig_sequence[site]).lower() +\
                               site + getOne(variant).lower() + '-rot%i-%s.pdb, ' \
                               % (i,state) +'((%s/))' % site
                #print saveString 
                cmd.do('save %s' % saveString)
            cmd.do('delete all') 
            cmd.set_wizard('done')
    print "Frag is all done"
Ejemplo n.º 60
0
    def set_and_search(self):
        print 'a'
        
        # Max and Min fuse length checks
        if self.is_num(str(self.range_max.get())):
            print 'b'
            pass
        else:
            print 'c'
            cmd.get_wizard().status = 'range input not number'
            cmd.refresh_wizard()
            return
        
        if self.is_num(str(self.range_min.get())):
            pass
        else:
            cmd.get_wizard().status = 'range input not number'
            cmd.refresh_wizard()
            return
        print 'q'
        if self.pdbstr_n == None or self.pdbstr_c == None:
            print 'requires two stubs'
            return
        print 't'
        
        
        # Set RMSD cutoff
        if self.is_num(self.rmsd.get()):
            pass
        else:
            cmd.get_wizard().status = 'rmsd not number'
            cmd.refresh_wizard()
            return
        print 'o'
        # Set number of structures
        if self.is_num(self.num_structs.get()):
            pass
        else:
            cmd.get_wizard().status = 'num matches not number'
            cmd.refresh_wizard()
            return
        print '3'
        # Set Database
        if self.db.get() == "Test DB":
            self.database_type = DATABASE_TEST
        elif self.db.get() == "Full DB":
            self.database_type = DATABASE_FULL
        print '6'
        # Set Full matches
        if self.fm.get() == "Region":
            print 7
            self.full_match = False
        elif self.fm.get() == "Full":
            print 9
            self.full_match = True
        print 10


        print self.pdbstr, self.rmsd.get(), self.num_structs.get(), self.full_match, self.database_type, float(self.range_max.get()), float(self.range_min.get()), self.serverURL

        self.stop_search()
        print 'go'
        self.pdbstr = (self.pdbstr_n[:-4] + self.pdbstr_c) # without 'END'
        print 'gogo'
        self.fragmentThread = FragmentThread(cmd.get_wizard(), self.pdbstr, self.rmsd.get(), self.num_structs.get(), self.full_match, self.database_type, float(self.range_max.get()), float(self.range_min.get()), self.serverURL, cmd.get_wizard().cmd)
                            
        self.fragmentThread.start()
        cmd.get_wizard().set_status('search launched')
        cmd.get_wizard().searchProgress = 0
        
        cmd.refresh_wizard()