[chimera-dev] Recent API changes

Greg Couch gregc at cgl.ucsf.edu
Tue Oct 18 16:57:57 PDT 2005


Hello Developers,

In the recent chimera release candidates and the imminent 1.2180 production
release, there several API changes that may trip up existing code.  Many of
these changes are due to our improved method of moving data between Python
and the underlying C++ layer (roughly 2X faster).  Most of the changes are
detailed below.

 	Greg Couch
 	gregc at cgl.ucsf.edu

------

The new code works much better with the Python help function.  In the IDLE 
window, try help(chimera.Atom) and you'll see all of Atom's methods and 
their argument types and return values.

For the changes below assume:

m is a Molecule
r is a Residue
a is an Atom
b is a Bond
x is a Xform

Atoms have a simpified interface to their bonds:

 	a.bonds() returns a list of bonds
 	a.neighbors() returns a list of adjacent atoms (via bonds)
 	a.bondsMap() is both of the above combined as a dictionary
 		and is what a.bonds() used to return

 	If a structure has alternate locations, you can get just the
 	highest occupancy bonds/atoms with a.primaryBonds() and
 	a.primaryNeighbors().  Molecules have a corresponding
 	m.primaryAtoms() function.

Residues have a simpified interface to their atoms:

 	r.atoms() returns a list of atoms
 	r.atomNames() returns a list of atom names
 	r.atomsMap() is both of the above combined as a dictionary
 		with atom name as the key and a list of atoms with
 		that name as the value

Residue ids (of type MolResId) no longer have an exposed str method:

 	r.id.str() is now 'str(r.id)' or 'print r.id'

MolResId, Point, Vector, and Xform now have copy constructors.  You can 
make copies in the C++ style, 'xprime = Xform(x)', or in the Python style 
with the copy module or the __copy__ method.

The following chimera module functions are now static methods:

 	Atom_getIdatmInfoMap		-> Atom.getIdatmInfoMap
 	Camera_hasMode			-> Camera.hasMode
 	Camera_modes			-> Camera.modes
 	Color_list			-> Color.list
 	Color_lookup			-> Color.lookup
 	Color_remove**
 	Element_bondLength		-> Element.bondLength
 	Element_bondRadius		-> Element.bondRadius
 	LODControl_get			-> LODControl.get
 	Material_list			-> Material.list
 	Material_lookup			-> Material.lookup
 	Material_remove**
 	Mol2io_isBlankLine		-> Mol2io.isBlankLine
 	Mol2io_splitLine		-> Mol2io.splitLine
 	OGLFont_defaultFont		-> OGLFont.defaultFont
 	OGLFont_setDefaultFont		-> OGLFont.setDefaultFont
 	OpenModels_get			-> OpenModels.get
 	PDBio_addStandardResidue	-> PDBio.addStandardResidue
 	PDBio_bondLengthTolerance	-> PDBio.bondLengthTolerance
 	PDBio_removeStandardResidue	-> PDBio.removeStandardResidue
 	PDBio_setBondLengthTolerance	-> PDBio.setBondLengthTolerance
 	PDBio_standardResidue		-> PDBio.standardResidue
 	PixelMap_list			-> PixelMap.list
 	PixelMap_lookup			-> PixelMap.lookup
 	PixelMap_maxLength		-> PixelMap.maxLength
 	PixelMap_remove**
 	PseudoBondMgr_mgr		-> PseudoBondMgr.mgr
 	Residue_getDefaultRibbonStyle	-> Residue.getDefaultRibbonStyle
 	RibbonResidueClass_classes		-> RibbonResidueClass.classes
 	RibbonResidueClass_deregisterClass	-> RibbonResidueClass.deregisterClass
 	RibbonResidueClass_registerClass	-> RibbonResidueClass.registerClass
 	RibbonXSection_circle		-> RibbonXSection.circle
 	RibbonXSection_line		-> RibbonXSection.line
 	RibbonXSection_square		-> RibbonXSection.square
 	Selectable_count		-> Selectable.count
 	Shader_list			-> Shader.list
 	Shader_lookup			-> Shader.lookup
 	Shader_remove**
 	Spline_makeGeometryVector	-> Spline.makeGeometryVector
 	Texture_computeComponents	-> Texture.computeComponents
 	Texture_computeDimension	-> Texture.computeDimension
 	Texture_computeImageTypeBytes	-> Texture.computeImageTypeBytes
 	Texture_computeTarget		-> Texture.computeTarget
 	Texture_list			-> Texture.list
 	Texture_lookup			-> Texture.lookup
 	Texture_remove**
 	TrackChanges_get		-> TrackChanges.get
 	Xform_coordFrame		-> Xform.coordFrame
 	Xform_identity			-> Xform.identity
 	Xform_lookAt			-> Xform.lookAt
 	Xform_rotation			-> Xform.rotation
 	Xform_translation		-> Xform.translation
 	Xform_xRotation			-> Xform.xRotation
 	Xform_xform			-> Xform.xform
 	Xform_yRotation			-> Xform.yRotation
 	Xform_zAlign			-> Xform.zAlign
 	Xform_zRotation			-> Xform.zRotation

** Color_remove, Material_remove, PixelMap_remove, Shader_remove, and Texture_remove

 	Unlike C++, Python can not have a method and a static method with
 	the same name.  So the static method versions have been excised
 	from the Python layer.



More information about the Chimera-dev mailing list