Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#6252 closed defect (limitation)

perframe surface zone keeps showing whole surface

Reported by: J.R.Lewandowski@… Owned by: Tom Goddard
Priority: moderate Milestone:
Component: Surface Version:
Keywords: Cc: Elaine Meng
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

From: "Lewandowski, Jozef" <J.R.Lewandowski@…> via ChimeraX-users" <chimerax-users@…>
Subject: [chimerax-users] Surface zone and movie recording
Date: February 25, 2022 at 5:42:24 AM PST
Hi,
I would like to use “surface zone” command to visualise a substrate channel in an animation of an MD trajectory. For that I would like to regenerate the surface every frame with “perframe”.
However, if I do that when I record the movie the entire surface (instead of just the selected zone) will flash before the zone is displayed. Is there any way so that only the surface zone will be displayed from frame to frame without the entire surface flashing?
I essentially just would like to follow the changes to the substrate channel without any distractions.
Thank you,
Józef

Elaine: I can reproduce this problem with a small test case, ChimeraX commands

open 1plx coordset true
perframe "surf; surf zone #1 near S"

... looks OK when you are just sitting on one frame. But when you drag the slider the whole surface flashes, and when I click the "play" button on the slider, all I see is the whole surface bopping around.

Still the same problem if I only use "surface" once and just put "surf zone" in the perframe.

Change History (3)

comment:1 by Tom Goddard, 4 years ago

Cc: Elaine Meng added
Notify when closed: J.R.Lewandowski@warwick.ac.uk
Priority: highmoderate
Reporter: changed from Elaine Meng to J.R.Lewandowski@…

Here is what is happening. The perframe script gets triggered at the start of a new frame. But right after that and before the frame is drawn, the code checks for changes in atom coordinates and updates the surface. So the perframe runs the surface zone, and then the coordinate change is handled after that and redraws the surface eliminating the zone. So you always see the surface without the zone.

At first I thought when the coordinates change the zone should get updated. I made a small code change to do that. But with "surface zone #1 near :4" it has a rather bad effect because the zone is preserved about the atoms of residue 4 when the command was run. When you change coordinates it only remembers the positions of the original residue 4 coordinates when recomputing the zone -- it has no idea they came from residue :4. Probably you expect it to make the zone around the new residue 4 but it cannot do that because the surface zone does not remember what atoms were involved. So I think the current behavior where a surface removes the zone when a new molecular surface is made is probably best.

So the question is how to convince ChimeraX to update the surface for the coordinate change, then do the surface zone on the new surface, in that order.

comment:2 by Tom Goddard, 4 years ago

Resolution: limitation
Status: assignedclosed

Ok, this isn't pretty but here are some solutions.

The problem is that the surface gets automatically updated after a coordinate change right before rendering, leaving no chance for a surface zone to happen after the coordinate change but before the rendering. So here are two approaches.

First the incredibly simple. If you just want the surface near certain residues which line the channel don't use a zone, just show the surface patches for those residues

perframe "surface :4,7,8,9,16"

But maybe you are taking a zone near some markers in the channel so you need a zone. Then use a trickier method of using the "update false" option to prevent the surface from auto updating when the coordinates change deleting your zone:

perframe "surface close #1 ; surface #1 update false ; surface zone #1 near #2"

This just closes any previous surface, makes a new one without enabling automatic updates when coordinates change, and zoning that fixed surface. When recording a movie it would look like

open 1mtx coordset true
coordset #1
perframe "surface close #1 ; surface #1 update false ; surface zone #1 near #2"
movie record
wait 23
movie encode

It is important that coordset command come before the perframe command so that on each frame the coordset change happens first, then the surface is recomputed in that order.

While the behavior of surface updating with coordinate changes and zoning is bad I don't see a way to improve it. You might think the surface should update as soon as the coordinates change instead of being delayed until rendering occurs. But ChimeraX only sends notices about when coordinates change right before rendering so that is the only time when the code knows to do the surface update. This is the way all of ChimeraX code works, batching up all the atomic changes and delivering them to any tools (such as surface calculation) that wants to know about changes before a rendering occurs. So this is a limitation of the ChimeraX design in how tools find out about structure changes.

I think this is a pretty rare case so I am ok calling it a limitation, since it is easy to work around, especially if you can use a surface defined by atoms/residues.

in reply to:  3 ; comment:3 by J.R.Lewandowski@…, 4 years ago

Thank you both. I think I can work with that. 
Regards,
Józef

-----Original Message-----
From: ChimeraX <ChimeraX-bugs-admin@cgl.ucsf.edu> 
Sent: 26 February 2022 00:26
Cc: Lewandowski, Jozef <J.R.Lewandowski@warwick.ac.uk>; goddard@cgl.ucsf.edu; meng@cgl.ucsf.edu
Subject: Re: [ChimeraX] #6252: perframe surface zone keeps showing whole surface

#6252: perframe surface zone keeps showing whole surface
----------------------------------------+-------------------------
          Reporter:  J.R.Lewandowski@…  |      Owner:  Tom Goddard
              Type:  defect             |     Status:  closed
          Priority:  moderate           |  Milestone:
         Component:  Surface            |    Version:
        Resolution:  limitation         |   Keywords:
        Blocked By:                     |   Blocking:
Notify when closed:                     |   Platform:  all
           Project:  ChimeraX           |
----------------------------------------+-------------------------
Changes (by Tom Goddard):

 * status:  assigned => closed
 * resolution:   => limitation


Comment:

 Ok, this isn't pretty but here are some solutions.

 The problem is that the surface gets automatically updated after a  coordinate change right before rendering, leaving no chance for a surface  zone to happen after the coordinate change but before the rendering.  So  here are two approaches.

 First the incredibly simple.  If you just want the surface near certain  residues which line the channel don't use a zone, just show the surface  patches for those residues

    perframe "surface :4,7,8,9,16"

 But maybe you are taking a zone near some markers in the channel so you  need a zone.  Then use a trickier method of using the "update false"
 option to prevent the surface from auto updating when the coordinates  change deleting your zone:

   perframe "surface close #1 ; surface #1 update false ; surface zone #1  near #2"

 This just closes any previous surface, makes a new one without enabling  automatic updates when coordinates change, and zoning that fixed surface.
 When recording a movie it would look like

 open 1mtx coordset true
 coordset #1
 perframe "surface close #1 ; surface #1 update false ; surface zone #1  near #2"
 movie record
 wait 23
 movie encode

 It is important that coordset command come before the perframe command so  that on each frame the coordset change happens first, then the surface is  recomputed in that order.

 While the behavior of surface updating with coordinate changes and zoning  is bad I don't see a way to improve it.  You might think the surface  should update as soon as the coordinates change instead of being delayed  until rendering occurs.  But ChimeraX only sends notices about when  coordinates change right before rendering so that is the only time when  the code knows to do the surface update.  This is the way all of ChimeraX  code works, batching up all the atomic changes and delivering them to any  tools (such as surface calculation) that wants to know about changes  before a rendering occurs.  So this is a limitation of the ChimeraX design  in how tools find out about structure changes.

 I think this is a pretty rare case so I am ok calling it a limitation,  since it is easy to work around, especially if you can use a surface  defined by atoms/residues.

--
Ticket URL: <https://www.rbvi.ucsf.edu/trac/ChimeraX/ticket/6252#comment:2>
ChimeraX <https://www.rbvi.ucsf.edu/chimerax/>
ChimeraX Issue Tracker
Note: See TracTickets for help on using tickets.