Difference between revisions of "Communicating with GenomeView"
Thomas Admin (talk | contribs) |
Thomas Admin (talk | contribs) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 5: | Line 5: | ||
<nowiki><script type="text/javascript" src="http://genomeview.org/start/genomeview.js"></script></nowiki> | <nowiki><script type="text/javascript" src="http://genomeview.org/start/genomeview.js"></script></nowiki> | ||
− | By default the instructions will only work with the GenomeView instance that was launched from the same page with launchGV() instruction. To override this behavior you can set the instanceID to 'ALL' | + | By default the instructions will only work with the GenomeView instance that was launched from the same page with launchGV() instruction. To override this behavior you can set the instanceID to 'ALL' or alternatively you can call 'setInstructAllInstancesGV()' |
<script>instanceID='ALL'</script> | <script>instanceID='ALL'</script> | ||
Line 14: | Line 14: | ||
|- | |- | ||
| launchGV(command line) | | launchGV(command line) | ||
− | | Launch GenomeView with | + | | Launch GenomeView with the specified command line options. |
|- | |- | ||
| loadGV(url) | | loadGV(url) | ||
Line 28: | Line 28: | ||
| 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> | | 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> | ||
|- | |- | ||
+ | | trackGV(trackname) | ||
+ | | Scroll vertically to make sure the named track is visible. | ||
+ | |- | ||
+ | | configGV(key=value) | ||
+ | | Set a single configuration option. | ||
+ | |- | ||
+ | |||
| isAlive(callback) | | isAlive(callback) | ||
− | | 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. | + | | 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. This could be used to check whether there is already a GenomeView instance launched and based on that information start an instance or load the data into the existing one. |
|- | |- | ||
| setInstanceID(id) | | setInstanceID(id) | ||
Line 37: | Line 44: | ||
| Any commands after this function call will be send to all GenomeView instances | | Any commands after this function call will be send to all GenomeView instances | ||
|} | |} | ||
− | |||
== Examples == | == Examples == |
Latest revision as of 22:58, 18 November 2013
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 using JavaScript (recommended)
Include the GenomeView javascript file into your HTML page
<script type="text/javascript" src="http://genomeview.org/start/genomeview.js"></script>
By default the instructions will only work with the GenomeView instance that was launched from the same page with launchGV() instruction. To override this behavior you can set the instanceID to 'ALL' or alternatively you can call 'setInstructAllInstancesGV()'
<script>instanceID='ALL'</script>
Instruction | Description |
---|---|
launchGV(command line) | Launch GenomeView with the specified command line options. |
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]
|
trackGV(trackname) | Scroll vertically to make sure the named track is visible. |
configGV(key=value) | Set a single configuration option. |
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. This could be used to check whether there is already a GenomeView instance launched and based on that information start an instance or load the data into the existing one.
|
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. |
setInstructAllInstancesGV | Any commands after this function call will be send to all GenomeView instances |
Examples
launchGV(command line)
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] |