This is a read-only mirror of pymolwiki.org

Difference between revisions of "ColorByRMSD"

From PyMOL Wiki
Jump to navigation Jump to search
m (26 revisions)
 
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 +
{{Infobox script-repo
 +
|type      = Python Module
 +
|filename  = colorbyrmsd.py
 +
|author    = [[User:Shiven|Shivender Shandilya]], [[User:Inchoate|Jason Vertrees]], [[User:Speleo3|Thomas Holder]]
 +
|license  = BSD-2-Clause
 +
}}
 +
 
== Introduction ==
 
== Introduction ==
 +
This script allows you to color two structures by Root Mean Square Deviation (RMSD).
 +
The distances between aligned C-alpha atom pairs are stored as B-factors of these residues, which are colored by a color spectrum, with blue specifying the minimum pairwise RMSD and red indicating the maximum.
 +
Unaligned residues are colored gray.
 +
 +
== Usage ==
 +
 +
colorbyrmsd mobile, target [, doAlign [, doPretty [, guide [, method ]]]]
  
An attempt to perform a coloring of two structures by RMS deviation as calculated by PyMol's internal [[Rms_Cur]] command.
+
== Arguments ==
  
== Code ==
+
* '''mobile''' = string: atom selection for mobile atoms
WARNING: This is still a work in progress, and is almost useless right now! It is just a proof of principle at this stage and mainly an attempt at using the "alignment" object to iterate over the aligned objects. However, if you make any improvements, please do edit this page to reflect the same.
+
* '''target''' = string: atom selection for target atoms
 +
* '''doAlign''' = 0 or 1: Superpose selections before calculating distances {default: 1}
 +
* '''doPretty''' = 0 or 1: Show nice representation and colors {default: 1}
 +
* '''guide''' = 0 or 1: Only use C-alpha atoms {default: 1}
 +
* '''method''' = align or super: Method to match atoms {default: super}
  
 +
== Examples ==
 
<source lang="python">
 
<source lang="python">
"""
+
# example #1
--- ColorByRMSD: RMSD based coloring ---
+
colorbyrmsd 1cbs, 1hmt, doAlign=1, doPretty=1
Author  : Shivender Shandilya
+
# example #2
Program : ColByRMS
+
colorbyrmsd 1eaz, 1fao, doAlign=1, doPretty=1
Date    : July 2009
+
</source>
Version : 0.0.2 (very very alpha!)
 
Mail    : firstname.lastname@umassmed.edu
 
 
Keywords: color rms rmsd colorbyrms colorbyrmsd
 
----------------------------------------------------------------------
 
Reference:
 
This email from Warren - http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg07078.html
 
Literature:
 
DeLano, W.L. The PyMOL Molecular Graphics System (2002) DeLano Scientific, San Carlos, CA, USA. http://www.pymol.org
 
----------------------------------------------------------------------
 
"""
 
 
import pymol
 
import cmd
 
 
# Code for a special case first
 
cmd.load("D:/PyMOL-1.2r1/data/tut/1hpv.pdb", "1hpv")
 
 
cmd.create("chA", "1hpv and polymer and chain A")
 
cmd.create("chB", "1hpv and polymer and chain B")
 
 
# We need the alignment object, but PyMol refuses to give us that unless
 
# we (needlessly) specify all the other values in the cmd.align() function
 
# all the 0's are needlessly forced to be specified...
 
# PyMol is not smart enough to use the defaults
 
cmd.align("chA and name CA", "chB and name CA",0,0,0,0,0,object="aln")
 
# So, lets use "super" instead
 
#cmd.super("chA", "chB",object="aln")
 
 
# Utter the magic word
 
cmd.refresh()
 
 
# Arrays to store all residue identifiers in "aln"
 
stored.alnAres = []
 
stored.alnBres = []
 
 
# Now interrogate "aln" to get residue numbers for each object
 
cmd.iterate("chA and aln","stored.alnAres.append(resi)")
 
