Difference between revisions of "Rotkit"

From PyMOLWiki
Jump to navigation Jump to search
Line 61: Line 61:
  
 
<syntaxhighlight lang="python">
 
<syntaxhighlight lang="python">
#-------------------------------------------------------------------------------
+
reinitialize
# Name: rotkit.py
+
cd /home/tlinnet/test
# Purpose:      To rotate molecules easier in pymol
 
#
 
# Author:      tlinnet
 
#
 
# Created:    30/08/2011
 
# Copyright:  (c) tlinnet 2011
 
# Licence:    Free
 
#-------------------------------------------------------------------------------
 
 
 
cd C:\Users\tlinnet\Documents\My Dropbox\Speciale\5NT-project\Mutant-construct\Distance-Plot
 
 
import rotkit
 
import rotkit
 
+
#fetch 1HP1, async=0
+
fetch 1HP1, async=0
load 1HP1.pdb
 
 
load Atto590.pdb
 
load Atto590.pdb
 +
# Make sure everything is loaded before we continue
 +
cmd.refresh()
  
 
### Get the names of the loaded objects
 
### Get the names of the loaded objects
Line 88: Line 79:
 
protselectCA="%s and resi 308 and name CA"%protname
 
protselectCA="%s and resi 308 and name CA"%protname
 
protnameselectCA="K308CA"
 
protnameselectCA="K308CA"
molselect87="%s and id 87"%molname
+
molselect13="%s and id 13"%molname
molnameselect87="dyeatom87"
+
molnameselect13="dyeatom13"
molselect85="%s and id 85"%molname
+
molselect12="%s and id 12"%molname
molnameselect85="dyeatom85"
+
molnameselect12="dyeatom12"
 
+
 
### Make some selections
 
### Make some selections
 
cmd.select("%s"%protnameselectCB,"%s"%protselectCB)
 
cmd.select("%s"%protnameselectCB,"%s"%protselectCB)
 
cmd.select("%s"%protnameselectCA,"%s"%protselectCA)
 
cmd.select("%s"%protnameselectCA,"%s"%protselectCA)
cmd.select("%s"%molnameselect85,"%s"%molselect85)
+
cmd.select("%s"%molnameselect13,"%s"%molselect13)
cmd.select("%s"%molnameselect87,"%s"%molselect87)
+
cmd.label("%s"%molnameselect13,"13")
 +
cmd.select("%s"%molnameselect12,"%s"%molselect12)
 +
cmd.label("%s"%molnameselect12,"12")
  
 
### Make nice representations
 
### Make nice representations
 
cmd.show_as("cartoon","%s"%protname)
 
cmd.show_as("cartoon","%s"%protname)
 
cmd.show("sticks","byres %s"%protnameselectCB)
 
cmd.show("sticks","byres %s"%protnameselectCB)
 
+
 
##### PART I: Use of functions #####
 
##### PART I: Use of functions #####
 
### This view will take you to the first part
 
### This view will take you to the first part
Line 112: Line 105:
 
     19.480533600,  34.572898865,    6.978204727,\
 
     19.480533600,  34.572898865,    6.978204727,\
 
     46.615653992,  66.201446533,  -20.000001907 )
 
     46.615653992,  66.201446533,  -20.000001907 )
 
+
 
#### Just unhash each part for itself, as you continue through
 
#### Just unhash each part for itself, as you continue through
#### The python mini shell is important, to get the return values of the functions
 
 
 
### To print a objects TTT matrix in a readable format
 
### To print a objects TTT matrix in a readable format
python
 
 
rotkit.printMat(cmd.get_object_matrix(molname))
 
rotkit.printMat(cmd.get_object_matrix(molname))
python end
+
 
 
 
##### We want to move the dye to a desired location, and rotate it to a view we desire
 
##### We want to move the dye to a desired location, and rotate it to a view we desire
 
##### First get the vector bewteen the dyeatom and the protein atom
 
##### First get the vector bewteen the dyeatom and the protein atom
##python
+
diffvector = rotkit.vector("%s"%molselect13,"%s"%protnameselectCB)
##diffvector = rotkit.vector("%s"%molselect87,"%s"%protnameselectCB)
 
##python end
 
##
 
 
##### Then move the dye
 
##### Then move the dye
##python
+
move = rotkit.transmat(diffvector)
##move = rotkit.transmat(diffvector)
 
 
##### print the matrix for fun
 
##### print the matrix for fun
##rotkit.printMat(move)
+
rotkit.printMat(move)
 
