Changes between Version 17 and Version 18 of ChimeraAnimationState


Ignore:
Timestamp:
Jan 7, 2011, 10:59:57 AM (15 years ago)
Author:
Darren Weber
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • ChimeraAnimationState

    v17 v18  
    9191}}}
    9292
     93See also the [http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/bild.html Chimera BILD] commands.
     94
     95==== 'Active' models ====
     96
     97{{{
     98#!python
     99#
     100# Working with a specific active model:
     101# openState(id: int, subid: int)
     102modelID = chimera.openModels.listIds()[0]
     103model_openState = chimera.openModels.openState(*modelID)
     104if model_openState.active:
     105    # do something useful with it
     106    print model_openState.xform
     107    print model_openState.xform.getRotation()
     108    print model_openState.xform.getTranslation()
     109#
     110# looping over all open-active models
     111#
     112if chimera.openModels.hasActiveModels():
     113    om = chimera.openModels.list(all=True)
     114    for m in om:
     115        if m.openState.active:
     116            # do something useful with it
     117            print m.openState.xform
     118#
     119# Setting 'active' models:
     120# chimera.openModels.setActive(id: int, active: bool)
     121#
     122chimera.openModels.setActive(modelID[0], False)
     123model_openState.active
     124# False
     125chimera.openModels.setActive(modelID[0], True)
     126model_openState.active
     127# True
     128
     129}}}
     130
     131
    93132
    94133=== Atoms ===
     
    100139}}}
    101140
    102 ==== Color ====
     141==== Representations ====
     142
     143Each atom in a molecule has a drawMode attribute, with possible values: 0 = 'dot', 1 = 'sphere', 2 = 'endcap', 3 = 'ball'.  These values can be compared with the equivalent 'enum' values in chimera.Atom, i.e.:
     144
     145{{{
     146#!python
     147>>> chimera.Atom.Dot
     1480
     149>>> chimera.Atom.Sphere
     1501
     151>>> chimera.Atom.EndCap
     1522
     153>>> chimera.Atom.Ball
     1543
     155}}}
     156
     157{{{
     158#!python
     159molecules = chimera.openModels.list(modelTypes=[chimera.Molecule])
     160for m in molecules:
     161    for a in m.atoms:
     162        print a.drawMode == chimera.Atom.Sphere
     163}}}
     164
     165
     166==== Color and Material Attributes ====
     167
     168See [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/Main_ColorWellUI.html Main_ColorWellUI example].
    103169
    104170{{{
     
    167233
    168234
    169 ==== Representations ====
    170 
    171 Each atom in a molecule has a drawMode attribute, with possible values: 0 = 'dot', 1 = 'sphere', 2 = 'endcap', 3 = 'ball'.  These values can be compared with the equivalent 'enum' values in chimera.Atom, i.e.:
    172 
    173 {{{
    174 #!python
    175 >>> chimera.Atom.Dot
    176 0
    177 >>> chimera.Atom.Sphere
    178 1
    179 >>> chimera.Atom.EndCap
    180 2
    181 >>> chimera.Atom.Ball
    182 3
    183 }}}
    184 
    185 {{{
    186 #!python
    187 molecules = chimera.openModels.list(modelTypes=[chimera.Molecule])
    188 for m in molecules:
    189     for a in m.atoms:
    190         print a.drawMode == chimera.Atom.Sphere
    191 }}}
    192 
    193 
    194 === Parameter Access Methods ===
    195 
    196 Something like this gains access to a lot of view parameters:
    197 {{{
    198 #!python
    199 for n in dir(chimera.viewer):
    200     print n, eval('type(chimera.viewer.%s)' % n)
    201 }}}
    202 
    203 Some tips in the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html programming FAQ] are useful (esp, items 4, 5, 7-10).
    204 
    205 ==== Attributes: To Copy or Not to Copy, that is the question! ====
    206 
    207 From the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html FAQ], item (7): Some attributes return a copy of an object.
    208 {{{
    209 #!python
    210 >>> xf = model.openState.xform  # xf is a copy of the model's Xform matrix.
    211 >>> xf.zRotate(45)              # This will not rotate the model.
    212 
    213 >>> c = model.atoms[0].color    # c is the MaterialColor object for the atom
    214 >>> c.ambientDiffuse = (1,0,0)  # The Atom color changes immediately to red.
    215 }}}
    216 
    217 Some Chimera objects returned as attributes are always copies, some are always references to the uncopied object. Objects that are always copied include {{{Xform, Vector, Point, Sphere, Element, MolResId, Coord,}}} .... Objects that are never copied include {{{Atom, Bond, PseudoBond, CoordSet, Molecule, Residue, RibbonStyle,}}} .... Object that can be copied have a {{{__copy__}}} method. In order to know if an object type is passed by value is to look at the Chimera C++ header files. Classes without a !WrapPy base class are always copied. This base class is part of the C++ to Python interface generation.
    218 
    219 
    220 
    221 ==== Color and Material Attributes ====
    222 
    223 See http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/Main_ColorWellUI.html
    224 
    225 Also need a function for color interpolations (linear may suffice).  This may be a simple function to interpolate each component of the RGBA tuple from stateA to stateB over N frames (the range of values is between 0-1, so it's a floating point interpolation).
     235
     236
    226237
    227238Get a PDB molecule to play with:
     
    274285
    275286
     287=== Parameter Access Methods ===
     288
     289Something like this gains access to a lot of view parameters:
     290{{{
     291#!python
     292for n in dir(chimera.viewer):
     293    print n, eval('type(chimera.viewer.%s)' % n)
     294}}}
     295
     296Some tips in the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html programming FAQ] are useful (esp, items 4, 5, 7-10).
     297
     298==== Attributes: To Copy or Not to Copy, that is the question! ====
     299
     300From the [http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html FAQ], item (7): Some attributes return a copy of an object.
     301{{{
     302#!python
     303>>> xf = model.openState.xform  # xf is a copy of the model's Xform matrix.
     304>>> xf.zRotate(45)              # This will not rotate the model.
     305
     306>>> c = model.atoms[0].color    # c is the MaterialColor object for the atom
     307>>> c.ambientDiffuse = (1,0,0)  # The Atom color changes immediately to red.
     308}}}
     309
     310Some Chimera objects returned as attributes are always copies, some are always references to the uncopied object. Objects that are always copied include {{{Xform, Vector, Point, Sphere, Element, MolResId, Coord,}}} .... Objects that are never copied include {{{Atom, Bond, PseudoBond, CoordSet, Molecule, Residue, RibbonStyle,}}} .... Object that can be copied have a {{{__copy__}}} method. In order to know if an object type is passed by value is to look at the Chimera C++ header files. Classes without a !WrapPy base class are always copied. This base class is part of the C++ to Python interface generation.
     311
     312
    276313==== openState attributes ====
    277314
     
    281318
    282319
    283 
    284 ==== 'Active' models ====
    285 
    286 {{{
    287 #!python
    288 #
    289 # Working with a specific active model:
    290 # openState(id: int, subid: int)
    291 modelID = chimera.openModels.listIds()[0]
    292 model_openState = chimera.openModels.openState(*modelID)
    293 if model_openState.active:
    294     # do something useful with it
    295     print model_openState.xform
    296     print model_openState.xform.getRotation()
    297     print model_openState.xform.getTranslation()
    298 #
    299 # looping over all open-active models
    300 #
    301 if chimera.openModels.hasActiveModels():
    302     om = chimera.openModels.list(all=True)
    303     for m in om:
    304         if m.openState.active:
    305             # do something useful with it
    306             print m.openState.xform
    307 #
    308 # Setting 'active' models:
    309 # chimera.openModels.setActive(id: int, active: bool)
    310 #
    311 chimera.openModels.setActive(modelID[0], False)
    312 model_openState.active
    313 # False
    314 chimera.openModels.setActive(modelID[0], True)
    315 model_openState.active
    316 # True
    317 
    318 }}}
    319320
    320321