Programmatic access to the Genome Browser

From genomewiki
Revision as of 09:08, 6 July 2015 by Max (talk | contribs) (Created page with "* Get the sequence of a genome at a particular place ** Download the tool twoBitToFa from http://hgdownload.cse.ucsc.edu/admin/exe/ ** twoBitToFa http://hgdownload.cse.ucsc.edu/g...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
  • Download data from 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
    • use "curl http://genome.ucsc.edu/cgi-bin/hgRenderTracks > test.png". hgRenderTracks understands the same parameters and options as the main hgTracks CGI, e.g. <trackName>=pack.
    • to show only a single track with hgRenderTracks, make sure that the first track parameter is hideTracks=1
    • for example, to download the image for a chromosomal location with only the RefSeq transcripts and publications track to "pack" mode, use this command:
  curl 'http://genome.ucsc.edu/cgi-bin/hgRenderTracks?position=chr17:41570860-41650551&hideTracks=1&refGene=pack&pubs=pack' > temp.png 
  • Upload a custom track and link to the genome browser with the track loaded
    • create a file temp.bed with contents like these:
 track name="TestTrack" description="TestTrack with links on features" url="http://www.google.com/$$"
 chr1 1 1000 testIdForUrl
    • upload your file with a command like this, it will print a string to stdout which we are calling $HGSID in the following
 curl -s -F db=hg19 -F 'hgct_customText=chr1 1 1000' http://genome.ucsc.edu/cgi-bin/hgCustom  | grep -o 'hgsid=[0-9]*_[a-zA-Z0-9]*' | uniq | sed -e 's/hgsid=//'