##### Move the dye
 
##### Move the dye
##cmd.transform_selection("%s"%molname,move)
+
cmd.transform_selection("%s"%molname,move)
##python end
+
 
##
 
 
##### Now we want to displace the dye in the CA-CB bond direction
 
##### Now we want to displace the dye in the CA-CB bond direction
##python
 
 
##### First find the vector/direction to displace it in. From A -> B
 
##### First find the vector/direction to displace it in. From A -> B
##diffvector = rotkit.vector("%s"%protnameselectCA,"%s"%protnameselectCB)
+
diffvector = rotkit.vector("%s"%protnameselectCA,"%s"%protnameselectCB)
 
##### Make the vector so its lenth is equal 1
 
##### Make the vector so its lenth is equal 1
##uvector = rotkit.unitvector(diffvector)[0]
+
uvector = rotkit.unitvector(diffvector)[0]
 
##### Make the move translation matrix, and we multiply the matrix with 3, so it moves 3 Angstrom
 
##### Make the move translation matrix, and we multiply the matrix with 3, so it moves 3 Angstrom
##move = rotkit.transmat(uvector,3)
+
move = rotkit.transmat(uvector,3)
 
##### Print the matrix
 
##### Print the matrix
##rotkit.printMat(move)
+
rotkit.printMat(move)
 
##### Displace it in the CA-CB direction
 
##### Displace it in the CA-CB direction
##cmd.transform_selection("%s"%molname,move)
+
cmd.transform_selection("%s"%molname,move)
##python end
+
 
##
 
 
##### Now we want to rotate it a single time. We convert 40 degress to radians
 
##### Now we want to rotate it a single time. We convert 40 degress to radians
 
##### The input is the angle, the line to rotate around, and a point where the line goes through
 
##### The input is the angle, the line to rotate around, and a point where the line goes through
##python
+
CBxyz = rotkit.getxyz("%s"%protnameselectCB)[0]
##CBxyz = rotkit.getxyz("%s"%protnameselectCB)[0]
+
rmat = rotkit.rotmat(rotkit.radangle(40),uvector,CBxyz)
##rmat = rotkit.rotmat(rotkit.radangle(40),uvector,CBxyz)
+
rotkit.printMat(rmat)
##rotkit.printMat(rmat)
 
 
##### Copy paste this line into pymol to see it manually
 
##### Copy paste this line into pymol to see it manually
##cmd.transform_selection("%s"%molname,rmat)
+
cmd.transform_selection("%s"%molname,rmat)
##python end
+
 
##
 
 
##### We are not quite satisfied, we want to rotate it around its own bond
 
##### We are not quite satisfied, we want to rotate it around its own bond
##### So we rotate in around its own 87-85 bonds
+
##### So we rotate in around its own 13 -> 12 bonds
##python
+
diffvector = rotkit.vector("%s"%molnameselect13,"%s"%molnameselect12)
##diffvector = rotkit.vector("%s"%molnameselect87,"%s"%molnameselect85)
+
uvector = rotkit.unitvector(diffvector)[0]
##uvector = rotkit.unitvector(diffvector)[0]
+
xyz12 = rotkit.getxyz("%s"%molnameselect12)[0]
##xyz85 = rotkit.getxyz("%s"%molnameselect85)[0]
+
rmat = rotkit.rotmat(rotkit.radangle(10),uvector,xyz12)
##rmat = rotkit.rotmat(rotkit.radangle(10),uvector,xyz85)
 
 
##### Copy paste this line into pymol to see it manually
 
##### Copy paste this line into pymol to see it manually
##cmd.transform_selection("%s"%molname,rmat)
+
cmd.transform_selection("%s"%molname,rmat)
##python end
+
 
##
 
 
##### Now, lets make a function that collects all these call in one function
 
##### Now, lets make a function that collects all these call in one function
 
##### We only want to define two positions that defines the line, the angle and the object to rotate
 
##### We only want to define two positions that defines the line, the angle and the object to rotate
##python
+
rotkit.rotateline("%s"%molnameselect13,"%s"%molnameselect12,180,"%s"%molname)
##rotkit.rotateline("%s"%molnameselect87,"%s"%molnameselect85,180,"%s"%molname)
 
##python end
 
 
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
 
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
##print("rotateline Pos1=%s, Pos2=%s, degangle=15, molecule=%s"%(molnameselect87, molnameselect85, molname))
+
print("rotateline Pos1=%s, Pos2=%s, degangle=15, molecule=%s"%(molnameselect13, molnameselect12, molname))
##
+
 
 
##### To illustate best, we create som copies of the dye
 
