This is a read-only mirror of pymolwiki.org

Difference between revisions of "FindSurfaceResidues"

From PyMOL Wiki
Jump to navigation Jump to search
m (1 revision)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
<gallery>
+
{{Infobox script-repo
Image:FindExRes.png|thumb|right|300px|Result of $TUT/1hpv.pdb at 2.5 Ang cutoff.
+
|type      = module
Image:Surface_residues_ex.png|300px|Example coloring of surface residues
+
|filename  = findSurfaceResidues.py
</gallery>
+
|author    = [[User:inchoate|Jason Vertrees]]
 +
|license  = BSD-2-Clause
 +
}}
  
 +
The [[findSurfaceResidues]] script will select (and color if requested) surface residues and atoms on an object or selection.  See the options below.
  
= Overview =
+
Each time, the script will create two new selections called, '''exposed_res_XYZ''' and '''exposed_atm_XYZ''' where ''XYZ'' is some random numberThis is done so that no other selections/objects are overwritten.
This script will select (and color if requested) surface residues and atoms on an object or selectionSee the options below.
 
  
 +
= Usage =
  
Each time, the script will create two new selections called, 'exposed_res_XYZ' and 'exposed_atm_XYZ' where XYZ is some random number.  This is done so that no other selections/objects are overwritten.
+
findSurfaceResidues [ selection=all [, cutoff=2.5 [, doShow=0 ]]]
  
= Usage =
+
= Arguments =
<source lang="python">
 
findSurfaceResidues [objSel=(all)[, cutoff=2.5[, doShow=False[, verbose=False ]]]]
 
</source>
 
The parameters are:
 
  
'''objSel'''
+
* '''selection''' = str: The object or selection for which to find exposed residues {default: all}
:: The object or selection for which to find exposed residues;
+
* '''cutoff''' = float: The cutoff in square Angstroms that defines exposed or not. Those atoms with > cutoff Ang^2 exposed will be considered ''exposed'' {default: 2.5 Ang^2}
:: DEFAULT = (all)
+
* '''doShow''' = 0/1: Change the visualization to highlight the exposed residues vs interior {default: 0}
'''cutoff'''
 
:: The cutoff in square Angstroms that defines exposed or not. Those residues with > cutoff Ang^2 exposed will be considered ''exposed'';
 
:: DEFAULT =  2.5 Ang^2
 
'''doShow'''
 
:: Change the visualization to highlight the exposed residues vs interior
 
:: DEFAULT = False/Blank
 
'''verbose'''
 
:: Level of verbosity.
 
:: DEFAULT = False/Blank
 
  
== Examples ==
+
= Examples =
<source lang="python">
 
# make sure you download and run the code below, before trying these examples.
 
load $TUT/1hpv.pdb
 
findSurfaceResidues
 
# now show the exposed
 
findSurface residues doShow=True
 
  
# watch how the visualization changes:
+
<gallery>
findSurfaceResidues doShow=True, cutoff=0.5
+
Image:FindExRes.png|thumb|right|300px|Result of $TUT/1hpv.pdb at 2.5 Ang cutoff.
findSurfaceResidues doShow=True, cutoff=1.0
+
Image:Surface_residues_ex.png|300px|Example coloring of surface residues
findSurfaceResidues doShow=True, cutoff=1.5
+
</gallery>
findSurfaceResidues doShow=True, cutoff=2.0
 
findSurfaceResidues doShow=True, cutoff=2.5
 
findSurfaceResidues doShow=True, cutoff=3.0
 
</source>
 
  
= The Code =
 
 
<source lang="python">
 
<source lang="python">
# -*- coding: utf-8 -*-
+
run findSurfaceResidues.py
import pymol
+
fetch 1hpv, async=0
from pymol import cmd
 
import random
 
  
def findSurfaceResidues(objSel="(all)", cutoff=2.5, doShow=False, verbose=False):
+
findSurfaceResidues
"""
 
findSurfaceResidues
 
finds those residues on the surface of a protein
 
that have at least 'cutoff' exposed A**2 surface area.
 
  
PARAMS
+
# now show the exposed
objSel (string)
+
findSurfaceResidues doShow=1
the object or selection in which to find
 
exposed residues
 
DEFAULT: (all)
 
  
cutoff (float)
+
# watch how the visualization changes:
your cutoff of what is exposed or not.
+
findSurfaceResidues doShow=1, cutoff=0.5
DEFAULT: 2.5 Ang**2
+
findSurfaceResidues doShow=1, cutoff=1.0
 
+
findSurfaceResidues doShow=1, cutoff=1.5
asSel (boolean)
+
findSurfaceResidues doShow=1, cutoff=2.0
make a selection out of the residues found
+
findSurfaceResidues doShow=1, cutoff=2.5
 
+
findSurfaceResidues doShow=1, cutoff=3.0
RETURNS
 
(list: (chain, resv ) )
 
A Python list of residue numbers corresponding
 
to those residues w/more exposure than the cutoff.
 
 
 
"""
 
tmpObj="__tmp"
 
cmd.create( tmpObj, objSel + " and polymer");
 
if verbose!=False:
 
print "WARNING: I'm setting dot_solvent. You may not care for this."
 
cmd.set("dot_solvent");
 
cmd.get_area(selection=tmpObj, load_b=1)
 
 
 
# threshold on what one considers an "exposed" atom (in A**2):
 
cmd.remove( tmpObj + " and b < " + str(cutoff) )
 
 
 
stored.tmp_dict = {}
 
cmd.iterate(tmpObj, "stored.tmp_dict[(chain,resv)]=1")
 
exposed = stored.tmp_dict.keys()
 
