Script Documentation: Difference between revisions
From Eterna Wiki
(Corrected getPairmap example) |
(Update formatting) |
||
(4 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
<div style="right: 50%; float: left; position: relative;"> | <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;"> | <div style="width: 46%; left: 52%; float: left; position: relative; padding: 0 0 1em 0; overflow: hidden;"> | ||
== Pervasives== | |||
<p class="script-functions"> </p> | <p class="script-functions"> </p> | ||
===out(text)=== | |||
<p class="script-description">display text in result textarea</p> | <p class="script-description">display text in result textarea</p> | ||
<p> </p> | <p> </p> | ||
===outln(text)=== | |||
<p class="script-description">display text in result textarea with newline</p> | <p class="script-description">display text in result textarea with newline</p> | ||
<p> </p> | <p> </p> | ||
===clear()=== | |||
<p class="script-description">clear result textarea</p> | <p class="script-description">clear result textarea</p> | ||
<p> </p> | <p> </p> | ||
==Library functions== | |||
===Lib.bases === | |||
<p class="script-description">"AGCU"</p> | <p class="script-description">"AGCU"</p> | ||
<p> </p> | <p> </p> | ||
===Lib.fold(sequence)=== | |||
<p class="script-description">return folded structure with sequence</p> | <p class="script-description">return folded structure with sequence</p> | ||
<p>ex) Lib.fold("GGGGCCCC") = "((....))";</p> | <p>ex) Lib.fold("GGGGCCCC") = "((....))";</p> | ||
<p> </p> | <p> </p> | ||
===Lib.energyOfStruct(sequence, structure)=== | |||
<p class="script-description">return energy of structure</p> | <p class="script-description">return energy of structure</p> | ||
<p> </p> | <p> </p> | ||
===Lib.EternaScript(script id)=== | |||
<p class="script-description">return other user's script</p> | <p class="script-description">return other user's script</p> | ||
<p>ex) var func = Lib.EternaScript(script_id);</p> | <p>ex) var func = Lib.EternaScript(script_id);</p> | ||
<p>ex) func(parameters);</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> </p> | ||
=== Lib.getStructure(puzzle id)=== | |||
<p class="script-description">return structure of puzzle</p> | <p class="script-description">return structure of puzzle</p> | ||
<p>ex) Lib.getStructure(1001759)</p> | <p>ex) Lib.getStructure(1001759)</p> | ||
<p> </p> | <p> </p> | ||
===Lib.replace(sequence, index, target)=== | |||
<p class="script-description">return sequence which character at index in sequence replaced to 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>ex) Lib.replace("AGCU", 2, "A") = "AGAU";</p> | ||
<p> </p> | <p> </p> | ||
===Lib.nextSequence(sequence) === | |||
<p class="script-description">return next sequence of sequence in the order of default bases</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>ex) Lib.nextSequence("AAAA") = "GAAA";</p> | ||
<p> </p> | <p> </p> | ||
===Lib.nextSequenceWithBases(sequence, bases)=== | |||
<p class="script-description">return next sequence of sequence in the order of 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("UUUU", "UCGA") = "CUUU";</p> | ||
<p>ex) Lib.nextSequenceWithBases("AUAA", "UCGA") = "UCAA";</p> | <p>ex) Lib.nextSequenceWithBases("AUAA", "UCGA") = "UCAA";</p> | ||
<p> </p> | <p> </p> | ||
===Lib.random(from, to)=== | |||
<p class="script-description">return random number between from and to</p> | <p class="script-description">return random number between from and to</p> | ||
<p> </p> | <p> </p> | ||
===Lib.randomSequence(size)=== | |||
<p class="script-description">return random sequence with length of size</p> | <p class="script-description">return random sequence with length of size</p> | ||
<p> </p> | <p> </p> | ||
===Lib.map(function, sequence)=== | |||
<p class="script-description">applies function to each sequence bases</p> | <p class="script-description">applies function to each sequence bases</p> | ||
<p> </p> | <p> </p> | ||
===Lib.filter(function, sequence)=== | |||
<p class="script-description">return sequences only satisfy the function</p> | <p class="script-description">return sequences only satisfy the function</p> | ||
<p> </p> | <p> </p> | ||
===Lib.splitDefault(structure)=== | |||
<p class="script-description">split structure into a structure array</p> | <p class="script-description">split structure into a structure array</p> | ||
<p>ex) Lib.splitDefault("((..))") = ["((", "..", "))"];</p> | <p>ex) Lib.splitDefault("((..))") = ["((", "..", "))"];</p> | ||
<p> </p> | <p> </p> | ||
===Lib.join(array)=== | |||
<p class="script-description">join array with each element to sequence</p> | <p class="script-description">join array with each element to sequence</p> | ||
<p>ex) Lib.join(Lib.split("((..))")) = "((..))";</p> | <p>ex) Lib.join(Lib.split("((..))")) = "((..))";</p> | ||
<p> </p> | <p> </p> | ||
===Lib.distance(source structure, destination structure)=== | |||
<p class="script-description">return differences between source structure and 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 same then 0 else +1</p> | ||
Line 76: | Line 80: | ||
<p>ex) Lib.distance("(((())))", "(())") = -1</p> | <p>ex) Lib.distance("(((())))", "(())") = -1</p> | ||
<p> </p> | <p> </p> | ||
===Lib.distanceCustom(function, source structure, destination structure)=== | |||
<p class="script-description">return differences between source structure and destination structure with custom rule</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>ex) Lib.distanceCustom(function(index){ ... }, source, dest);</p> | ||
Line 82: | Line 86: | ||
</div> | </div> | ||
<div style="width: 46%; left: 56%; float: left; position: relative; padding: 0 0 1em 0; overflow: hidden;"> | <div style="width: 46%; left: 56%; float: left; position: relative; padding: 0 0 1em 0; overflow: hidden;"> | ||
==Class RNA== | |||
<p> | <p>[http://kws.eternadev.org/web/script/ example code]</p> | ||
<p class="script-functions"> </p> | <p class="script-functions"> </p> | ||
===getPairmap(structure)=== | |||
<p class="script-description">return the array of pair information</p> | <p class="script-description">return the array of pair information</p> | ||
<p>ex) getPairmap("((...))") = [6,5,,,,1,0]</p> | <p>ex) getPairmap("((...))") = [6,5,,,,1,0]</p> | ||
<p> </p> | <p> </p> | ||
===getStructure() === | |||
<p class="script-description">return structure</p> | <p class="script-description">return structure</p> | ||
<p> </p> | <p> </p> | ||
===getRootElement()=== | |||
<p class="script-description">return root RNAElement class of rna object</p> | <p class="script-description">return root RNAElement class of rna object</p> | ||
<p> </p> | <p> </p> | ||
===map()=== | |||
<p class="script-description">applies function to all RNAElement</p> | <p class="script-description">applies function to all RNAElement</p> | ||
<p> </p> | <p> </p> | ||
==Class RNAElement== | |||
<p class="script-functions"> </p> | <p class="script-functions"> </p> | ||
===getParent()=== | |||
<p class="script-description">return the parent RNAElement class</p> | <p class="script-description">return the parent RNAElement class</p> | ||
<p> </p> | <p> </p> | ||
=== getChilds()=== | |||
<p class="script-description">return the child RNAElement class array</p> | <p class="script-description">return the child RNAElement class array</p> | ||
<p> </p> | <p> </p> | ||
===getElements() === | |||
<p class="script-description">return the array of structure and index JSON objects</p> | <p class="script-description">return the array of structure and index JSON objects</p> | ||
<p> </p> | <p> </p> | ||
===isPaired()=== | |||
<p class="script-description">return boolean whether the stack element is paired or not</p> | <p class="script-description">return boolean whether the stack element is paired or not</p> | ||
<p> </p> | <p> </p> | ||
===getBaseType()=== | |||
<p class="script-description">return RNAElement.Stack or RNAElement.Loop if the element is stack or loop</p> | <p class="script-description">return RNAElement.Stack or RNAElement.Loop if the element is stack or loop</p> | ||
<p> </p> | <p> </p> | ||
===getType()=== | |||
<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 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> </p> | ||
===getIndices()=== | |||
<p class="script-description">return the array of indices</p> | <p class="script-description">return the array of indices</p> | ||
<p> </p> | <p> </p> | ||
===isStack() / isLoop() / isHairpin() / isBulge() / isInternal() / isMultiloop() / isDangling()=== | |||
<p class="script-description">return boolean wheter the element is stack, loop, hairpin, bulge, internal, multiloop or dangling</p> | <p class="script-description">return boolean wheter the element is stack, loop, hairpin, bulge, internal, multiloop or dangling</p> | ||
<p> </p> | <p> </p> | ||
===getSegmentCount()=== | |||
<p class="script-description">return how many structure segments included</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> | <p>if the multiloop consists of 2 branches then getSegmentCount() of multiloop returns 2</p> | ||
Line 135: | Line 139: | ||
</div> | </div> | ||
<div style="clear: both; float: left; overflow: hidden;"> | <div style="clear: both; float: left; overflow: hidden;"> | ||
==See Also== | |||
<ul> | <ul> | ||
<li>[[API for Server Data Queries]]</li> | <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>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>[https://docs.google.com/document/d/1AVs401fSZVD8FNNgkMQbFcxm_5O6RqpbSAk9o19f6Z8/edit#heading=h.8bg64ampbuz5 HTML Magic - Learn tricks for sharing material] by [[User:Machinelves|Machinelves]] and [[User:Eli Fisker|Eli Fisker]]</li> | |||
</ul> | </ul> | ||
<p> | <p>[[Category:Computational Tools]]</p> | ||
</div> | </div> |
Latest revision as of 18:59, 18 June 2022