##### To illustate best, we create som copies of the dye
##python
+
python
##anglerange = range(90,360,90)
+
anglerange = range(90,360,90)
##for angle in anglerange:
+
for angle in anglerange:
## ### Make a suitable name for the new molecule
+
    ### Make a suitable name for the new molecule
## molanglename="%s%s"%(molname,angle)
+
    molanglename="%s%s"%(molname,angle)
## ### Now make a copy
+
    ### Now make a copy
## cmd.create(molanglename,molname)
+
    cmd.create(molanglename,molname)
## ### Rotate the copy
+
    cmd.label("%s and id 12"%molanglename,"12")
## rotkit.rotateline("%s"%molnameselect87,"%s"%molnameselect85,angle,"%s"%molanglename)
+
    cmd.label("%s and id 13"%molanglename,"13")
##python end
+
    ### Rotate the copy
##
+
    rotkit.rotateline("%s"%protnameselectCB,"%s"%molnameselect13,angle,"%s"%molanglename)
 +
python end
 +
 
 +
 
 
####### End of PART I ####
 
####### End of PART I ####
 
####### PART II: More advanced functions #####
 
####### PART II: More advanced functions #####
 
##### This view will take you to the second part
 
##### This view will take you to the second part
##set_view (\
+
set_view (\
##    0.723298192,    0.467510879,    0.508201897,\
+
    0.723298192,    0.467510879,    0.508201897,\
##    0.371686131,  -0.883831143,    0.284063697,\
+
    0.371686131,  -0.883831143,    0.284063697,\
##    0.581970334,  -0.016570913,  -0.813038886,\
+
    0.581970334,  -0.016570913,  -0.813038886,\
##    0.000000000,    0.000000000,  -76.609786987,\
+
    0.000000000,    0.000000000,  -76.609786987,\
##    11.790571213,  64.992294312,  20.803859711,\
+
    11.790571213,  64.992294312,  20.803859711,\
##  -31.181428909,  184.401092529,  -20.000001907 )
+
  -31.181428909,  184.401092529,  -20.000001907 )
##
+
 
 
##### We can fast mutate a protein. frame 1 is the most probable mutation
 
##### We can fast mutate a protein. frame 1 is the most probable mutation
##python
+
rotkit.mutate(protname, chain="A", resi=513, target="CYS", mutframe=1)
##rotkit.mutate(protname, chain="A", resi=513, target="CYS", mutframe=1)
+
##### The mutate functions take 0.2 seconds, so we put in a refesh command to wait for everything is done
##python end
+
cmd.refresh()
 
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
 
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
##print("mutate %s, chain=%s, resi=%s, target=CYS, mutframe=1"%(protname, "A", 515))
+
print("mutate %s, chain=%s, resi=%s, target=CYS, mutframe=1"%(protname, "A", 515))
##
+
 
 
##### We now make some selections for this mutation
 
##### We now make some selections for this mutation
##protselectCBcys="%s and resi 513 and name CB"%protname
+
protselectCBcys="%s and resi 513 and name CB"%protname
##protnameselectCBcys="P513C_CB"
+
protnameselectCBcys="P513C_CB"
##protselectCAcys="%s and resi 513 and name CA"%protname
+
protselectCAcys="%s and resi 513 and name CA"%protname
##protnameselectCAcys="P513C_CA"
+
protnameselectCAcys="P513C_CA"
##cmd.select("%s"%protnameselectCBcys,"%s"%protselectCBcys)
+
cmd.select("%s"%protnameselectCBcys,"%s"%protselectCBcys)
##cmd.select("%s"%protnameselectCAcys,"%s"%protselectCAcys)
+
cmd.select("%s"%protnameselectCAcys,"%s"%protselectCAcys)
##
+
 
 
##### Now, lets make a function that collects all the commands to put on an atom on the same line defined by two points
 
##### Now, lets make a function that collects all the commands to put on an atom on the same line defined by two points
 
##### The input is the two points that define the line, the atom of a molecule to be put on the line, and the distance to move
 
