[chimerax-users] Rotate bond move large/small option in VR

Tom Goddard goddard at sonic.net
Fri Dec 6 15:11:15 PST 2019


Hi Józef,

  I guess you are rotating bonds of small molecules and want to control which end moves.  We don't have any support for options that change the behavior of mouse modes (or VR modes) right now, although this has come up a lot that users want a slightly different mouse mode behavior, so I hope in the future to support mouse mode options.  While the torsion command that rotates bonds has a "move small / large" option the bond rotation mouse mode always moves the small end.

  For now you can hack ChimeraX Python to do what you want.  First find the bond rotation mouse mode code, on Windows it will be

	chimerax/bin/lib/site-packages/chimerax/atomic/bond_rot/mouse_rot.py

The code change to move the large size actually isn't too obvious, I had to do some spelunking to find it, but you would add a line to the code changing

                br = self.session.bond_rotations.new_rotation(pick.bond)
                self.session.logger.status('Rotating bond %s' % str(pick.bond))

to
                br = self.session.bond_rotations.new_rotation(pick.bond)
                br.moving_side = br.bond.other_atom(br.moving_side)  # Move the large side
                self.session.logger.status('Rotating bond %s' % str(pick.bond))

Keep the indentation the same since that is important in Python.  Then the bond rotation mouse mode will always move the large side.

  But I guess you really want to control which side rotates.  So how about in VR we move the side the hand controller is closest to when you click the bond? To do that instead of the above change I would change the vr_press() routine adding some lines, from

    def vr_press(self, event):
        # Virtual reality hand controller button press.
        pick = event.picked_object(self.view)
        self._bond_rot = self._bond_rotation(pick)

to

    def vr_press(self, event):
        # Virtual reality hand controller button press.
        pick = event.picked_object(self.view)
        self._bond_rot = self._bond_rotation(pick)

        # Move the side of the bond the VR click is closest to.
        br = self._bond_rot
        atom1 = br.moving_side
        atom2 = br.bond.other_atom(atom1)
        p = event.tip_position
        from chimerax.core.geometry import distance
        if distance(p, atom2.scene_coord) < distance(p, atom1.scene_coord):
            br.moving_side = atom2    # Switch to moving the atom2 side

A drawback of these Python hacks is that when you update your ChimeraX it won't have your code modifications.  To make it easier to add this modification I've put it into our code but it is disabled by default since mostly people rotate protein side-chain bonds and they don't want the large side (ie whole protein chain) rotating.  To enable it I put a flag in the vr_press() routine move_closer_side that you can change from False to True, simplifying your code edit.

	Tom


> On Dec 6, 2019, at 9:21 AM, Lewandowski, Jozef <J.R.Lewandowski at warwick.ac.uk> wrote:
> 
> Hi, 
>  
> Is there a way to change the option from the default “move small” to “move large” of the Bond rotation tool in VR?
> Ideally, it would be great if I could switch between these options on the fly with some combination of buttons on the controllers.
> If nothing like that is implemented is there a way I could change the “move” default for the Bond rotation tool in VR using the command line?
>  
> Thanks,
> Józef
>  
> ------------------------------------------------------------------------------------------------------
> Józef R. Lewandowski
> Professor  |  Department of Chemistry |  University of Warwick <http://www2.warwick.ac.uk/>
> j.r.lewandowski at warwick.ac.uk <mailto:j.r.lewandowski at warwick.ac.uk>  |  External: +44 (0) 24 76151355 |  Internal: 51355  
> Millburn House: F07 |  Coventry CV4 7AL  | Find us on the interactive map <http://www2.warwick.ac.uk/about/visiting/maps/interactive/>
> Lewandowski group website <https://www2.warwick.ac.uk/fac/sci/chemistry/research/lewandowski/lewandowskigroup/> | Warwick solid-state NMR group website <http://www2.warwick.ac.uk/fac/sci/physics/research/condensedmatt/nmr/>
>  
>  
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu <mailto:ChimeraX-users at cgl.ucsf.edu>
> Manage subscription:
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users <http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20191206/16b2ce9e/attachment.html>


More information about the ChimeraX-users mailing list