exposed.sort()
 
 
 
        randstr = str(random.randint(0,10000))
 
selName = "exposed_atm_" + randstr
 
if verbose!=False:
 
print "Exposed residues are selected in: " + selName
 
cmd.select(selName, objSel + " in " + tmpObj )
 
        selNameRes = "exposed_res_" + randstr
 
        cmd.select(selNameRes, "byres " + selName )
 
 
 
 
 
if doShow!=False:
 
cmd.show_as("spheres", objSel + " and poly")
 
cmd.color("white", objSel)
 
cmd.color("red", selName)
 
 
 
cmd.delete(tmpObj)
 
 
 
return exposed
 
 
 
 
 
cmd.extend("findSurfaceResidues", findSurfaceResidues)
 
 
</source>
 
</source>
  
= Another version =
+
= See Also =
<gallery heights="240px" widths="340px">
 
Image:Surfaceatoms.png|Another version, to show the same thing. The part of the protein which is not surface exposed is in cartoon. The white is the surface "byres" exposed residues shown in sticks. The orange is the atoms which is exposed.
 
</gallery>
 
 
 
<source lang="python">
 
from pymol import cmd, stored
 
 
def surfaceatoms(molecule="NIL",show=True, verbose=True, cutoff=2.5):
 
"""
 
surfaceatoms
 
finds those residues on the surface of a protein
 
that have at least 'cutoff' exposed A**2 surface area.
 
PARAMS
 
molecule (string)
 
the object or selection in which to find
 
exposed residues
 
DEFAULT: (last molecule in pymol)
 
cutoff (float)
 
your cutoff of what is exposed or not.
 
DEFAULT: 2.5 Ang**2
 
RETURNS
 
(list: (chain, resv ) )
 
A Python list of residue numbers corresponding
 
to those residues w/more exposure than the cutoff.
 
"""
 
if molecule=="NIL":
 
assert len(cmd.get_names())!=0, "Did you forget to load a molecule? There are no objects in pymol."
 
molecule=cmd.get_names()[-1]
 
tmpObj="__tmp"
 
cmd.create(tmpObj, "(%s and polymer) and not resn HOH"%molecule)
 
if verbose!=False:
 
print "WARNING: I'm setting dot_solvent.  You may not care for this."
 
cmd.set("dot_solvent")
 
cmd.get_area(selection=tmpObj, load_b=1)
 
# threshold on what one considers an "exposed" atom (in A**2):
 
cmd.remove( tmpObj + " and b < " + str(cutoff) )
 
stored.tmp_dict = {}
 
cmd.iterate(tmpObj, "stored.tmp_dict[(chain,resv)]=1")
 
exposed = stored.tmp_dict.keys()
 
exposed.sort()
 
 
selName = "%s_atoms"%molecule
 
cmd.select(selName, molecule + " in " + tmpObj )
 
if verbose!=False:
 
print "Exposed residues are selected in: " + selName
 
selNameRes = "%s_resi"%molecule
 
cmd.select(selNameRes, "byres " + selName )
 
 
if show!=False:
 
cmd.hide("everything", molecule)
 
cmd.show("cartoon", "%s and not %s and not resn HOH"%(molecule,selNameRes))
 
cmd.show("sticks", "%s"%selNameRes)
 
cmd.util.cbaw(selNameRes)
 
cmd.disable(selNameRes)
 
cmd.alter('%s'%(selName),'vdw=0.5')
 
cmd.show("spheres", "%s"%selName)
 
cmd.util.cbao(selName)
 
cmd.disable(selName)
 
  
cmd.delete(tmpObj)
+
* [[get_sasa_relative]]
print(exposed)
+
* [[Get_Area|get_area]]
return(exposed)
 
cmd.extend("surfaceatoms", surfaceatoms)
 
</source>
 
  
 
[[Category:Script_Library]]
 
[[Category:Script_Library]]
Line 186: Line 54:
 
[[Category:Biochemical_Scripts]]
 
[[Category:Biochemical_Scripts]]
 
[[Category:Structural_Biology_Scripts]]
 
[[Category:Structural_Biology_Scripts]]
 +
__NOTOC__

Latest revision as of 03:11, 1 April 2019

Type Python Module
Download findSurfaceResidues.py
Author(s) Jason Vertrees
License BSD-2-Clause
This code has been put under version control in the project Pymol-script-repo

The findSurfaceResidues script will select (and color if requested) surface residues and atoms on an object or selection. See the options below.

Each time, the script will create two new selections called, exposed_res_XYZ and exposed_atm_XYZ where XYZ is some random number. This is done so that no other selections/objects are overwritten.

Usage

findSurfaceResidues [ selection=all [, cutoff=2.5 [, doShow=0 ]]]

Arguments

  • selection = str: The object or selection for which to find exposed residues {default: all}
  • cutoff = float: The cutoff in square Angstroms that defines exposed or not. Those atoms with > cutoff Ang^2 exposed will be considered exposed {default: 2.5 Ang^2}
  • doShow = 0/1: Change the visualization to highlight the exposed residues vs interior {default: 0}

Examples

run findSurfaceResidues.py
fetch 1hpv, async=0

findSurfaceResidues

# now show the exposed
findSurfaceResidues doShow=1

# watch how the visualization changes:
findSurfaceResidues doShow=1, cutoff=0.5
findSurfaceResidues doShow=1, cutoff=1.0
findSurfaceResidues doShow=1, cutoff=1.5
findSurfaceResidues doShow=1, cutoff=2.0
findSurfaceResidues doShow=1, cutoff=2.5
findSurfaceResidues doShow=1, cutoff=3.0

See Also