IGV.py - Simple wrapper to the IGV socket interface

Author:Brent Pedersen
Release:$Id$
Date:December 09, 2013
Tags:Python

This code was written by Brent Pedersen.

Downloaded from https://github.com/brentp/bio-playground/blob/master/igv/igv.py on Nov.30 2011.

class IGV.IGV(host='127.0.0.1', port=60151, snapshot_dir='/tmp/igv')

Bases: object

Simple wrapper to the IGV (http://www.broadinstitute.org/software/igv/home) socket interface (http://www.broadinstitute.org/software/igv/PortCommands)

requires:

  1. you have IGV running on your machine (launch with webstart here:

    http://www.broadinstitute.org/software/igv/download)

  2. you have enabled port communication in

    View -> Preferences... -> Advanced

Successful commands return ‘OK’

example usage:

>>> igv = IGV()
>>> igv.genome('hg19')
'OK'

#>>> igv.load(‘http://www.broadinstitute.org/igvdata/1KG/pilot2Bams/NA12878.SLX.bam‘) ‘OK’ >>> igv.go(‘chr1:45,600-45,800’) ‘OK’

#save as svg, png, or jpg
>>> igv.save('/tmp/r/region.svg')
'OK'
>>> igv.save('/tmp/r/region.png')
'OK'
# go to a gene name.
>>> igv.go('muc5b')
'OK'
>>> igv.sort()
'OK'
>>> igv.save('muc5b.png')
'OK'
# get a list of commands that will work as an IGV batch script.
>>> print "\n".join(igv.commands)
snapshotDirectory /tmp/igv
genome hg19
goto chr1:45,600-45,800
snapshotDirectory /tmp/r
snapshot region.svg
snapshot region.png
goto muc5b
sort base
snapshot muc5b.png

Note, there will be some delay as the browser has to load the annotations at each step.

sort(option='base')

options is one of: base, position, strand, quality, sample, and readGroup.

Previous topic

Glam2Scan.py - Parser for MAST files

Next topic

<no title>

This Page