themarquis Lv 1
Hey Alex,
I'm in the process of recovering from the h1n1 flu (that's why you haven't heard from me), but I'm excited to see your work!
I'll get on later today and respond in more detail.
Hey Alex,
I'm in the process of recovering from the h1n1 flu (that's why you haven't heard from me), but I'm excited to see your work!
I'll get on later today and respond in more detail.
all right, onto your question:
Yes, I think you should move ahead with the advanced tutorial(s) – I'm excited to see what you come up with. Here are some thoughts of what content might be needed (some of which you already mentioned)
-writing and using functions
-a section about the issue of the "missing" library functions and how to reproduce some of them: random numbers, abs, integer functions, factorial, etc (or whatever you think is important.) (also see next message for another thought about libraries).
-control structures (I do a for loop in intermediate, but it would be nice to cover how to use all the different control structures in lua: while, repeat, etc.)
-table constructors (basically arrays in lua)
-error messages/debugging (I do a bit on this in intermediate, but there is lots more to cover. For non-programmers especially, dealing with errors is a difficult process that they could use some pointers on. For programmer types, a list of the common error messages and what they mean might be useful.)
On another note, I had a thought about library functions. This is a big project, but wouldn't it be great if we wrote our own "libraries" for foldit lua?
Alex, maybe you should make a new page on the wiki that will be a collection of foldit lua “library” functions (or I will make it if I get the chance). The “library” is going to be written by us (or so far, by you :) ). It can include functions that reproduce standard lua libraries that are woefully missing, as well as specialized functions that serve a general purpose in foldit and that many people might want to use as “building blocks” for their own programs. In other words, what are some common folding tasks that people might want to do that are very useful but a bit complicated to implement? If we write library functions for them, then people don't have to worry about how to code them – they can just use them like the standard commands. Of course, they will have to cut/paste the library functions into their programs, but that should be easy.
For example, a function that returns a random segment index. There could be an overriden version of it that takes parameters representing an index range. So get_random_segment() or get_random_segment(5, 20). Similarly, add_random_band() and add_random_band(5,20) (add random band between seg 5 and 20). select_random_index(), wiggle_random_index, and so on (that might be overkill, but you get the idea).
Mcurtis' print_segment_details might be a good foldit lua library function. Something like get_structure_indices might be nice (takes a structure type and a start index and returns an index range representing the next location where that structure is located). Or get_all_structure_indices() would return sets of ordered pairs (table?) representing where each structure starts and ends. We could also do a similar thing for residue types: get_residue_indices() that takes a residue type.
There could be something like select_lowest_scoring_segments() that takes an int and finds the n lowest scorers. A select_lowest_scoring_structures() would find the n lowest scoring structures.
A save_structure() uses get_structure_indices to store the protein's current structures in memory, then a restore_structure() can restore it.
Finally, we could try to replicate the local wiggle sequence from the cookbook (though as far as I know, the local/global wiggle is still an issue in scripting) for folks who might “miss” it! It would just be a loop w/ wiggle by 2s or 3s or whatever (since by 1s doesn't work right).
Anyway, I'm just throwing out some ideas! Anyone else have thoughts?
So, you got infected by your gf?
Ow….
But it's good to know that we both do better now :)
"Alex, maybe you should make a new page on the wiki that will be a collection of foldit lua “library” functions (or I will make it if I get the chance)"
Yes, a library for those functions which are not accessible due to restrictions are a MUST!
"It can include functions that reproduce standard lua libraries that are woefully missing, as well as specialized functions that serve a general purpose in foldit and that many people might want to use as “building blocks” for their own programs. In other words, what are some common folding tasks that people might want to do that are very useful but a bit complicated to implement? If we write library functions for them, then people don't have to worry about how to code them – they can just use them like the standard commands. Of course, they will have to cut/paste the library functions into their programs, but that should be easy."
Accepted!
"For example, a function that returns a random segment index. There could be an overriden version of it that takes parameters representing an index range. So get_random_segment() or get_random_segment(5, 20). Similarly, add_random_band() and add_random_band(5,20) (add random band between seg 5 and 20). select_random_index(), wiggle_random_index, and so on (that might be overkill, but you get the idea)."
I've just created a new "random"-bond-algorithm, whre you can choose, how the numbers are generated!
http://fold.it/portal/recipe/1987
"Mcurtis' print_segment_details might be a good foldit lua library function. Something like get_structure_indices might be nice (takes a structure type and a start index and returns an index range representing the next location where that structure is located). Or get_all_structure_indices() would return sets of ordered pairs (table?) representing where each structure starts and ends. We could also do a similar thing for residue types: get_residue_indices() that takes a residue type."
I'm still missing a description of all segment attributes, for example what "other" means.
"A save_structure() uses get_structure_indices to store the protein's current structures in memory, then a restore_structure() can restore it."
This is what I also want!
kind regards,
Alex
I'm glad you're feeling better, too! How long until your next treatment?
We both got the flu. She got sick about a day before me, but in retrospect, I might have started the illness that day too because I had awful chest pains (I thought I had strained a muscle or something)! Then we were both very sick for about 5-6 days – just sat around the house coughing and complaining. The worst part was that we were so sick that we couldn't even take care of each other. But much much better now … still coughing, but feeling fine.
I'm happy we agree with the "library". Maybe I will work on a couple of these when I get the chance – save and restore structures?
Your new randomization algorithm is great and i think we should use that as the basis for all our randomization library functions.
I was talking to someone – gneutral? About the lack of library functions (which he was understandably not very happy about) and we went back and forth a bit about whether we can replicate missing library functions ourselves. I think we argued about integer functions and how to convert a float to an int without the library. It's tedious, but you'd have to grab the digits after the decimal using mod or something, then use if statements:
say that our original number is x. The code would look something like this:
i = x mod 1 // integer part
d = x - i // decimal part
if d < .5 then n = i
if d > .5 then n = i + 1
(n is returned as the int)
We can replicate floor and ceiling this way, too.
I made a new page on the wiki for foldit library functions:
http://foldit.wikia.com/wiki/FoldIt_Lua_Library
for links or cut/paste code. but we should consider it a short-term strategy. Code should live in a repository somewhere and we can just link to it from the wiki.
That's great!
I'm on the way to paste some functions.
Should we separate the functions by ==name==?, so we can create an index?
I've got a shorter (and faster) way for integer:
Note, that using many IF-conditions slow down computing.
The CPU has to run more internal commands on assembler-layer, where all program languages are transformed to at last, than on a single addition-task, so I'm trying to use as less conditions as possible.
Have a look into my latest random-Bond recipe, where I also use integer.
If you have a value, which should be activated or deactivated, you can do it this way:
function (value,active)
if active==1 then y=value end
elseif active==0 then y=0 end
return y
end
OR
function (value,active)
y=value*active
return y
end
Whereas the second solution runs faster, because it uses CPU calculationg functions and gets only memory information some times.
The first solution has to get memory values more times to compare the values (program-lanugages use data-arrays for the varable names and assign them to a memory adress, for example value->Addr 00FF, so they have to reget them from there by using the array).
So, as I meantioned arrays here, I'm happy that mentioned them before and you want to describe them, too!
Something other:
At first, I have to wait for 6 months to have another MRI, so they can check if the therapy was effective, and how the tumor did change.
Then we can think about a second therapy, as it is required (I hope not!)
best regards,
Alex
Alex, you're much better at programming efficiently than I am! Which is why I hope you write many library functions :)
I'm on the way to paste some functions.
Should we separate the functions by ==name==?, so we can create an index?
Yes, that's a good idea. Or if you just set each function name to h3 on the wiki editor, it will make headers and an index for us. I'd recommend using the PRE setting for all the code so that it's marked as code and it's easier for people to cut and paste (see my "simplified list of lua commands" where I have super, super easy code snippets http://foldit.wikia.com/wiki/Simplified_List_of_Lua_Commands).
I'm still having the feeling like using wiki to store a bunch of code is not optimal. And in fact, our little "lua scripting working group" does not have a home anywhere, but we have a couple of forum posts and in-game messaging and the wiki, but that is not enough! So we will have to think more about that.
speaking of library functions, I wrote up a couple of functions yesterday for saving and restoring secondary structures. The big problem, though, is that the functions are not very useful because there's no way to store info about the structures to access at a later time (after script is done running). For example, you can't run a script to store the structure data, then do folding or run other scripts or whatever, and then run a script to restore structure data. Because we cannot store anything in memory after a script exits. (as far as I know) Yet again, reading/writing files would be the way to go on this, but it's not possible (and the devs don't seem to be working on this at all).
So save/restore structures can only work in two ways: 1) if you had a script that saved, then changed structures, then restored all in one script (how often will people do this?) or 2) output structures as a concat string to output window, cut(which we can't do with output!?!?!) and then paste the string and pass as parameter to restore. Very tedious and annoying!!
But one of my group members makes cookbook recipes that set structures for some puzzles, which must be a lot of work, so this would be an easier method for him. But for most people, it would not be very useful.
Any thoughts??
You can tell that I'm obsessed with reading/writing files from foldit lua. Can you think of any other way to pass information from foldit lua to somewhere else? We can get the scripts themselves, but can we get the output or store data somehow?
I'm also for file access, for the reasons you meant.
Copying data out of the output window doesn't work, so it is my idea, as we made it with the all.macro-files, that we take the puzzle-files and get the structure information out of them, so we can paste them back into the script editor.
But my question of the puzzle-file structure wasn't answered.
I'll give it a try and check them with a HEX-edior or Notepad++
Or, maybe Judecca has got an idea?