Script Documentation: Difference between revisions
From Eterna Wiki
(Blanked the page) |
(Added pointers to samples of passing parameters when using Lib.EternaScript) |
||
(9 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
<p> </p> | |||
<p>__TOC__</p> | |||
<p> </p> | |||
<div style="clear: both; float: left; overflow: hidden;"> | |||
<div style="right: 50%; float: left; position: relative;"> | |||
<div style="width: 46%; left: 52%; float: left; position: relative; padding: 0 0 1em 0; overflow: hidden;"> | |||
<p class="script-section-title">== Pervasives ==</p> | |||
<p class="script-functions"> </p> | |||
<p class="script-title">=== out(text) ===</p> | |||
<p class="script-description">display text in result textarea</p> | |||
<p> </p> | |||
<p class="script-title">=== outln(text) ===</p> | |||
<p class="script-description">display text in result textarea with newline</p> | |||
<p> </p> | |||
<p class="script-functions">=== clear() ===</p> | |||
<p class="script-description">clear result textarea</p> | |||
<p> </p> | |||
<p>== Library functions ==</p> | |||
<p class="script-functions">=== Lib.bases ===</p> | |||
<p class="script-description">"AGCU"</p> | |||
<p> </p> | |||
<p class="script-functions">=== Lib.fold(sequence) ===</p> | |||
<p class="script-description">return folded structure with sequence</p> | |||
<p>ex) Lib.fold("GGGGCCCC") = "((....))";</p> | |||
<p> </p> | |||
<p>=== Lib.energyOfStruct(sequence, structure) ===</p> | |||
<p class="script-description">return energy of structure</p> | |||
<p> </p> | |||
<p>=== Lib.EternaScript(script id) ===</p> | |||
<p class="script-description">return other user's script</p> | |||
<p>ex) var func = Lib.EternaScript(script_id);</p> | |||
<p>ex) func(parameters);</p> | |||
<p><em>Passing parameters between scripts is a little tricky. </em></p> | |||
<p><em>See http://www.eternagame.org/web/script/8074717/ </em></p> | |||
<p><em>and http://www.eternagame.org/web/script/8074800/</em></p> | |||
<p><em>for an example.</em></p> | |||
<p> </p> | |||
<p>=== Lib.getStructure(puzzle id) ===</p> | |||
<p class="script-description">return structure of puzzle</p> | |||
<p>ex) Lib.getStructure(1001759)</p> | |||
<p> </p> | |||
<p>=== Lib.replace(sequence, index, target) ===</p> | |||
<p class="script-description">return sequence which character at index in sequence replaced to target</p> | |||
<p>ex) Lib.replace("AGCU", 2, "A") = "AGAU";</p> | |||
<p> </p> | |||
<p>=== Lib.nextSequence(sequence) ===</p> | |||
<p class="script-description">return next sequence of sequence in the order of default bases</p> | |||
<p>ex) Lib.nextSequence("AAAA") = "GAAA";</p> | |||
<p> </p> | |||
<p>=== Lib.nextSequenceWithBases(sequence, bases) ===</p> | |||
<p class="script-description">return next sequence of sequence in the order of bases</p> | |||
<p>ex) Lib.nextSequenceWithBases("UUUU", "UCGA") = "CUUU";</p> | |||
<p>ex) Lib.nextSequenceWithBases("AUAA", "UCGA") = "UCAA";</p> | |||
<p> </p> | |||
<p>=== Lib.random(from, to) ===</p> | |||
<p class="script-description">return random number between from and to</p> | |||
<p> </p> | |||
<p class="script-functions">=== Lib.randomSequence(size) ===</p> | |||
<p class="script-description">return random sequence with length of size</p> | |||
<p> </p> | |||
<p>=== Lib.map(function, sequence) ===</p> | |||
<p class="script-description">applies function to each sequence bases</p> | |||
<p> </p> | |||
<p class="script-functions">=== Lib.filter(function, sequence) ===</p> | |||
<p class="script-description">return sequences only satisfy the function</p> | |||
<p> </p> | |||
<p class="script-functions">=== Lib.splitDefault(structure) ===</p> | |||
<p class="script-description">split structure into a structure array</p> | |||
<p>ex) Lib.splitDefault("((..))") = ["((", "..", "))"];</p> | |||
<p> </p> | |||
<p>=== Lib.join(array) ===</p> | |||
<p class="script-description">join array with each element to sequence</p> | |||
<p>ex) Lib.join(Lib.split("((..))")) = "((..))";</p> | |||
<p> </p> | |||
<p>=== Lib.distance(source structure, destination structure) ===</p> | |||
<p class="script-description">return differences between source structure and destination structure</p> | |||
<p>if same then 0 else +1</p> | |||
<p>if different length then just return -1</p> | |||
<p>ex) Lib.distance("((..))", "((()))") = 2</p> | |||
<p>ex) Lib.distance("(((())))", "(())") = -1</p> | |||
<p> </p> | |||
<p>=== Lib.distanceCustom(function, source structure, destination structure) ===</p> | |||
<p class="script-description">return differences between source structure and destination structure with custom rule</p> | |||
<p>ex) Lib.distanceCustom(function(index){ ... }, source, dest);</p> | |||
<p> </p> | |||
</div> | |||
<div style="width: 46%; left: 56%; float: left; position: relative; padding: 0 0 1em 0; overflow: hidden;"> | |||
<p>== Class RNA ==</p> | |||
<p><a href="http://kws.eternadev.org/web/script/">example code</a></p> | |||
<p class="script-functions"> </p> | |||
<p class="script-title">=== getPairmap(structure) ===</p> | |||
<p class="script-description">return the array of pair information</p> | |||
<p>ex) getPairmap("((...))") = [6,5,,,,1,0]</p> | |||
<p> </p> | |||
<p>=== getStructure() ===</p> | |||
<p class="script-description">return structure</p> | |||
<p> </p> | |||
<p>=== getRootElement() ===</p> | |||
<p class="script-description">return root RNAElement class of rna object</p> | |||
<p> </p> | |||
<p>=== map() ===</p> | |||
<p class="script-description">applies function to all RNAElement</p> | |||
<p> </p> | |||
<p>== Class RNAElement ==</p> | |||
<p class="script-functions"> </p> | |||
<p class="script-title">=== getParent() ===</p> | |||
<p class="script-description">return the parent RNAElement class</p> | |||
<p> </p> | |||
<p>=== getChilds() ===</p> | |||
<p class="script-description">return the child RNAElement class array</p> | |||
<p> </p> | |||
<p>=== getElements() ===</p> | |||
<p class="script-description">return the array of structure and index JSON objects</p> | |||
<p> </p> | |||
<p>=== isPaired() ===</p> | |||
<p class="script-description">return boolean whether the stack element is paired or not</p> | |||
<p> </p> | |||
<p>=== getBaseType() ===</p> | |||
<p class="script-description">return RNAElement.Stack or RNAElement.Loop if the element is stack or loop</p> | |||
<p> </p> | |||
<p>=== getType() ===</p> | |||
<p class="script-description">return RNAElement.Hairpin, RNAElement.Bulge, RNAElement.Internal, RNAElement.Multiloop or RNAElement.Dangling if the element is hairpin, bulge, internal, multiloop or dangling</p> | |||
<p> </p> | |||
<p>=== getIndices() ===</p> | |||
<p class="script-description">return the array of indices</p> | |||
<p> </p> | |||
<p>=== isStack() / isLoop() / isHairpin() / isBulge() /<br /> isInternal() / isMultiloop() / isDangling() ===</p> | |||
<p class="script-description">return boolean wheter the element is stack, loop, hairpin, bulge, internal, multiloop or dangling</p> | |||
<p> </p> | |||
<p>=== getSegmentCount() ===</p> | |||
<p class="script-description">return how many structure segments included</p> | |||
<p>if the multiloop consists of 2 branches then getSegmentCount() of multiloop returns 2</p> | |||
</div> | |||
</div> | |||
</div> | |||
<div style="clear: both; float: left; overflow: hidden;"> | |||
<p> </p> | |||
<p>Documentation for functions and APIs at the devel stage can be found on [[Script Documentation (devel)]]</p> | |||
</div> | |||
<div style="clear: both; float: left; overflow: hidden;"> | |||
<p>==See Also==</p> | |||
<ul> | |||
<li>[[API for Server Data Queries]]</li> | |||
<li>There is a beginners guide to the script interface [https://docs.google.com/document/d/1VC94wTuRhNd-FN60ueaBc5mUxBsiIy8UzJzQL6ap3CE/edit?pli=1 here] on google docs.</li> | |||
<li>Scripting lectures in [http://eternawiki.org/wiki/index.php5/EteRNA_University EteRNA University]</li> | |||
<li><a href="https://docs.google.com/document/d/1AVs401fSZVD8FNNgkMQbFcxm_5O6RqpbSAk9o19f6Z8/edit#heading=h.8bg64ampbuz5">HTML Magic - Learn tricks for sharing material</a> by [[User:Machinelves|Machinelves]] and [[User:Eli Fisker|Eli Fisker]]</li> | |||
</ul> | |||
<p> </p> | |||
</div> |
Revision as of 22:19, 28 August 2017