Icon representing a recipe

Recipe: Random Mutate

created by joshmiller

Profile


Name
Random Mutate
ID
105522
Shared with
Public
Parent
None
Children
Created on
January 03, 2022 at 21:27 PM UTC
Updated on
January 03, 2022 at 21:27 PM UTC
Description

Randomly mutates some amino acids to change your sequence. No guarantee that it actually helps your score, just gives some randomness to your fold. No quality of life features yet, might come later if this is helpful.

Best for


Code


-- Random Mutate by joshmiller -- Randomly changes a couple of amino acids, to switch up your sequence single_letter_codes = { "g","a","v","l","i","m","f","w","p","s","t","c","y","n","q","d","e","k","r","h"} function mutate(mutations) mutations = 3 for ii = 1, mutations do res = math.ceil(math.random() * structure.GetCount()) aa = single_letter_codes[math.ceil(math.random() * 20.0)] structure.SetAminoAcid(res, aa) print("changed", res, "to", aa) end end math.randomseed(recipe.GetRandomSeed()) local d = dialog.CreateDialog("Random Mutate") d.mutations = dialog.AddSlider("Mutations", 3, 1, 50, 0) d.go = dialog.AddButton("Go", 1) d.cancel = dialog.AddButton("Cancel", 0) if (dialog.Show(d) > 0) then mutate(d.mutations.value) end

Comments