##### The input is the two points that define the line, the atom of a molecule to be put on the line, and the distance to move
##python
+
rotkit.toline(protnameselectCAcys,protnameselectCBcys,molnameselect13,molname,3)
##rotkit.toline(protnameselectCAcys,protnameselectCBcys,molnameselect87,molname,3)
+
rotkit.rotateline(protnameselectCAcys,protnameselectCBcys,180,molname)
##rotkit.rotateline(protnameselectCAcys,protnameselectCBcys,5,molname)
+
rotkit.rotateline(molnameselect13,molnameselect12,10,molname)
##rotkit.rotateline(molnameselect87,molnameselect85,10,molname)
+
print("toline Pos1=%s, Pos2=%s, atom=%s, molecule=%s, dist=%s"%(protnameselectCAcys,protnameselectCBcys,molnameselect13,molname,3))
##python end
+
print("rotateline Pos1=%s, Pos2=%s, degangle=180, molecule=%s"%(protnameselectCAcys, protnameselectCBcys, molname))
##print("toline Pos1=%s, Pos2=%s, atom=%s, molecule=%s, dist=%s"%(protnameselectCAcys,protnameselectCBcys,molnameselect87,molname,3))
+
print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect13, molnameselect12, molname))
##print("rotateline Pos1=%s, Pos2=%s, degangle=5, molecule=%s"%(protnameselectCAcys, protnameselectCBcys, molname))
+
cmd.refresh()
##print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect87, molnameselect85, molname))
 
##
 
 
####### End of PART II ####
 
####### End of PART II ####
 +
 
####### Now we make a cross product ####
 
####### Now we make a cross product ####
##molselect88="%s and id 88"%molname
+
molselect14="%s and id 14"%molname
##molnameselect85="dyeatom88"
+
molnameselect14="dyeatom14"
##cmd.select("%s"%molnameselect88,"%s"%molselect88)
+
cmd.select("%s"%molnameselect14,"%s"%molselect14)
##
+
cmd.label("%s"%molnameselect14,"14")
##python
+
 
##cross = rotkit.crossprod(rotkit.vector(molselect87,molselect85),rotkit.vector(molselect87,molselect88))
+
cross = rotkit.crossprod(rotkit.vector(molselect13,molselect12),rotkit.vector(molselect13,molselect14))
###ucross = rotkit.unitvector(cross)[0]
+
unity_cross = rotkit.unitvector(cross)[0]
##pcross = rotkit.crosspoint(molselect87,cross)
+
point_cross = rotkit.crosspoint(molselect13,cross)
##rotkit.rotateline(molnameselect87,pcross,10,molname)
+
rotkit.rotateline(molnameselect13,point_cross,180,molname)
##python end
+
print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect13, pcross, molname))
##print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect87, pcross, molname))
 
 
</syntaxhighlight>
 
</syntaxhighlight>
  

Revision as of 04:52, 2 December 2011

Author

This pymol script is made by Troels Emtekær Linnet

Introduction

This script-kit is a collection of small script to be able to precisely to put a molecule (like a dye) where you want in relation to a protein. It simply makes the PyMOL TTT matrixes, in a easy and user friendly way. The calls to the functions available in PyMOL, takes care of all the conversion of input and such.

If you are interested in this, you might also want to check out the PyMOL Chempy module that is included in PyMOL. It provides handy vector and matrix functions.

Available in PyMOL

  • rotateline(Pos1,Pos2,degangle,molecule):
    "Pos1->Pos2" define a line whereabout "molecule" will be rotated "degangle" degrees
    rotateline Pos1=P513C_CA, Pos2=P513C_CB, degangle=5, molecule=Atto590
    rotateline Pos1=dyeatom87, Pos2=dyeatom85, degangle=10, molecule=Atto590
  • mutate(molecule,chain,resi,target="CYS",mutframe="1"):
    Mutate a /molecule//chain/resi into a target, and selecting most probable frame 1
    mutate 1HP1, chain=A, resi=515, target=CYS, mutframe=1
  • toline(Pos1,Pos2,atom,molecule,dist=1):
    Translate molecule atom, 1 angstrom away in the same direction Pos1->Pos2 specify
    toline Pos1=P513C_CA, Pos2=P513C_CB, atom=dyeatom87, molecule=Atto590, dist=3

