Programmatic access to the Genome Browser: Difference between revisions

From genomewiki
Jump to navigationJump to search
Line 26: Line 26:
* upload your file with a command like this, it will print a string to stdout which we are calling $HGSID in the following <code>curl -s -F db=hg19 -F 'hgct_customText=@temp.bed' http://genome.ucsc.edu/cgi-bin/hgCustom  | grep -o 'hgsid=[0-9]*_[a-zA-Z0-9]*' | uniq | sed -e 's/hgsid=//'</code>
* upload your file with a command like this, it will print a string to stdout which we are calling $HGSID in the following <code>curl -s -F db=hg19 -F 'hgct_customText=@temp.bed' http://genome.ucsc.edu/cgi-bin/hgCustom  | grep -o 'hgsid=[0-9]*_[a-zA-Z0-9]*' | uniq | sed -e 's/hgsid=//'</code>
* you can link to a fresh genome browser session with only this track loaded with  http://genome.ucsc.edu/cgi-bin/hgTracks?hgsid=$HGSID&position=chr1:1-1000
* you can link to a fresh genome browser session with only this track loaded with  http://genome.ucsc.edu/cgi-bin/hgTracks?hgsid=$HGSID&position=chr1:1-1000
* you can load more tracks into this session by adding the parameter hgsid=$HGSID to all future curl calls
* you can load more tracks into this session by adding the parameter hgsid=$HGSID to all future curl calls with the parameter "-F hgsid=$HGSID"
* you can download the image of this sessions with hgRenderTrack above, by supplying the $HGSID value to hgRenderTracks, like this <code>curl "http://genome.ucsc.edu/cgi-bin/hgRenderTracks?hgsid=$HGSID" > test.png</code>
* you can download the image of this session with hgRenderTrack as shown above, by supplying the $HGSID value to hgRenderTracks, like this <code>curl "http://genome.ucsc.edu/cgi-bin/hgRenderTracks?hgsid=$HGSID" > test.png</code>

Revision as of 09:42, 6 July 2015

The UCSC API for retrieving data and uploading data is not REST driven but revolves around client-side C tools that convert to/from binary files.

Here are some common tasks that can be solved with calls from scripts to the UCSC Genome Browser, assuming that you know the standard Unix command line tools:

Get the chromosome sequence for a range

Get the "wiggle" (x-y-plot) graph data for a chromosome range

Download data stored in a database table

  • use Tools - Table Browser - "Describe schema" to browse the database schema. All fields have a human readable description and the links to other tables are shown.
  • mysql --no-defaults -h genome-mysql.cse.ucsc.edu -u genome -A -e 'select * from pubsBingBlat' -NB > out.txt

Get a copy of the current Genome Browser image from a script

Upload a custom track and link to the genome browser with the track loaded