from pymol import cmd import os import sys from pymol import stored from os.path import splitext # ************************************************************ # ------------------------------------------------------------ # VSC: Variant Side Chains of BCX # Modifies selection around substrate, mutations based on # current 'resn'. # ------------------------------------------------------------ # ************************************************************ # DESCRIPTION: # - Mutate a residue and save the fragment amino acid. # PyMOL: # - modify>around: residues select, substrate excluded # - modify>expand: residues select, substrate included # MODE: prod = 'production' debug = 'debugging' mode = prod # PREPARATION: # - Enter 'set retain_order, 0' to protect atom ordering. # - Substrate resi set to 500 # - Substrate resn and chain set to 'LIG' and A # NOTE: # - Probably hydrogen addition to N- and C- can # be discarded for complete enzyme chains # Auto build-up of mutations dictionary. # First select residues to mutate, then select alpha carbons of the new selection # then store the residue number of those alpha carbons. # PyMOL> cmd.select("lig-es-default", "resi 500", enable=1) # PyMOL> cmd.select("lig-es-around", "(byres (lig-es-default around 4))", enable=1) # PyMOL> cmd.select("lig-es-around-ca", "lig-es-around and name ca", enable=1) # PyMOL> cmd.do("iterate (lig-es-around-ca)", stored.li.append(resi)") # REQUIRES: # - PDB file to mutate # CALLING orig_sequence: # PyMOL> cd directory/containing/vsc-set.py # PyMOL> run vsc-set.py # PyMOL> frag # PARAMETERS: # - dictionary below obj = 'ge-onp-opt-pm6-1.0-15.pdb' sub = '500' distance = '4' state = sys.argv[1] # OPTIONS: # - The number of conformers can be adjusted. # - The mutated side chain can be optimized locally by vdW minimization. # ************************************************************ def setup(obj): """ Calling sequence of setup: PyMOL> run vsc-set.py PyMOL> setup Variables: 'mutations': {'':['', '', ...]} """ # Setup. pwd = os.getcwd() #cmd.do('wizard mutagenesis') #cmd.do('refresh_wizard') # {'':''} orig_sequence = set_names(obj) # Catalytically active positions. do_not_mutate = ['78', '172'] if mode == prod: all_side_chains = ['ALA', 'ARG', 'ASN', 'ASP', 'CYS', 'GLU', 'GLN', 'GLY', 'HIS', 'ILE', 'LEU', 'LYS', 'MET', 'PHE', 'PRO', 'SER', 'THR', 'TRP', 'TYR', 'VAL' ] else: all_side_chains = ['PHE', 'ASP', 'ILE'] positions_in_selection = get_all_positions_in_selection(sub, distance) # 1) Avoid mutation of critical positions. # 2) All side chains are included, discarding is controlled on MOPAC side. mutations = {} for i in positions_in_selection: if i[0] not in do_not_mutate: current_resn = i[1] mutations[i[0]] = all_side_chains for i in mutations.keys(): print i, mutations[i] return pwd, mutations, orig_sequence # ------------------------------------------------------------ # ************************************************************ def get_all_positions_in_selection(sub, distance): cmd.do("select lig-def, resi %s" % sub) cmd.select("lig-around", "(byres (lig-def around %s))" % distance) cmd.select("lig-around-ca", "lig-around and name ca") cmd.do("stored.li = []") cmd.do("iterate (lig-around-ca), stored.li.append((resi, resn))") cmd.do("delete all") if mode == prod: return stored.li else: return [('71', 'PHE')] # ------------------------------------------------------------ # ************************************************************ # 'state=state': The first variable is the variable used within # the scope of this function. The second variable is the one # in the global scope and defined at the top of the module. # 'state': <1|3> for ES (1) complex or TI (3). 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. # <> 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 #<