External control of IGV

This section describes how a running IGV application can be controlled through a sequence of commands.

Batch scripts#

A user running the IGV application can load a text file to execute a series of commands by selecting Run Batch Script from the Tools menu. See Batch scripts in the Tools Menu for further details.

Port commands#

IGV can optionally listen for commands over a port. By default the port number is 60151. The port number can be changed and the port listening can be disabled in the Advanced tab of the View > Preferences window.

The port commands are the same as the batch script commands. See Batch scripts in the Tools Menu for a full list.

The IGV application must already be running. There is no command to launch IGV.

IGV will write a response back to the port socket upon completion of each command. It is good practice to read this response before sending the next command. Failure to do so can overflow the socket buffer and cause IGV to freeze. See the example below for the recommended pattern.

Example#

An example of a Java code snippet that sends IGV commands to the listener port:

Socket socket = new Socket("127.0.0.1", 60151);  
PrintWriter out = new PrintWriter(socket.getOutputStream(), true);  
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));

out.println("load na12788.bam,n12788.tdf");  
String response = in.readLine();  
System.out.println(response);

out.println("genome hg18");  
response = in.readLine();  
System.out.println(response);

out.println("goto chr1:65,827,301");   
response = in.readLine();  
System.out.println(response);

out.println("snapshotDirectory/screenshots");  
response = in.readLine();  
System.out.println(response);

out.println("snapshot");  
response = in.readLine();  
System.out.println(response);

HTML links#

Data and session files can be loaded into IGV from a web browser or other application supporting hyperlinks. This makes use of the listener port. By default the port number is 60151. The port number can be changed and the port listening can be disabled in the Advanced tab of the View > Preferences window.

Links can be created to set the reference genome, load data, or jump to a specified locus as follows.

http://localhost:PORT/load?file=URL&locus=LOCUS&genome=GENOME&merge=[true|false]&name=NAME

http://localhost:PORT/goto?locus=LOCUS

The IGV application must already be running. The links will not launch IGV.

Examples#

http://localhost:60151/load?file=http://www.broadinstitute.org/igvdata/annotations/hg18/conservation/pi.12mer.wig.tdf&locus=egfr&genome=hg18

http://localhost:60151/load?file=http://www.broadinstitute.org/igvdata/exampleFiles/gbm_session.xml&merge=true

http://localhost:60151/goto?locus=egfr