FANDOM


This is a place to brainstorm and figure out what functions should be added to Foldit Lua Interface to allow you to create scripts that imitate the actions that you perform as a human.

With the release of the Lua V2 interface, functions that are now available have been removed from the list. Check the history of the page to see stuff that once was here.

The 2017 feedback thread New Lua functions, any suggestions? contains many suggestions for new Lua functions.

A number of the suggestions have been marked as Implemented, with links to the Lua functions where appropriate. See Foldit Lua Functions for a complete list of the current functions.

Other suggestions are marked with Note. Some of suggestions have known workarounds, other suggestions involve puzzle types which aren't being used at present.

A few of the suggestions involve the recipe editor, and have been at least partially addressed by the ability import recipes from files.

Other Threads with Lua-related suggestions Edit

Protein Manipulation Functions Edit

  • We need threshold parameters, which automatically stops wiggle and shake when the score goes outside of a delta range. For example, structure.WiggleAll(1,10,3) would perform the normal structure.WiggleAll(1) operation, but would stop the wiggle if the score went down by 10 points or more, or up by 3 or more. If these parameters are nil, then foldit performs the current functionality. Many scripts need to put the protein into a higher energy state to get them out of a local minimum, but not distort the protein structure excessively. One iteration frequently is too much change in the protein, which causes the current entire structure layout to be lost.
  • We need ability to change wiggle power Implemented: see behavior.SetWigglePower and behavior.GetWigglePower
  • We need the ability to move and rotate the ligand in a protein design puzzle. And to move and rotate parts of protein after cut.
  • We need the ability to insert and remove protein segments in a protein design puzzle. Implemented: see structure.InsertResidue and structure.DeleteResidue

Banding Functions Edit

  • We need the ability to find the segment numbers of the endpoints of a band.
  • We need the ability to modify the strength and length of all existing bands, and affect all future created bands.
  • We need the ability to retrieve all the existing bands.
  • We need either the ability to save the current bands to a named object, or we need enough functions to be able to enumerate everything about every band and be able to reconstruct them ourselves. I need to be able to remove all the bands to the guide I have in place, run a script that uses bands, then reapply the bands to the guide.
  • We need the ability to band to the equivalent segment in the guide. This could be disabled in QTTN puzzles, if desired.
  • Delete shouldn't throw an exception when it fails - it can just not delete the non-existent band.
  • We need an ability to add notes to bands
  • We need an ability to add band going to symmetrical protein. Implemented: see band.AddBetweenSegments, which can add a band to a symmetric chain, and structure.GetSymCount which gets the number of symmetric chains

Cutpoint Functions Edit

  • We need to know if deleting a cutpoint has failed. Note: successfully deleting a cutpoint normally changes the score.
  • We need to be able to ask if there is a cutpoint at a segment. It's hard to write a script that preserves user-supplied cuts or that promises to clean up all its own cuts if we don't know whether the reason a cut didn't get deleted was because it's too far to heal or because there hadn't been a cut there in the first place. Walking every AA of a protein trying to heal cuts is costly time-wise; simpler would be to ask if a cut is present first.

Freezing Functions Edit

Alignment Functions Edit

Note: there haven't been new alignment puzzles in several years as of 2020.

  • We need the ability to determine the total number of available templates.
  • We need the ability to select/deselect a template.
  • We need the ability to determine the length of a template.
  • We need the ability to retrieve the template score.
  • We need the ability to shift/offset a letter (designation).
  • We need the ability to detect a gap (absence of a letter designation) in a template.
  • We need the ability to determine if a template is threadable.
  • We need the ability to determine which AAs and or sequences were threaded from which templates.

Guide Functions Edit

Note: there haven't been new Quest to the Native (QTTN) puzzles in several years as of 2020. QTTN puzzles rely on the guide. The "open as guide" function is still available for comparing two solutions, however.

  • We need tools to manipulate the guide tool.

Investigative Functions Edit

  • We need structure.GetDistance() to take optional atom numbers. Note: the equivalent is to add a band using band.AddBetweenSegments, then get its length using band.GetLength. The drawback is that banding functions are very slow.
  • We need the ability to get_aa_codon(), this information could be very vital, since an aa can be instantiated from more than one codon.
  • We need the ability to retrieve the entire group and solo rank lists to a Lua table. This is important for a script trying to increase rank. If there is a 30 point difference between me and the person above me, a different part of the script may run than if there is .03 points between us. Also, some scripts may execute different strategies based on the score between me and the person in first place.
  • We need the ability to retrieve the date and time a puzzle was posted.
  • We need the ability to retrieve the date and time that a puzzle was first worked on. Early in the working on a puzzle, one might use a completely different strategy than later.
  • We need the ability to retrieve the names of all the current saves for a given puzzle. Implemented: see save.GetSolutions and save.LoadSolutionByName
  • We need the ability to find out where voids are located. This needs to happen in such a way that we can identify protein segments that are around the void.
  • We need the ability to get a rating of each segment on how well it aligns to the guide. This corresponds to the color of segments when View Color Relative to Guide is checked.
  • We need to know which aa's have hydrogen bonds to which other ones. Or something like contact map could be implemented for all puzzles - it reports what contacts exist. I suggest these functions:
    • table structure.GetBonds(integer segmentIndex) - returns table where key is index of segments and value is number of bonds with it.
    • number structure.GetBondsCount(integer segmentIndex) - returns number of bonds for this segment
    • number structure.GetTotalBonds - returns total number of bonds
  • Contact map info should return how close two aa's need to be in order for the contact to succeed.
  • We need GetAtom, GetDonorAtoms, GetAcceptorAtoms, GetPolarHydrogens. To get atomic info - atom type, donors, acceptors, polar hydrogen. Note: for proteins, the atoms don't change, and the donor/acceptor status is also mostly constant. Histidine is the exception, since its sidechain nitrogens can switch their donor/acceptor status. The recipe Atom Tables 1.21 provides tables that provide much of the information. For ligands, it would be useful to have a way to determine the atom type and related informaton.

