Rotate bond move large/small option in VR
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 Warwickhttp://www2.warwick.ac.uk/ j.r.lewandowski@warwick.ac.ukmailto:j.r.lewandowski@warwick.ac.uk | External: +44 (0) 24 76151355 | Internal: 51355 Millburn House: F07 | Coventry CV4 7AL | Find us on the interactive maphttp://www2.warwick.ac.uk/about/visiting/maps/interactive/ Lewandowski group websitehttps://www2.warwick.ac.uk/fac/sci/chemistry/research/lewandowski/lewandowskigroup/ | Warwick solid-state NMR group websitehttp://www2.warwick.ac.uk/fac/sci/physics/research/condensedmatt/nmr/
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@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@warwick.ac.uk mailto:j.r.lewandowski@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@cgl.ucsf.edu mailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
On Dec 6, 2019, at 3:11 PM, Tom Goddard goddard@sonic.net wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
Hi Eric,
Oops! That is easier! What I meant by the needed change "isn't too obvious" is that I thought my code would have a line that says "rotate_bond(bond, angle)" and then I would change it to "rotate_bond(bond, angle, move_smaller = False)". But in fact the code makes something called a BondRotater in one place (when the mouse is pressed) and later when the mouse is dragged uses that BondRotater object br.angle = new_angle. This just required a bit of digging, especially to make the more useful code modification that allows you to control which side where I needed to find out how to change the BondRotater to rotate the side closest to the button click (where I don't care which side is smaller).
None of that was meant as a critique of the code. I just wanted to warn anyone new to hacking ChimeraX that this isn't the simplest possible kind of change, like changing a False to a True somewhere.
Tom
On Dec 6, 2019, at 3:19 PM, Eric Pettersen pett@cgl.ucsf.edu wrote:
On Dec 6, 2019, at 3:11 PM, Tom Goddard <goddard@sonic.net mailto:goddard@sonic.net> wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Thank you both. Works like a charm. I like the solution with the rotation being defined by which side of the bond one clicks – that is exactly the type of thing I need. It gives me an error when I accidentally click at the center but I can live with that and just have to be careful with my selection.
Thanks again, Józef
From: Eric Pettersen pett@cgl.ucsf.edu Date: Friday, 6 December 2019 at 23:19 To: Tom Goddard goddard@sonic.net Cc: "Lewandowski, Jozef" J.R.Lewandowski@warwick.ac.uk, "chimerax-users@cgl.ucsf.edu" chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Rotate bond move large/small option in VR
On Dec 6, 2019, at 3:11 PM, Tom Goddard <goddard@sonic.netmailto:goddard@sonic.net> wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Dec 9, 2019, at 3:33 AM, Lewandowski, Jozef J.R.Lewandowski@warwick.ac.uk wrote:
Thank you both. Works like a charm. I like the solution with the rotation being defined by which side of the bond one clicks – that is exactly the type of thing I need. It gives me an error when I accidentally click at the center but I can live with that and just have to be careful with my selection.
Thanks again, Józef
From: Eric Pettersen pett@cgl.ucsf.edu Date: Friday, 6 December 2019 at 23:19 To: Tom Goddard goddard@sonic.net Cc: "Lewandowski, Jozef" J.R.Lewandowski@warwick.ac.uk, "chimerax-users@cgl.ucsf.edu" chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Rotate bond move large/small option in VR
On Dec 6, 2019, at 3:11 PM, Tom Goddard goddard@sonic.net wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Hi Jozef,
Please press the report bug button on the error dialog and I will fix the problem. I don’t think clicking in the middle of the bond is the issue and I need to see the error to fix it. Thanks.
Tom
On Dec 9, 2019, at 3:33 AM, Lewandowski, Jozef J.R.Lewandowski@warwick.ac.uk wrote:
Thank you both. Works like a charm. I like the solution with the rotation being defined by which side of the bond one clicks – that is exactly the type of thing I need. It gives me an error when I accidentally click at the center but I can live with that and just have to be careful with my selection.
Thanks again, Józef
From: Eric Pettersen pett@cgl.ucsf.edu Date: Friday, 6 December 2019 at 23:19 To: Tom Goddard goddard@sonic.net Cc: "Lewandowski, Jozef" J.R.Lewandowski@warwick.ac.uk, "chimerax-users@cgl.ucsf.edu" chimerax-users@cgl.ucsf.edu Subject: Re: [chimerax-users] Rotate bond move large/small option in VR
On Dec 6, 2019, at 3:11 PM, Tom Goddard goddard@sonic.net wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
Hi Józef,
I got your bug report. The error happened when you click to rotate a bond in VR and you miss the bond. The code I added last week and that I suggested in the previous email needed to check if no bond is picked. The fix will be in tonight's ChimeraX daily build. Here is the fix to the code I sent in a previous message (adding the lines "if br is None: return".
Tom
Fixed VR bond rotation code.
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 if br is None: return 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
On Dec 9, 2019, at 9:15 AM, Tom Goddard goddard@sonic.net wrote:
Hi Jozef,
Please press the report bug button on the error dialog and I will fix the problem. I don’t think clicking in the middle of the bond is the issue and I need to see the error to fix it. Thanks.
Tom
On Dec 9, 2019, at 3:33 AM, Lewandowski, Jozef <J.R.Lewandowski@warwick.ac.uk mailto:J.R.Lewandowski@warwick.ac.uk> wrote:
Thank you both. Works like a charm. I like the solution with the rotation being defined by which side of the bond one clicks – that is exactly the type of thing I need. It gives me an error when I accidentally click at the center but I can live with that and just have to be careful with my selection.
Thanks again, Józef
From: Eric Pettersen <pett@cgl.ucsf.edu mailto:pett@cgl.ucsf.edu> Date: Friday, 6 December 2019 at 23:19 To: Tom Goddard <goddard@sonic.net mailto:goddard@sonic.net> Cc: "Lewandowski, Jozef" <J.R.Lewandowski@warwick.ac.uk mailto:J.R.Lewandowski@warwick.ac.uk>, "chimerax-users@cgl.ucsf.edu mailto:chimerax-users@cgl.ucsf.edu" <chimerax-users@cgl.ucsf.edu mailto:chimerax-users@cgl.ucsf.edu> Subject: Re: [chimerax-users] Rotate bond move large/small option in VR
On Dec 6, 2019, at 3:11 PM, Tom Goddard <goddard@sonic.net mailto:goddard@sonic.net> wrote:
br = self.session.bond_rotations.new_rotation(pick.bond) br.moving_side = br.bond.other_atom(br.moving_side) # Move the large side
Not sure why this was hard to find since it’s a documented arg of new_rotation, but just do this:
br = self.session.bond_rotations.new_rotation(pick_bond, move_smaller_side=False)
—Eric
Eric Pettersen UCSF Computer Graphics Lab
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu mailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
ChimeraX-users mailing list ChimeraX-users@cgl.ucsf.edu mailto:ChimeraX-users@cgl.ucsf.edu Manage subscription: http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
participants (3)
-
Eric Pettersen
-
Lewandowski, Jozef
-
Tom Goddard