cmd.iterate("chB and aln","stored.alnBres.append(resi)")
 
  
print "Length of alnAres: "+str(len(stored.alnAres))
+
<gallery heights="300px" widths="300px">
print "Length of alnBres: "+str(len(stored.alnBres))
+
Image:ColorByRMSD_1cbs_1hmt.png|1cbs and 1hmt aligned and colored by RMSD. Dark blue is good alignment, higher deviations are in orange/yellow/red. Residues not used for alignment are colored white.
+
Image:ColorByRMSD_1eaz_1fao.png|1eaz and 1fao aligned and colored by RMSDDark blue is good alignment, higher deviations are in orange/yellow/red. Residues not used for alignment are colored white.
# The main function that assigns "cur_rms" as the new b-factor
+
</gallery>
def colbyRMS(objA, alnAri, objB, alnBri):
+
 
    cmd.alter(str(objA), "chain='Z'")
+
[[Category:Script_Library]]
    cmd.alter(str(objB), "chain='Z'")
+
[[Category:Structural_Biology_Scripts]]
    cmd.rebuild()
+
[[Category:Pymol-script-repo]]
    for x in range(len(alnAri)):
 
        rmsd = cmd.rms_cur(str(objA)+" and i. "+str(alnAri[x]), str(objB)+" and i. "+str(alnBri[x]), matchmaker=4)
 
        cmd.alter(str(objA)+" and resi "+str(alnAri[x]), "b = "+str(rmsd))
 
        cmd.alter(str(objB)+" and resi "+str(alnBri[x]), "b = "+str(rmsd))
 
 
cmd.extend("colbyRMS", colbyRMS)
 
   
 
# Run the just defined function
 
if len(stored.alnAres) > len(stored.alnBres):
 
    colbyRMS("chA",stored.alnAres,"chB",stored.alnBres)
 
else:
 
    colbyRMS("chB",stored.alnBres,"chA",stored.alnAres)
 
 
# Arrays to store the NEW b-factors
 
stored.alnAnb = []
 
stored.alnBnb = []
 
 
# Store the NEW b-factors
 
cmd.iterate("chA and aln","stored.alnAnb.append(b)")
 
cmd.iterate("chB and aln","stored.alnBnb.append(b)")
 
 
# Assign the just stored NEW b-factors to the original object
 
for x in range(len(stored.alnAres)):
 
    cmd.alter("1hpv and chain A and resi "+str(stored.alnAres[x]), "b = "+str(stored.alnAnb[x]))
 
for x in range(len(stored.alnBres)):
 
    cmd.alter("1hpv and chain B and resi "+str(stored.alnBres[x]), "b = "+str(stored.alnBnb[x]))
 
 
# Get rid of all intermediate objects etc.
 
cmd.delete("chA")
 
cmd.delete("chB")
 
cmd.delete("aln")
 
 
# Showcase what you did
 
cmd.orient()
 
cmd.hide("all")
 
cmd.show("cartoon", "1hpv")
 
cmd.cartoon("loop")
 
print "\n"
 
print "Colored by 'overall' RMSD...\n"
 
cmd.spectrum("b", "rainbow", "1hpv and polymer")
 
</source>
 

Latest revision as of 01:21, 28 March 2014

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

Introduction

This script allows you to color two structures by Root Mean Square Deviation (RMSD). The distances between aligned C-alpha atom pairs are stored as B-factors of these residues, which are colored by a color spectrum, with blue specifying the minimum pairwise RMSD and red indicating the maximum. Unaligned residues are colored gray.

Usage

colorbyrmsd mobile, target [, doAlign [, doPretty [, guide [, method ]]]]

Arguments

  • mobile = string: atom selection for mobile atoms
  • target = string: atom selection for target atoms
  • doAlign = 0 or 1: Superpose selections before calculating distances {default: 1}
  • doPretty = 0 or 1: Show nice representation and colors {default: 1}
  • guide = 0 or 1: Only use C-alpha atoms {default: 1}
  • method = align or super: Method to match atoms {default: super}

Examples

# example #1
colorbyrmsd 1cbs, 1hmt, doAlign=1, doPretty=1
# example #2
colorbyrmsd 1eaz, 1fao, doAlign=1, doPretty=1