User Input Functions Edit

  • We need to have the type of point and click input that is possible in GUI scripts. The one I miss most is the ability to have the user select an amino acid or range along the backbone. I can have the user mark a range with a band before starting, which is ugly. But there is no way to ask a user for input in the middle of execution. (As an example, ask which sheet or helix to try straightening next.) RIEachus

Other Functions Edit

  • We need the ability to "Align Protein to Density' from Lua.
  • We need the ability of a recipe to be able to call another recipe.
  • We need the ability to scale the viewport (the equivalent of scrolling the mouse wheel).
  • We need the ability to alter all of the options.
  • We need the ability to save and restore saves. Implemented: see save.GetSolutions and save.LoadSolutionByName
  • We need at least one of these two features:
    1. We need the ability to maintain a stack of savesets. A saveset here is defined as all of the quicksave slots, plus the recent best. We need a saveset_push() and saveset_pop() function. A saveset_push() would take the current savesets and copy them to the top of a stack. When a saveset_pop() occurs, the top of the stack would overwrite all of the current saveset slots. The purpose is to make parts of a complex script not have to worry about what slots have been used. So at the start of a function, it can call saveset_push(), and before it returns, it can call saveset_pop().
    2. We need the ability to save savesets by name. saveset_save('foo'), saveset_restore('foo'), would save and restore the current savesets to the name 'foo'. These do not have to be persisted across runs of a script. These could again be used to save a saveset at the beginning of a function and restore it at the end.

Tweak function Edit

Note: some of the tweak functions are defined in the interface, but they don't actually do anything.

  • We need Tweak straighten secondary structure
  • We need Tweak rotate secondary structure
  • We need the ability to tweak sheets and helices, with all of the operations available from the user interface.

UI Functions Edit

  • We need an ability to change view settings
  • We need an ability to move camera (or at least to center it on some segment)

Lua Functions Edit

Implemented: the many standard Lua functions are available in V2 of the Foldit interface. The major exceptions include file and network input and output functions and metatable access.

Many of the Lua standard library functions need to be implemented. A discussion of which functions and their impact can be found at Lua Standard Libraries

ipairs / pairs -- index an array of strings Edit

I would like the following code to work:

   local _n = {["1"]=0,["2"]=0,["3"]=0,["4"]=0,}
   local function _s (n)
       for i,v in pairs (_n) do
           v = 1
       end
       return _n
   end
   _s(_n)
   print ( _n["3"] ) -- should print 1

Note: the code runs in Foldit, but prints 0. But the same result occurs in standalone Lua.

One problem is that the value v returned by ipairs is just that -- a value. It's a copy of one of the values from the table _n, it's not a reference or pointer to the value. (There are no pointers in Lua.) Changes to v have no impact on the contents of the table.

Another slight problem is that the function _s takes an argument for the table, but then goes ahead and uses the global name of the table, _n, instead of the argument. Not an issue, unless you try to use _s on a different table.

Here's a version of the code that produces the desired result, at least for one specific key:

  local _n = {["1"]=0,["2"]=0,["3"]=0,["4"]=0,}
  local function _s (n)
      for i,v in pairs (n) do
          v = 1
          if i == "3" then
               n [ i ] = 1
           end
      end
      return n
  end
  _s(_n)
  print ( _n["3"] ) -- should print 1

Editor Edit

Note: the Foldit recipe editor can import a recipe from a file and export a recipe to a file. The choice of an external editor is up to the user.

  • We need the ability to call an external editor, possibly set by user preferences

LuaEdit

  • It would be nice to be able to run "compiled" Lua code (luac) so it would run faster
  • It would be nice to implement meta-tables (to allow things like read-only variables)
  • We need the ability to save recipes themselves to a file in Linux (cut/paste not working). External editor would address this Note: the Foldit recipe editor can import a recipe from a file and export a recipe to a file.

Recipes Edit

  • We need the problem with large all.macro files crashing the client resolved Implemented: long since fixed
  • We need a button to reload the all.macro file into the cookbook. This would facilitate editing the recipes outside of Foldit; the painful workaround is to close and reopen Foldit. Implemented: the Foldit recipe editor can import a recipe from a file and export a recipe to a file. Issues with copying and pasting recipes have also been resolved, although it's still not possible to copy just part of a recipe. Also, the all.macro file is digitally signed, so it's not possible to modify the file outside of Foldit.
  • We need the ability to add folders to the Cookbook Note: there's no Lua function, but users can add folders manually.
  • We need the ability to sort recipes within the Cookbook Note: recipes are sorted alphabetically within a folder.
  • We need the ability to assign recipes to hotkeys
Community content is available under CC-BY-SA unless otherwise noted.