Skip to content

Customizing BLAT

helgathorv edited this page Jul 23, 2021 · 5 revisions

IGV supports on-the-fly alignment of short sequences by making use of a BLAT web service. For example, from the popup menu in a BAM track you can select to BLAT the read sequence of the selected alignment, or you can BLAT any short sequence by selecting Tools > BLAT in the menu bar.

By default, a public service hosted at UCSC is used, and BLAT support is limited to IGV reference genomes that are derived from UCSC's hosted set. This can be customized in IGV's advanced preferences to use another BLAT service, or a locally executable command line program that returns BLAT-like results.

To change the default BLAT service, open the advanced preferences in IGV by selecting View > Preferences > Advanced, and edit the "Blat url". The value is a string template with placeholders for the search sequence and genome ID: $SEQUENCE and $DB. These values are substituted at runtime. The default value is

https://genome.ucsc.edu/cgi-bin/hgBlat?userSeq=$SEQUENCE&type=DNA&db=$DB&output=json

Output from the web service or command line program should be JSON containing a "blat" property at the top level, followed by an array of PSL records representing the alignments. Each PSL record is represented as a JSON array. An example is given below. Details of the PSL format is available at UCSC. If configuring a local command line program, the output should be written to STDOUT.

{
    "blat" : [
        [33,1,0,0,0,0,0,0,"+","YourSeq",40,0,34,"chr1",249250621,155161117,155161151,1, 34,0,155161117],
        [33,1,0,0,0,0,0,0,"+","YourSeq",40,0,34,"chr1",249250621,155161255,155161289,1, 34,0,155161255],
        [33,1,0,0,0,0,0,0,"+","YourSeq",40,0,34,"chr1",249250621,155161315,155161349,1, 34,0,155161315],
        [33,1,0,0,0,0,0,0,"+","YourSeq",40,0,34,"chr1",249250621,155161435,155161469,1, 34,0,155161435],
        [33,1,0,0,0,0,0,0,"+","YourSeq",40,0,34,"chr1",249250621,155161495,155161529,1, 34,0,155161495]
    ]
}

An example of configuring a command line BLAT shell script, written for Linux and Mac systems, is given below. This script takes the search sequence and database ID as arguments, and simply calls the UCSC service referenced above and diverts the output to STDOUT.

The script, testBlat.sh:

#!/bin/bash
wget -q -O - --no-check-certificate "https://genome.ucsc.edu/cgi-bin/hgBlat?userSeq=$1&type=DNA&db=$2&output=json"

To use the script, set the "Blat url" IGV preference to:

testBlat.sh $SEQUENCE $DB
Clone this wiki locally