Let's say I want to download the fasta sequence of the region chr1:100000..200000 from the UCSC browser. How do you do that? I can't find a button to 'export to fasta' in the UCSC genome browser. I think that the solution is to click on one of the tracks displayed, but I am not sure of which. If I go to the Tables section, I can't find a table with the fasta sequences among the many.
Use the DAS server:
http://genome.ucsc.edu/cgi-bin/das/hg19/dna?segment=chr1:100000,200000
Just click "DNA" at the top of the screen.
There is no table with sequences. The sequences are in a file because that's a lot faster.
I think the question was mostly about how to get a single sequence and the answer to that is very simple: click View - DNA.
If you need to get the sequence from a script, use the UCSC utility twoBitToFa (see http://hgdownload.cse.ucsc.edu/admin/exe/) like this:
wget http://hgdownload.cse.ucsc.edu/admin/exe/linux.x86_64/twoBitToFa
chmod a+x twoBitToFa
twoBitToFa http://hgdownload.cse.ucsc.edu/gbdb/hg19/hg19.2bit test.fa -seq=chr21 -start=1 -end=10000
Yet another solution.
TogoWS's REST API now supports the UCSC Genome Database.
For example, http://togows.org/api/ucsc/hg38/chr1:12,345-12,500.fasta returns the reference genome sequence in the fasta format.
Please see further information at the "External API" section of http://togows.org/help/
The Genome Browser is for visualization.
To get data in many formats use the UCSC Table Browser then select the output format of your choice.
You may also need to select the right group and track to get the data you want.
I tought so, but I can't find the table for sequences, not even when I select 'All tracks' and 'AlLl tables'. Thanks anyway..
I guess you are right, now that I tried myself and it seems that information is awfully hard to get - sometimes the seemingly getting the easiest thing is not possible. You could try your luck with the Ensemble API.
I guess you are right, now that I tried myself and it seems that information is awfully hard to get - sometimes getting something seemingly easy end up as being not possible. You could try your luck with the Ensemble API.
I you need to download sequences, first you need to tell the website the coordinates that you want to download. (Remember that table browser is for batch processing). Click on "Custom track" and type in something like this:
chr1 1 1000
chr2 123 12345
Click Submit.
Now you can go to the table browser, select your "custom track" and select "Fasta format" as output format.
The advantage of this procedure is that you can request thousands of sequences in one go. No need to use an API. For scripting see my reply above that uses the linux command line tool "twoBitToFa" from UCSC.
I think, now UCSC browser has changed. Even I have the same query, but unable to fetch FASTA sequence using the coordinates. Can u explain using the given link.. https://genome.ucsc.edu/cgi-bin/hgTables?hgsid=703655381_NWHqxkgVDaPPscUhaKxyA9bAbb7e
Another solution is using Heng Li's sequence toolkit:
seqtk subseq Usage: seqtk subseq [options] <in.fa> <in.bed>|<name.list> Options: -t TAB delimited output -l INT sequence line length [0] Note: Use 'samtools faidx' if only a few regions are intended.
which can be downloaded from: https://github.com/lh3/seqtk , however, seqtk subseq does not consider the strand information, which has been implemented in bedtools getfasta
bedtools getfasta
Tool: bedtools getfasta (aka fastaFromBed) Version: v2.23.0 Summary: Extract DNA sequences into a fasta file based on feature coordinates. Usage: bedtools getfasta [OPTIONS] -fi <fasta> -bed <bed/gff/vcf> -fo <fasta> Options: -fi Input FASTA file -bed BED/GFF/VCF file of ranges to extract from -fi -fo Output file (can be FASTA or TAB-delimited) -name Use the name field for the FASTA header -split given BED12 fmt., extract and concatenate the sequencesfrom the BED "blocks" (e.g., exons) -tab Write output in TAB delimited format. - Default is FASTA format. -s Force strandedness. If the feature occupies the antisense, strand, the sequence will be reverse complemented. - By default, strand information is ignored. -fullHeader Use full fasta header. - By default, only the word before the first space or tab is used.
I understand this is a very old post, but if it helps anyone who is searching for programmatic access directly using UCSC tools, I found the below link http://genomewiki.ucsc.edu/index.php/Programmatic_access_to_the_Genome_Browser
It has details on
1) How to download data from their MySQL database
2) Get Chromosome sequence for a range (using REST API, which was what I was looking for)
... and few such things including accessing a copy of current Genome browser image
Hope this helps!