Hi Tony,

  There is currently not a way to allow the user to choose between two different ways to open a file with the ChimeraX Open File dialog.  Ideally you would just choose the file gaussian.log in the Open File dialog and then some new checkbutton options would appear in that dialog "Open as trajectory", "Open optimized structure" (it could even open both).  Right now the ChimeraX Open File dialog is not able to show any custom options.  The ChimeraX Save File dialog does allow custom options, for instance, when you are saving a session it shows a checkbutton "Include maps".  We could allow this with the Open File dialog too but there is a big downside.  Currently the Open File dialog uses the native Mac or Windows open dialog.  Those don't allow adding options.  So to add options we have to switch to a Qt Open dialog which is a poorer user experience.  We made that sacrifice because for saving many formats need options (e.g. save PDB needs an option to specify which open PDB model to save).

  Here are a few ideas.  You might have open create both the optimized structure model, and the trajectory model.  The user can easily close one if they don't want it.  Another approach would be have your open_file() routine pop-up a dialog asking whether to open optimized or trajectory.  That has the problem that even the open command would ask which is probably annoying since the user can specify what the want in the command.  But you could have your coordset option default to None and if it is specified as True or False then the routine does not popup a dialog.  A third option is we could make what you were trying work -- if you choose in the Open File dialog the filter to show only Molecular Trajectory formats, then choose your file, then it will open using your trajectory format.  Currently the format menu only controls what types of files are shown in the dialog, not how they are opened.  I tend to think your registering Gaussian log files as two different formats is a hack that should be avoided -- it is one format, and you just want some options on what is done when it gets opened.  In our older program Chimera the Open dialog "File type" menu includes an entry that says "All (ask type)" which pops up a separate dialog after you choose the file and press Open where there is a menu of types to choose from.  We could probably add that.  That was intended to handle files with a non-standard or ambiguous file suffix.  Again I'm not keen on this -- you really want options about how the file is opened, and it will just be confusing for the user if they have to do that by choosing between different file types.

  Maybe we can achieve the best result by allowing custom opening options like the Save File dialog does, only we still use a native Open File dialog and if the user clicks a file that has options it automatically pops up a separate window with the options for that format.  Then pressing the Open button on the Open File dialog closes both the open file dialog and the options pane.

Tom



On Dec 30, 2019, at 2:30 PM, Anthony James Schaefer <tony.schaefer@uga.edu> wrote:

Hello, 

Is there any way I can get a bundle to know that I'm trying to open a file from a certain category (e.g.Molecular structure vs. Molecular trajectory) from the File -> Open... menu?

I'm trying to build a plugin that will allow me to open Gaussian log files in ChimeraX. I'd like to have it open the optimized structure when I go File -> Open... and change the file filter to "Molecular structure files". When I set the file filter to "Molecular trajectory files", I'd like it to open the log file as a trajectory with each frame being one of Gaussian's optimization steps. The file stays the same, I just want to have my 'open_file' method know that it should open the file differently. 

So far, I've tried having multiple 'Open' entries in my bundle tags. Here are some relevant tags from my setup.py:
"ChimeraX :: DataFormat :: LOG :: Gaussian output file :: Molecular structure :: .log :: :: :: :: :: Gaussian output file :: utf-8",
"ChimeraX :: DataFormat :: LOG trajectory :: Gaussian output trajectory :: Molecular trajectory :: .log :: :: :: :: :: Gaussian output file :: utf-8",
"ChimeraX :: Open :: LOG :: Gaussian output file ::",
"ChimeraX :: Open :: LOG trajectory :: Gaussian output trajectory :: :: coordsets:Bool",

My 'open_file' definition line is:
def open_file(session, path, format_name, coordsets=False):

While I'm testing, I've set up my 'open_file' method to print the arguments that get passed to it. When I use File -> Open..., I can see that 'format_name' is always "Gaussian ouput file" (never "Gaussian output trajectory") and 'coordsets' is always False, regardless of the file filter. When I use the `open` command (`open asdf.log coordsets true`), 'coordsets' is True and 'format_name' is "Gaussian output file". 

I can work with the open command because of the 'coordsets' argument, but I'd like to know if there's something I can do with the File -> Open... menu. 

Thanks,

Tony
_______________________________________________
ChimeraX-users mailing list
ChimeraX-users@cgl.ucsf.edu
Manage subscription:
http://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users