// Contributors:
// ElNando888
// calebgeniesse
// LFP6
// -------------------------------------------------------------
// Things that should probably go in the Library class (imo)
// -------------------------------------------------------------
var sid = "6713763";
var dbgwin, dbgdoc;
var dbg = false;
if (dbg) {
dbgwin = window.open("","EternaScript_"+sid,"width=400,height=800,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");
if (dbgwin !== null) {
dbgdoc = dbgwin.document;
dbgdoc.title = "EternaScript ID:"+sid+" output";
} else {
dbg = false;
}
}
var dbg_out = function(txt, elemtype) {
if (!dbg) return;
var elem = dbgdoc.createElement(elemtype);
var x = dbgdoc.createTextNode(txt);
elem.appendChild(x);
dbgdoc.body.appendChild(elem);
};
// -------------------------------------------------------------
String.prototype.repeat = function (num) {
var a = [];
a.length = (num << 0) + 1;
return a.join(this);
};
var seed = 3;
var seededRandom = function(min, max) {
max = max || 1;
min = min || 0;
seed = (seed * 9301 + 49297) % 233280;
var rnd = seed / 233280;
return min + rnd * (max - min);
}
function random_base() {
return Lib.bases[Math.floor(seededRandom(0,4))];
}
function mutate(sequence) {
var rindex = index_array[Math.floor(seededRandom(0,index_array.length))];
var seq_array = sequence.split("");
seq_array[rindex] = random_base();
dbg_out( "at "+(rindex+1)+" mutate to "+seq_array[rindex], "div");
return seq_array.join("");
}
function bp_distance(secstruct1, secstruct2, constraints) {
if (typeof constraints === "undefined") {
constraints = Array.apply(null, new Array(secstruct1.length)).map(Number.prototype.valueOf,1);
}