Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#487 closed defect (invalid)

error trying to use perframe with alias

Reported by: Elaine Meng Owned by: Tom Goddard
Priority: major Milestone:
Component: Command Line Version:
Keywords: Cc: Eric Pettersen, Conrad Huang
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

Maybe it's user error, but I can't get my first perframe example in
http://www.cgl.ucsf.edu/home/meng/chimera2/user/commands/perframe.html
to work... I had a similar example that worked in Chimera.

alias snap save $1.png
cd ~/Desktop
perframe snap zeropad 3; roll y 2 180; wait 180; ~perf

gives in Log:
Error executing per-frame command 'snap': 'int' object has no attribute 'split'

Change History (6)

comment:1 by Tom Goddard, 9 years ago

Resolution: invalid
Status: newclosed

This won't work because perframe knows nothing about expanding aliases. The perframe command will simply run snap 180 times with no argument. Running snap with no argument gives a cryptic error message which I will report as a separate bug. The following works correctly

perframe "snap $1" zeropad 3; roll y 2 180; wait 180; ~perf

although I think it is better to give a simple example in the docs without alias

perframe "save $1.png" zeropad 3; roll y 2 180; wait 180; ~perf

The $1 in your snap alias has a different meaning than the $1 in the perframe command. The alias replaces its first argument with its $1, while perframe puts in a frame number for the expliciltly given $1 in the perframe command. It doesn't make sense to me to substitute the alias text into the perframe command since then somehow the alias is just ignoring the fact that a $1 is supposed to be substituted for the first argument ($1 becomes 5 in "snap 5").

comment:2 by Elaine Meng, 9 years ago

This approach had worked in Chimera, and so I was expecting the same behavior in ChimeraX.  Is this a conscious choice to make it behave differently?

I had multiple examples, both with and without aliases, that I’d taken from the original Chimera “perframe” manpage and changed slightly to work with ChimeraX.  The Chimera examples had all been verified to work in Chimera.  
http://www.rbvi.ucsf.edu/chimera/docs/UsersGuide/midas/perframe.html

comment:3 by goddard@…, 9 years ago

I does not make sense to me that an alias appearing in a perframe command behaves in a different way than an alias run directly.  In "alias snap save $1.png" the $1 is replaced by the first argument given to the snap command.  When you use "snap" in perframe it has no arguments and that seems clearly to be an error in use of the perframe command, supplying a command with the wrong number of arguments.  I can see how that could be hacked to work in Chimera 1, where the perframe command decides not to treat the operation argument as a normal command, instead it looks to see if it is an alias and if it is then it treats it different from how the alias would behave if run as a standalone command -- in otherwords it expands it out and does not treat the $1 as the first argument.  That is an ugly hack which confounds the meaning of the $1 in the alias definition.

So I do not think we should allow that perframe behavior.  I grant that not putting this special hack into perframe means using aliases with perframe is a little bit more typing

	perframe "somealias $1"

instead of just

	perframe somealias

It is important that the command behavior be self evident.  The second command should behave like

	somealias
	somealias
	somealias
	...

independent of whether somealias is an alias or a command -- I may not know whether somealias is an alias, maybe ChimeraX defined some builtin alias that for all purposes looks like a command.

comment:4 by Elaine Meng, 9 years ago

I can live with it, as long as it is a conscious decision and not just forgetting how it worked before.  To me, the old (Chimera) behavior was very easy to understand as simple string substitution and the new (ChimeraX) behavior is a little confusing, e.g.

alias snap save $1.png
perframe snap zeropad 3; roll y 2 180; wait 180; ~perf

…in Chimera would simply substitute the string “save #1.png” to give:

perframe “save $1.png” zeropad 3; roll y 2 180; wait 180; ~perf

…whereas I guess ChimeraX  is instead evaluating “snap” separately.

in reply to:  5 ; comment:5 by Elaine Meng, 8 years ago

I’m still confused by this change between Chimera1 and ChimeraX.   So if I had the following commands in Chimera1, how could I do it with an alias in ChimeraX?  (or is it not possible to do with an alias anymore?)  I’m trying to revise the documentation and realized I don’t understand the current behavior well enough.

alias snap save $1.png
perframe snap zeropad 3; roll y 2 180; wait 180; ~perf


in reply to:  6 ; comment:6 by goddard@…, 8 years ago

What you need in ChimeraX is

  perframe “snap $1” zeropad 3 …

because your snap command takes an argument so “perframe snap zeropad 3...” would not work.  As I understand it ChimeraX alias is not a text substitution, it is a way of defining a new command.


Note: See TracTickets for help on using tickets.