Available through PyMOL mini shell

  • printMat(matrix):
    prints the TTT matrix in a readable format. (4X4)
  • getxyz(Sel):
    output is a list [x,y,z] in float. The input can be a list, a string(list) or a selection.
  • vector(Sel1,Sel2):
    Finds the vector between points. Gets the xyz list from getxyz, so input can be anything.
  • vectorstr(vector):
    turn a vector in list format into string. No real function actually.
  • transmat(vector,dist=1):
    Makes a TTT translation matrix for according to the input vector. The vector is multiplied with dist.
  • unitvector(vector):
    Make a vector a unitvector.
  • radangle(angle):
    Convert degree to radians. Not that all input are assumed to be in degrees, and are converted automatically.
  • rotmat(angle,vectornorm,pointcoord):
    This function is the most important. That makes the TTT matrix that rotates a molecule around a normalized vector, which goes through a coordinate point.
  • crossprod(Vector1, Vector2):
    Makes a crossproduct between two vectors
  • crosspoint(Pos1, crossprod):
    Returns the endpoint for the Position plus the crossproduct vector. Suitable if one would like to rotate around a crossvector.

Example of use

A tutorial.pml file

To understand how the script works, read through the tutorial. Unhash "##" each step at the time to see the effect. Note, the python mini shell is important, to get the return values of the functions.

To be able to follow the tutorial, you need the dye molecule. Right clicking the following link here -> Save as: Atto590.pdb in the directory with the tutorial.pml file

https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/files_for_examples/Atto590.pdb
reinitialize
cd /home/tlinnet/test
import rotkit
 
fetch 1HP1, async=0
load Atto590.pdb
# Make sure everything is loaded before we continue
cmd.refresh()

### Get the names of the loaded objects
protname = cmd.get_names()[0]
molname = cmd.get_names()[1]

### Make the names we are going to use
protselectCB="%s and resi 308 and name CB"%protname
protnameselectCB="K308CB"
protselectCA="%s and resi 308 and name CA"%protname
protnameselectCA="K308CA"
molselect13="%s and id 13"%molname
molnameselect13="dyeatom13"
molselect12="%s and id 12"%molname
molnameselect12="dyeatom12"
 
### Make some selections
cmd.select("%s"%protnameselectCB,"%s"%protselectCB)
cmd.select("%s"%protnameselectCA,"%s"%protselectCA)
cmd.select("%s"%molnameselect13,"%s"%molselect13)
cmd.label("%s"%molnameselect13,"13")
cmd.select("%s"%molnameselect12,"%s"%molselect12)
cmd.label("%s"%molnameselect12,"12")

### Make nice representations
cmd.show_as("cartoon","%s"%protname)
cmd.show("sticks","byres %s"%protnameselectCB)
 
##### PART I: Use of functions #####
### This view will take you to the first part
set_view (\
     0.377224118,    0.880101919,   -0.288305759,\
     0.661396861,   -0.473919988,   -0.581338286,\
    -0.648268998,    0.028612033,   -0.760871351,\
     0.000000000,    0.000000000,  -56.408561707,\
    19.480533600,   34.572898865,    6.978204727,\
    46.615653992,   66.201446533,  -20.000001907 )
 
#### Just unhash each part for itself, as you continue through
### To print a objects TTT matrix in a readable format
rotkit.printMat(cmd.get_object_matrix(molname))
 
##### We want to move the dye to a desired location, and rotate it to a view we desire
##### First get the vector bewteen the dyeatom and the protein atom
diffvector = rotkit.vector("%s"%molselect13,"%s"%protnameselectCB)
##### Then move the dye
move = rotkit.transmat(diffvector)
##### print the matrix for fun
rotkit.printMat(move)
##### Move the dye
cmd.transform_selection("%s"%molname,move)

##### Now we want to displace the dye in the CA-CB bond direction
##### First find the vector/direction to displace it in. From A -> B
diffvector = rotkit.vector("%s"%protnameselectCA,"%s"%protnameselectCB)
##### Make the vector so its lenth is equal 1
uvector = rotkit.unitvector(diffvector)[0]
##### Make the move translation matrix, and we multiply the matrix with 3, so it moves 3 Angstrom
move = rotkit.transmat(uvector,3)
##### Print the matrix
rotkit.printMat(move)
##### Displace it in the CA-CB direction
cmd.transform_selection("%s"%molname,move)

##### Now we want to rotate it a single time. We convert 40 degress to radians
##### The input is the angle, the line to rotate around, and a point where the line goes through
CBxyz = rotkit.getxyz("%s"%protnameselectCB)[0]
rmat = rotkit.rotmat(rotkit.radangle(40),uvector,CBxyz)
rotkit.printMat(rmat)
##### Copy paste this line into pymol to see it manually
cmd.transform_selection("%s"%molname,rmat)

