IGV can optionally listen for http requests over a port. This option is turned off by default but can be enabled from the Advanced tab of the Preferences window.
Note: 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.
Commands
|
Command |
Description |
|
new |
Create a new session. Unloads all tracks except the default genome annotations. |
|
load file |
Loads data or session files. Specify a comma-delimited list of full paths or URLs. |
|
collapse trackName |
Collapses a given trackName. trackName is optional, however, and if it is not supplied all tracks are collapsed. |
|
echo |
Writes "echo" back to the response. (Primarily for testing) |
|
exit |
Exit (close) the IGV application. |
|
expand trackName |
Expands a given trackName. trackName is optional, however, and if it is not supplied all tracks are expanded. |
|
genome genomeId |
Selects a genome. |
|
goto locus or listOfLoci |
Scrolls to a single locus or a space-delimited list of loci. If a list is provided, these loci will be displayed in a split screen view. Use any syntax that is valid in the IGV search box. |
|
region chr start end |
Defines a region of interest bounded by the two loci (e.g., region chr1 100 200). |
|
snapshotDirectory path |
Sets the directory in which to write images. |
|
snapshot filename |
Saves a snapshot of the IGV window to an image file. If filename is omitted, writes a PNG or SVG file with a filename generated based on the locus. If filename is specified, the filename extension determines the image file format, which must be .png, or .svg. |
|
sort option locus
|
Sorts an alignment track by the specified option. Recognized values for the option parameter are: base, position, strand, quality, sample, readGroup, AMPLIFICATION, DELETION, EXPRESSION, SCORE, and MUTATION_COUNT. The locus option can define a single position, or a range. If absent sorting will be perfomed based on the region in view, or the center position of the region in view, depending on the option. |
Example
Example java code:
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");
//out.println("goto chr1:65,839,697");
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);