Lesson 14 of 16 · 10 min
Fetching a sequence by accession
Sequence databases hold millions of records, but often you already know the exact one you want. In this lesson you'll learn how to pull a single sequence when you have its official name.
What is an accession?
Every record in a sequence database has a unique label called an accession number, which works like the exact street address of one record. For example, NM_007294 points to a specific messenger RNA (a working copy of a gene) from the human BRCA1 gene, a stretch of DNA that helps cells repair damage. Give a database that address and it hands you back exactly that record.
Get it from the web
Go to the NCBI website, the main public home for these databases, and paste the accession NM_007294 into the search box, then open the matching record. Click Send to, choose File, pick FASTA (a plain-text format for sequences) as the format, and click Create File to download it to your computer.
The command line way
Clicking is fine for one record, but once you need many you'll want the command line, a text window where you type instructions instead of clicking. A tool called efetch can pull a record straight from NCBI; it comes from a free toolkit named Entrez Direct that you install once (we'll cover installing it in a later lesson).
efetch -db nucleotide -id NM_007294 -format fasta > brca1.fastaThe > at the end means save the result into a file instead of printing it to the screen, so nothing appears yet. The file is now named brca1.fasta. To peek at just its first few lines, use the head command, which prints the top of a file.
head brca1.fasta>NM_007294.4 Homo sapiens BRCA1 DNA repair associated (BRCA1), transcript variant 1, mRNA
GCTGAGACTTCCTGGACGGGGGACAGGCTGTGGGGTTTCTCAGATAACTGGGCCCCTGCGCTCAGGAGGC
CTTCACCCTCTGCTCTGGGTAAAGTTCATTGGAACAGAAAGAAATGGATTTATCTGCTCTTCGCGTTGAA
GAAGTACAAAATGTCATTAATGCTATGCAGAAAATCTTAGAGTGTCCCATCTGTCTGGAGTTGATCAAGG
AACCTGTCTCCACAAAGTGTGACCACATATTTTGCAAATTTTGCATGCTGAAACTTCTCAACCAGAAGAA
AGGGCCTTCACAGTGTCCTTTATGTAAGAATGATATAACCAAAAGGAGCCTACAAGAAAGTACGAGATTT
AGTCAACTTGTTGAAGAGCTATTGAAAATCATTTGTGCTTTTCAGCTTGACACAGGTTTGGAGTATGCAA
ACAGCTATAATTTTGCAAAAAAGGAAAATAACTCTCCTGAACATCTAAAAGATGAAGTTTCTATCATCCA
AAGTATGGGCTACAGAAACCGTGCCAAAAGACTTCTACAGAGTGAACCCGAAAATCCTTCCTTGCAGGAA
ACCAGTCTCAGTGTCCAACTCTCTAACCTTGGAACTGTGAGAACTCTGAGGACAAAGCAGCGGATACAAC
Try it yourself: Pick another accession, such as NM_000546 (the human TP53 gene, often called the guardian of the genome), fetch it with efetch into a file, then open it with head. Compare its header line to the BRCA1 one you just saw and notice how each record announces exactly what it is.