Communicating with GenomeView

Other topics that may be of interest: Integrating GenomeView as viewer

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 demo page set up 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 demo page for examples on how to use them.

Instruction Description
loadGV(url) Load the data at the specified url
unloadGV() Unload all data that is currently loaded
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
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]

Controlling GenomeView webstart using JavaScript

Include the GenomeView javascript file

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:

Instruction Description
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]