Foldit scripting preview

Started by Seth Cooper

Seth Cooper Staff Lv 1

We've started working on adding Lua scripting, and here's a very rough preview of what it looks like now. This is just in a command line window, but there will also be support for scripts in the cookbook.

What do you think? What kind of API would you like to see? Let us know in the comments!

LennStar Lv 1

Yes, its there!

Yes, show the command set.

Have I seen that right, that there are no ( ) for if? That can be complicated if you use three or mire ifs.

Seth Cooper Staff Lv 1

The syntax is Lua, so the ( ) in the if are optional, you can use them if you want.

Here are the current functions. Shake, wiggle, and so on use the new selection based interface. What other functions would be useful?

number get_score(): Return the current score.

number get_segment_score(integer segment_index_1[, …, integer segment_index_n]): Return the current score of the given segments. More than one segment index may be specified.

integer get_segment_count(): Return the number of segments.

integer get_band_count(): Return the number of bands.

void band_add_segment_segment(integer segment_index_1, integer segment_index_2): Add a band between the segments at 'segment_index_1' and at 'segment_index_2'.

void band_delete(integer band_index_1[, …, integer band_index_n]): Delete the bands at the given band indices.

void band_enable(integer band_index_1[, …, integer band_index_n]): Enable the bands at the given band indices.

void band_disable(integer band_index_1[, …, integer band_index_n]): Disable the bands at the given band indices.

void do_shake([integer iterations]): Run shake. Run for 'iterations' iterations if given; otherwise, until stopped.

void do_mutate([integer iterations]): Run mutate. Run for 'iterations' iterations if given; otherwise, until stopped.

void do_global_wiggle_all([integer iterations]): Run global wiggle on backbone and sidechains. Run for 'iterations' iterations if given; otherwise, until stopped.

void do_global_wiggle_backbone([integer iterations]): Run global wiggle on backbone. Run for 'iterations' iterations if given; otherwise, until stopped.

void do_global_wiggle_sidechains([integer iterations]): Run global wiggle on sidechains. Run for 'iterations' iterations if given; otherwise, until stopped.

void select_all(): Select all segments.

void select_index(integer segment_index_1[, …, integer segment_index_n]): Select segments at the given indices. More than one segment index may be specified.

void deselect_all(): Clear selection.

lusien Lv 1

Hey folders,
Seems like we haven't got much input yet. We really would like to know which other functions you would like to have when we release this scripting feature (of course we can always add more later). What kinds of functions will enable you to create cool and useful scripts? Let us know!

Sig Lv 1

Lua looks like a language which must be easy to learn for many programmers. However, every programmer has her preferred language.

You probably can't expose your API under many languages. But maybe you could allow some remote interfacing via simple/ReSTful/HTTP+XML web services. You would expose your API as a set of URLs with an embedded web server running on some local port. And programmers could control their local foldit instance using HTTP calls written in their preferred language.

One could then even imagine to have foldit made usable from web mashups and other sort of creative oddities which may turn into nice ways to allow interactivity and creativity with many more users.

What do you think ?

mdsmith Lv 1

This is fantastic, I can't wait to try it out.

I'd assume we'll have all the standard functions of the programming language, including functions, if/else, while and for loops, etc?

tedeum Lv 1

I've been working with a Java Robot class selecting through the gui. This should be MUCH easier! I look forward to trying it out.
FWIW, here are a couple of ideas for methods. Also, will it be possible to have access to the undo 'queue'? somehow?
Thank you.

void select_lowscore_index_range(integer length]): Select [length] segments surrounding the lowest scoring index.

void select_lowscore_indexes(integer count]): Select [count] possibly non-contiguous, segments surrounding the lowest scoring index.

integer select_random(): Select and return index of a random segment.

BootsMcGraw Lv 1

What advantages will scripting give the programmer-folders over the rest of us common folk who see the above posts only as so much Greek?

feet1st Lv 1

I can't believe I missed this post! I would like to run such things in parallel. So, for example, save to X. And then from 3 different machines, load X, and do different scripts against it. Basically to run without a GUI.