Difference between revisions of "Communicating with GenomeView"

From GenomeView Manual
Jump to navigation Jump to search
(Created page with "http://genomeview.org/content/communicating-genomeview")
 
Line 1: Line 1:
http://genomeview.org/content/communicating-genomeview
+
<i>Other topics that may be of interest: <a href="/content/integration">Integrating GenomeView as viewer</a></i>
 +
 
 +
 
 +
Whatever way of communicating you choose, make sure you enable it in the configuration file!
 +
 
 +
It is <b>important</b> that you set <code>integration:monitorJavaScript=true</code> in your configuration file. Only if you add that line to the configuration file you specify, will communication work.
 +
 
 +
<h2>Controlling GenomeView applet using JavaScript</h2>
 +
We have a <a href="http://genomeview.org/jsdemo">demo page set up</a> that showcases the various aspects you may want to use when embedding GenomeView as an applet into your web platform.
 +
 
 +
<p>Supported instruction set, see the <a href="http://genomeview.org/jsdemo"> demo page</a> for examples on how to use them.
 +
<table>
 +
<th>Instruction</th><th>Description</th>
 +
<tr><td>launchGV(url)</td><td>Launch GenomeView with the file at the specified url as configuration file. If no url is specified an empty config is loaded with <code>integration:monitorJavaScript=true</code>. See <a href="http://genomeview.org/jsdemo/testlaunch.html">example</a> for more details.</td></tr>
 +
<tr><td>loadGV(url)</td><td>Load the data at the specified url</td></tr>
 +
<tr><td>unloadGV()</td><td>Unload all data that is currently loaded</td></tr>
 +
<tr><td>sessionGV(url)</td><td>Load the GenomeView session at the specified URL</td></tr>
 +
<tr><td>positionGV(position)</td><td>Move the visible region to the specified location. The position is in the format <code>[entry]:[start position]:[end position]</code> The entry part is optional can be omitted in which case it becomes <code>[start position]:[end position]</code> </td></tr>
 +
<tr><td>isAlive(callback)</td><td>Check whether a GenomeView instance is alive. <code>callback</code> should be a javascript function that you define that will be called by the script and will have a variable <code>isAlive</code> available that you can use. See the <a href="http://genomeview.org/jsdemo/testalive.html">example </a> for more details</td></tr>
 +
<tr><td>setInstanceID(id)</td><td>Set the GenomeView instance ID to be used in the next functions calls to the supplied argument. This is useful to communicate with multiple GenomeView instances at once. See the <a href="http://genomeview.org/jsdemo/testlaunch.html">example</a> for more details.</td></tr>
 +
<tr><td>setInstructAllInstancesGV</td><td>Any commands after this function call will be send to all GenomeView instances</td></tr>
 +
 
 +
</table>
 +
 
 +
<p>Deprecated legacy instructions.</p>
 +
<table>
 +
<th>Instruction</th><th>Description</th>
 +
<tr><td>startGV(gv_url,gv_loc, gv_config,gv_extra,a_width,a_height )</td><td>Start regular applet with the parameters described above</td></tr>
 +
<tr><td>startMiniGV(gv_url,gv_loc, gv_config,gv_extra,a_width,a_height )</td><td>Start minimal applet with the parameters as described above. The minimal applet has no side bar and no menu</td></tr>
 +
 
 +
</table>
 +
 
 +
<h2>Controlling GenomeView webstart using JavaScript</h2>
 +
Include the GenomeView javascript file
 +
<code><script type="text/javascript" src="http://genomeview.org/start/genomeview.js"></script></code>
 +
In java script, set <code>instanceID='ALL'</code>
 +
 
 +
Assuming there is a GenomeView webstart instance started, You can now use the java script methods described above to manipulate it.
 +
 
 +
<h2>Controlling GenomeView using a port</h2>
 +
The java script is implemented as a local server that listens on port 2223, so you could alternatively directly control GenomeView by sending instructions to that port.
 +
 
 +
The format of an instruction is <code>GET /genomeview-ALL/[instruction]/[argument]</code>
 +
 
 +
Some examples:
 +
Load the C. elegans demo instance
 +
<code>GET /genomeview-ALL/session/http://www.broadinstitute.org/software/genomeview/demo/c_elegans/session.php</code>
 +
 
 +
Position the current visible window to 10000-20000
 +
<code>GET /genomeview-ALL/position/10000:20000</code>
 +
 
 +
Unload all data:
 +
<code>GET /genomeview-ALL/unload</code>
 +
 
 +
Full working example code in Java
 +
<code>
 +
Socket gv = new Socket("localhost", 2223);
 +
PrintWriter pw=new PrintWriter(gv.getOutputStream());
 +
              /*pw.println("GET /genomeview-ALL/session/http://www.broadinstitute.org/software/genomeview/demo/c_elegans/session.php");*/
 +
                //pw.println("GET /genomeview-ALL/unload");
 +