##### We are not quite satisfied, we want to rotate it around its own bond
##### So we rotate in around its own 13 -> 12 bonds
diffvector = rotkit.vector("%s"%molnameselect13,"%s"%molnameselect12)
uvector = rotkit.unitvector(diffvector)[0]
xyz12 = rotkit.getxyz("%s"%molnameselect12)[0]
rmat = rotkit.rotmat(rotkit.radangle(10),uvector,xyz12)
##### Copy paste this line into pymol to see it manually
cmd.transform_selection("%s"%molname,rmat)

##### Now, lets make a function that collects all these call in one function
##### We only want to define two positions that defines the line, the angle and the object to rotate
rotkit.rotateline("%s"%molnameselect13,"%s"%molnameselect12,180,"%s"%molname)
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
print("rotateline Pos1=%s, Pos2=%s, degangle=15, molecule=%s"%(molnameselect13, molnameselect12, molname))

##### To illustate best, we create som copies of the dye
python
anglerange = range(90,360,90)
for angle in anglerange:
    ### Make a suitable name for the new molecule
    molanglename="%s%s"%(molname,angle)
    ### Now make a copy
    cmd.create(molanglename,molname)
    cmd.label("%s and id 12"%molanglename,"12")
    cmd.label("%s and id 13"%molanglename,"13")
    ### Rotate the copy
    rotkit.rotateline("%s"%protnameselectCB,"%s"%molnameselect13,angle,"%s"%molanglename)
python end


####### End of PART I ####
####### PART II: More advanced functions #####
##### This view will take you to the second part
set_view (\
     0.723298192,    0.467510879,    0.508201897,\
     0.371686131,   -0.883831143,    0.284063697,\
     0.581970334,   -0.016570913,   -0.813038886,\
     0.000000000,    0.000000000,  -76.609786987,\
    11.790571213,   64.992294312,   20.803859711,\
   -31.181428909,  184.401092529,  -20.000001907 )

##### We can fast mutate a protein. frame 1 is the most probable mutation
rotkit.mutate(protname, chain="A", resi=513, target="CYS", mutframe=1)
##### The mutate functions take 0.2 seconds, so we put in a refesh command to wait for everything is done
cmd.refresh()
##### This is made as a pymol command as well. I first print the names that we should write manually in the consol
print("mutate %s, chain=%s, resi=%s, target=CYS, mutframe=1"%(protname, "A", 515))

##### We now make some selections for this mutation
protselectCBcys="%s and resi 513 and name CB"%protname
protnameselectCBcys="P513C_CB"
protselectCAcys="%s and resi 513 and name CA"%protname
protnameselectCAcys="P513C_CA"
cmd.select("%s"%protnameselectCBcys,"%s"%protselectCBcys)
cmd.select("%s"%protnameselectCAcys,"%s"%protselectCAcys)

##### Now, lets make a function that collects all the commands to put on an atom on the same line defined by two points
##### The input is the two points that define the line, the atom of a molecule to be put on the line, and the distance to move
rotkit.toline(protnameselectCAcys,protnameselectCBcys,molnameselect13,molname,3)
rotkit.rotateline(protnameselectCAcys,protnameselectCBcys,180,molname)
rotkit.rotateline(molnameselect13,molnameselect12,10,molname)
print("toline Pos1=%s, Pos2=%s, atom=%s, molecule=%s, dist=%s"%(protnameselectCAcys,protnameselectCBcys,molnameselect13,molname,3))
print("rotateline Pos1=%s, Pos2=%s, degangle=180, molecule=%s"%(protnameselectCAcys, protnameselectCBcys, molname))
print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect13, molnameselect12, molname))
cmd.refresh()
####### End of PART II ####

####### Now we make a cross product ####
molselect14="%s and id 14"%molname
molnameselect14="dyeatom14"
cmd.select("%s"%molnameselect14,"%s"%molselect14)
cmd.label("%s"%molnameselect14,"14")

cross = rotkit.crossprod(rotkit.vector(molselect13,molselect12),rotkit.vector(molselect13,molselect14))
unity_cross = rotkit.unitvector(cross)[0]
point_cross = rotkit.crosspoint(molselect13,cross)
rotkit.rotateline(molnameselect13,point_cross,180,molname)
print("rotateline Pos1=%s, Pos2=%s, degangle=10, molecule=%s"%(molnameselect13, pcross, molname))

Python Code

This code has been put under version control. In the project, Pymol-script-repo.

For a color coded view:

https://github.com/Pymol-Scripts/Pymol-script-repo/blob/master/rotkit.py

See the raw code or download manually, by right clicking the following link here -> Save as: rotkit.py

https://raw.github.com/Pymol-Scripts/Pymol-script-repo/master/rotkit.py