This is a read-only mirror of pymolwiki.org

Difference between revisions of "Transform odb"

From PyMOL Wiki
Jump to navigation Jump to search
m
m (17 revisions)
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
===DESCRIPTION===
+
'''transform_odb''' transforms the coordinates of a selection and creates a new object with the transformed coordinates. The transformation matrix is read from a specified "O"-style tranformation matrix file (.odb) written by "O" or by any of the Uppsala Software Factory programs (from Gerard Klegweit) such as LSQMAN.
"transform_odb" transforms the coordinates of a selection and creates a new object with the transformed coordinates. The transformation matrix is read from a specified "O"-style tranformation matrix file (.odb) written by "O" or by any of the Uppsala Software Factory programs (from Gerard Klegweit) such as LSQMAN.
 
  
 
===USAGE===
 
===USAGE===
 
  transform_odb name, (selection), matrix_file [, transpose]
 
  transform_odb name, (selection), matrix_file [, transpose]
  
* name = object to contain transformed coordinates
+
* name = new or modified object that will contain transformed coordinates
* selection = atoms to transform
+
* selection = selection of atoms to transform
 
* matrix_file = file name or path of .odb file containing a transformation matrix data block
 
* matrix_file = file name or path of .odb file containing a transformation matrix data block
 
* transpose (default 0]
 
* transpose (default 0]
  
 
===EXAMPLES===
 
===EXAMPLES===
  transform moved_helix, ( mol1 and resi 200:220 ),  move_helix.odb
+
  transform_odb moved_helix, ( mol1 and resi 200:220 ),  move_helix.odb
  
 
===USER COMMENTS===
 
===USER COMMENTS===
Line 23: Line 22:
 
import os
 
import os
 
import re
 
import re
import string
 
  
 
def __init__(self):
 
def __init__(self):
Line 46: Line 44:
 
  if (theCurrLine) and (theCurrLine[0] != '!') and (theCurrLine[0] != '.'):
 
  if (theCurrLine) and (theCurrLine[0] != '!') and (theCurrLine[0] != '.'):
 
  # if the line isn't blank, make a list of items seperated by tabs
 
  # if the line isn't blank, make a list of items seperated by tabs
  theNewRow = string.split (theCurrLine)
+
  theNewRow = theCurrLine.split ()
 
  # add it in the matrix
 
  # add it in the matrix
 
  theMatrix.extend ( theNewRow )
 
  theMatrix.extend ( theNewRow )
Line 70: Line 68:
  
 
===SEE ALSO===
 
===SEE ALSO===
transform_selection, transform_object
+
[[transform_selection]], [[transform_object]]
  
[[Category:Script Library|transform_odb]]
+
[[Category:Script Library|Transform odb]]
 +
[[Category:ThirdParty_Scripts]]

Latest revision as of 04:07, 28 March 2014

transform_odb transforms the coordinates of a selection and creates a new object with the transformed coordinates. The transformation matrix is read from a specified "O"-style tranformation matrix file (.odb) written by "O" or by any of the Uppsala Software Factory programs (from Gerard Klegweit) such as LSQMAN.

USAGE

transform_odb name, (selection), matrix_file [, transpose]
  • name = new or modified object that will contain transformed coordinates
  • selection = selection of atoms to transform
  • matrix_file = file name or path of .odb file containing a transformation matrix data block
  • transpose (default 0]

EXAMPLES

transform_odb moved_helix, ( mol1 and resi 200:220 ),  move_helix.odb

USER COMMENTS

Please send questions or bug reports to Mark Saper, mailto:saper@umich.edu

SOURCE

from pymol import cmd
import pymol
import os
import re

def __init__(self):
	cmd.extend('transform_odb', transform_odb)

# Creates a new object name from selection after transforming it with O-style matrix
# found in matrix_file
# Author: Mark Saper <saper@umich.edu>

def transform_odb( name, selection, matrix_file='matrix.odb',  transpose=0):

	# open the file for reading
	matrix_file = os.path.expanduser(matrix_file)
	matrix_file = os.path.expandvars(matrix_file)
	theInFile = open ( matrix_file,"r")
	
	# what we'll store the results in
	theMatrix = []
	 
	# read every line in the file and ...
	for theCurrLine in theInFile.readlines():
	   if (theCurrLine) and (theCurrLine[0] != '!') and (theCurrLine[0] != '.'):
		  # if the line isn't blank, make a list of items seperated by tabs
		  theNewRow = theCurrLine.split ()
		  # add it in the matrix
		  theMatrix.extend ( theNewRow )
	
	# change matrix to pymol unsupported format
	
	theMatrix = [ theMatrix[0], theMatrix[3], theMatrix[6], theMatrix[9],
					  theMatrix[1], theMatrix[4], theMatrix[7], theMatrix[10],
					  theMatrix [2], theMatrix [5], theMatrix[8], theMatrix[11], 
					  0.0, 0.0, 0.0, 0.0 ]
	theMatrix = [ float(x) for x in theMatrix]	
	
	# close the file
	theInFile.close ()
	
	r = cmd.create ( name, selection)
	r = cmd.transform_object( name, theMatrix, transpose=transpose)

	return r

cmd.extend('transform_odb', transform_odb)

SEE ALSO

transform_selection, transform_object