pw.println("GET /genomeview-ALL/position/10000:20000");
 +
pw.flush();
 +
gv.close();
 +
</code>
 +
 
 +
<strong>Available instructions:</strong>
 +
 
 +
<table>
 +
<th>Instruction</th><th>Description</th>
 +
<tr><td>GET /genomeview-ALL/load/[URL]</td><td>Load the data at the specified url</td></tr>
 +
<tr><td>GET /genomeview-ALL/unload (no argument)</td><td>Unload all data that is currently loaded</td></tr>
 +
<tr><td>GET /genomeview-ALL/session/[URL]</td><td>Load the GenomeView session at the specified URL</td></tr>
 +
<tr><td>GET /genomeview-ALL/position/[position]</td><td>Move the visible region to the specified location. The position is in the format <code>[entry]:[start position]:[end position]</code> The entry part is optional can be omitted in which case it becomes <code>[start position]:[end position]</code> </td></tr>
 +
</table>

Revision as of 23:43, 15 November 2013

Other topics that may be of interest: <a href="/content/integration">Integrating GenomeView as viewer</a>


Whatever way of communicating you choose, make sure you enable it in the configuration file!

It is important that you set integration:monitorJavaScript=true in your configuration file. Only if you add that line to the configuration file you specify, will communication work.

Controlling GenomeView applet using JavaScript

We have a <a href="http://genomeview.org/jsdemo">demo page set up</a> that showcases the various aspects you may want to use when embedding GenomeView as an applet into your web platform.

Supported instruction set, see the <a href="http://genomeview.org/jsdemo"> demo page</a> for examples on how to use them.

InstructionDescription
launchGV(url)Launch GenomeView with the file at the specified url as configuration file. If no url is specified an empty config is loaded with integration:monitorJavaScript=true. See <a href="http://genomeview.org/jsdemo/testlaunch.html">example</a> for more details.
loadGV(url)Load the data at the specified url
unloadGV()Unload all data that is currently loaded
sessionGV(url)Load the GenomeView session at the specified URL
positionGV(position)Move the visible region to the specified location. The position is in the format [entry]:[start position]:[end position] The entry part is optional can be omitted in which case it becomes [start position]:[end position]
isAlive(callback)Check whether a GenomeView instance is alive. callback should be a javascript function that you define that will be called by the script and will have a variable isAlive available that you can use. See the <a href="http://genomeview.org/jsdemo/testalive.html">example </a> for more details
setInstanceID(id)Set the GenomeView instance ID to be used in the next functions calls to the supplied argument. This is useful to communicate with multiple GenomeView instances at once. See the <a href="http://genomeview.org/jsdemo/testlaunch.html">example</a> for more details.
setInstructAllInstancesGVAny commands after this function call will be send to all GenomeView instances

Deprecated legacy instructions.

InstructionDescription
startGV(gv_url,gv_loc, gv_config,gv_extra,a_width,a_height )Start regular applet with the parameters described above
startMiniGV(gv_url,gv_loc, gv_config,gv_extra,a_width,a_height )Start minimal applet with the parameters as described above. The minimal applet has no side bar and no menu

Controlling GenomeView webstart using JavaScript

Include the GenomeView javascript file <script type="text/javascript" src="http://genomeview.org/start/genomeview.js"></script> In java script, set instanceID='ALL'

Assuming there is a GenomeView webstart instance started, You can now use the java script methods described above to manipulate it.

Controlling GenomeView using a port

The java script is implemented as a local server that listens on port 2223, so you could alternatively directly control GenomeView by sending instructions to that port.

The format of an instruction is GET /genomeview-ALL/[instruction]/[argument]

Some examples: Load the C. elegans demo instance GET /genomeview-ALL/session/http://www.broadinstitute.org/software/genomeview/demo/c_elegans/session.php

Position the current visible window to 10000-20000 GET /genomeview-ALL/position/10000:20000

Unload all data: GET /genomeview-ALL/unload

Full working example code in Java Socket gv = new Socket("localhost", 2223); PrintWriter pw=new PrintWriter(gv.getOutputStream());

              /*pw.println("GET /genomeview-ALL/session/http://www.broadinstitute.org/software/genomeview/demo/c_elegans/session.php");*/
               //pw.println("GET /genomeview-ALL/unload");

pw.println("GET /genomeview-ALL/position/10000:20000"); pw.flush(); gv.close();

Available instructions:

InstructionDescription
GET /genomeview-ALL/load/[URL]Load the data at the specified url
GET /genomeview-ALL/unload (no argument)Unload all data that is currently loaded
GET /genomeview-ALL/session/[URL]Load the GenomeView session at the specified URL
GET /genomeview-ALL/position/[position]Move the visible region to the specified location. The position is in the format [entry]:[start position]:[end position] The entry part is optional can be omitted in which case it becomes [start position]:[end position]