Script Documentation
Contents
- 1 Pervasives
- 2 Library functions
- 2.1 Lib.bases
- 2.2 Lib.fold(sequence)
- 2.3 Lib.energyOfStruct(sequence, structure)
- 2.4 Lib.EternaScript(script id)
- 2.5 Lib.getStructure(puzzle id)
- 2.6 Lib.replace(sequence, index, target)
- 2.7 Lib.nextSequence(sequence)
- 2.8 Lib.nextSequenceWithBases(sequence, bases)
- 2.9 Lib.random(from, to)
- 2.10 Lib.randomSequence(size)
- 2.11 Lib.map(function, sequence)
- 2.12 Lib.filter(function, sequence)
- 2.13 Lib.splitDefault(structure)
- 2.14 Lib.join(array)
- 2.15 Lib.distance(source structure, destination structure)
- 2.16 Lib.distanceCustom(function, source structure, destination structure)
- 3 Class RNA
- 4 Class RNAElement
- 5 See Also
Pervasives
out(text)
display text in result textarea
outln(text)
display text in result textarea with newline
clear()
clear result textarea
Library functions
Lib.bases
"AGCU"
Lib.fold(sequence)
return folded structure with sequence
ex) Lib.fold("GGGGCCCC") = "((....))";
Lib.energyOfStruct(sequence, structure)
return energy of structure
Lib.EternaScript(script id)
return other user's script
ex) var func = Lib.EternaScript(script_id);
ex) func(parameters);
Passing parameters between scripts is a little tricky.
See http://www.eternagame.org/web/script/8074717/
and http://www.eternagame.org/web/script/8074800/
for an example.
Lib.getStructure(puzzle id)
return structure of puzzle
ex) Lib.getStructure(1001759)
Lib.replace(sequence, index, target)
return sequence which character at index in sequence replaced to target
ex) Lib.replace("AGCU", 2, "A") = "AGAU";
Lib.nextSequence(sequence)
return next sequence of sequence in the order of default bases
ex) Lib.nextSequence("AAAA") = "GAAA";
Lib.nextSequenceWithBases(sequence, bases)
return next sequence of sequence in the order of bases
ex) Lib.nextSequenceWithBases("UUUU", "UCGA") = "CUUU";
ex) Lib.nextSequenceWithBases("AUAA", "UCGA") = "UCAA";
Lib.random(from, to)
return random number between from and to
Lib.randomSequence(size)
return random sequence with length of size
Lib.map(function, sequence)
applies function to each sequence bases
Lib.filter(function, sequence)
return sequences only satisfy the function
Lib.splitDefault(structure)
split structure into a structure array
ex) Lib.splitDefault("((..))") = ["((", "..", "))"];
Lib.join(array)
join array with each element to sequence
ex) Lib.join(Lib.split("((..))")) = "((..))";
Lib.distance(source structure, destination structure)
return differences between source structure and destination structure
if same then 0 else +1
if different length then just return -1
ex) Lib.distance("((..))", "((()))") = 2
ex) Lib.distance("(((())))", "(())") = -1
Lib.distanceCustom(function, source structure, destination structure)
return differences between source structure and destination structure with custom rule
ex) Lib.distanceCustom(function(index){ ... }, source, dest);
Class RNA
getPairmap(structure)
return the array of pair information
ex) getPairmap("((...))") = [6,5,,,,1,0]
getStructure()
return structure
getRootElement()
return root RNAElement class of rna object
map()
applies function to all RNAElement
Class RNAElement
getParent()
return the parent RNAElement class
getChilds()
return the child RNAElement class array
getElements()
return the array of structure and index JSON objects
isPaired()
return boolean whether the stack element is paired or not
getBaseType()
return RNAElement.Stack or RNAElement.Loop if the element is stack or loop
getType()
return RNAElement.Hairpin, RNAElement.Bulge, RNAElement.Internal, RNAElement.Multiloop or RNAElement.Dangling if the element is hairpin, bulge, internal, multiloop or dangling
getIndices()
return the array of indices
isStack() / isLoop() / isHairpin() / isBulge() / isInternal() / isMultiloop() / isDangling()
return boolean wheter the element is stack, loop, hairpin, bulge, internal, multiloop or dangling
getSegmentCount()
return how many structure segments included
if the multiloop consists of 2 branches then getSegmentCount() of multiloop returns 2
Documentation for functions and APIs at the devel stage can be found on Script Documentation (devel)
See Also
- API for Server Data Queries
- There is a beginners guide to the script interface here on google docs.
- Scripting lectures in EteRNA University
- HTML Magic - Learn tricks for sharing material by Machinelves and Eli Fisker