Introduction to Biological Databases

Understand the landscape of biological databases — what they store, how they are structured, and why every bioinformatician must know how to navigate them.

📅 Module 11 · Week 16 · Lesson 1 of 6
Lesson 1 ⏱ 45 min 🐍 Python 🖥 CLI 🔬 Bioinformatics ⭐ Beginner

1. What is a biological database?

A biological database is an organised, searchable collection of biological data — sequences, structures, functions, pathways, variants, annotations, and more. These databases are the foundation of modern bioinformatics. Without them, you would have no reference genome to align to, no protein structure to compare, and no pathway to place your genes in context.

🔬 Why this matters for your work

When you run an RNA-seq experiment on sorghum, every step depends on biological databases: the reference genome comes from Ensembl Plants, gene annotations from NCBI RefSeq, protein functions from UniProt, and metabolic pathways from KEGG. Knowing which database to query, how to query it, and how to interpret what comes back is not optional — it is the starting point for every downstream analysis.

Biological databases exist because biological knowledge is vast, distributed, and constantly updated. Individual researchers deposit their findings (sequences, structures, expression data) into centralised repositories so that the entire community can build on that work. This is the principle of open science — and it is what makes bioinformatics possible.

💡

Historical note: The first biological sequence database was GenBank, established by the US National Institutes of Health (NIH) in 1982. Today it holds over 300 billion nucleotide bases from more than 40 million sequences, doubling in size roughly every 18 months.

How databases are structured

Every database record has a predictable anatomy. Understanding this structure lets you extract exactly what you need programmatically. A typical record contains:

Field What it contains Example (GenBank)
Accession Unique stable identifier NM_001316.3
Definition Plain-English description Homo sapiens RNA gene
Organism Source organism + taxonomy Sorghum bicolor (9606)
Sequence The actual nucleotide / AA sequence ATGATCGGC…
Features Annotated regions (CDS, exons, UTRs) CDS 1..453
References Publications linked to this record PMID:12345678
Cross-references IDs in other databases UniProt: P12345

2. Types of biological databases

Databases are classified by what they store and how they are curated. Understanding these categories prevents you from searching the wrong place and wasting hours of work.

By data type

Category What it stores Examples
Sequence databases Nucleotide & protein sequences GenBank, EMBL-EBI, DDBJ, RefSeq
Structure databases 3D molecular structures (X-ray, cryo-EM, NMR) PDB (Protein Data Bank)
Genome databases Annotated reference genomes Ensembl, UCSC Genome Browser, Phytozome
Protein function databases Protein identities, domains, pathways UniProt, InterPro, Pfam
Pathway & interaction databases Metabolic & signalling pathways, PPIs KEGG, Reactome, STRING
Expression databases Transcriptomic & proteomic data GEO, ArrayExpress, Expression Atlas
Variant databases SNPs, indels, structural variants dbSNP, ClinVar, gnomAD
Ontology databases Controlled vocabularies for annotation Gene Ontology (GO), Plant Ontology

By curation level

🔬 Primary vs Secondary vs Tertiary databases

Primary databases (GenBank, PDB) hold raw deposited data — submitted directly by researchers. Secondary databases (UniProt/Swiss-Prot, RefSeq) take that raw data and add expert annotation and quality checks. Tertiary databases (KEGG, Reactome) integrate data from many primary and secondary sources to build higher-level knowledge. For bioinformatics analysis, you almost always want secondary or tertiary databases — the annotations are more reliable than raw deposits.

⚠️

GenBank vs RefSeq: GenBank is the raw, unreviewed archive. RefSeq is a curated, non-redundant subset with standardised annotation. For gene/transcript sequences in your pipeline, always prefer RefSeq accessions (begin with NM_, NR_, XM_) over raw GenBank accessions where possible.

3. Major databases you will use

You do not need to memorise every database. You need to know the six core hubs that cover 90% of bioinformatics work — and which one to reach for in each situation.

🧬

NCBI / GenBank

The US national repository for nucleotide sequences, proteins, genomes, literature (PubMed), and taxonomy. The starting point for most searches.

Sequence
🔵

UniProt

The definitive protein sequence and function database. Swiss-Prot (manually curated) + TrEMBL (automatically annotated). Essential for protein work.

Protein
🌍

Ensembl

Annotated reference genomes for vertebrates and plants (Ensembl Plants). The go-to source for gene models, variants, and comparative genomics.

Genome
🔗

KEGG

Kyoto Encyclopedia of Genes and Genomes. Maps genes to metabolic pathways and disease pathways. Indispensable for functional enrichment analysis.

Pathway
🔲

PDB

Worldwide Protein Data Bank. 3D structures of proteins, nucleic acids, and complexes. Used for structural bioinformatics and drug target analysis.

Structure
📊

GEO

NCBI Gene Expression Omnibus. Thousands of publicly deposited RNA-seq, microarray, and epigenomics datasets you can re-analyse or use as controls.

Expression
🌱

Plant genomics tip: For Sorghum bicolor specifically, you will work with Phytozome (JGI Plant Portal), Ensembl Plants, SorghumBase, and NCBI. SorghumBase is a newer community resource that aggregates sorghum genomics data including SNPs from GWAS studies — directly relevant to your thesis work on genomic selection.

4. Common data formats from databases

Every database exports data in specific file formats. Before you can parse or analyse anything, you must recognise the format you received. The most important ones are:

Format Extension What it looks like Used for
FASTA .fa .fasta >ID description
ATGATCGGC…
Sequences (DNA, RNA, protein)
FASTQ .fq .fastq 4 lines per read: ID, seq, +, quality Raw sequencing reads with quality scores
GenBank flat file .gb .gbk LOCUS / DEFINITION / FEATURES header block Annotated sequence records
GFF3 / GTF .gff3 .gtf Tab-separated: seqname, source, feature, start, end… Gene annotations, exon coordinates
VCF .vcf ## header + CHROM POS ID REF ALT columns Variant calls (SNPs, indels)
JSON / XML .json .xml Key-value or tagged hierarchical text API responses from Entrez, Ensembl REST
🔬 FASTA vs FASTQ — the critical distinction

FASTA is a clean sequence you get from a database (a reference genome, a protein). FASTQ is a raw file you get from your sequencer — it contains quality scores because sequencers make errors. You align FASTQ reads against a FASTA reference. These two formats are never interchangeable. Confusing them at the start of your pipeline is one of the most common beginner mistakes.

FASTA format — anatomy

📁 No directory needed — this is a format reference
FASTA
# Every FASTA record has exactly two parts:

>Sb01g000010.1 Sorghum bicolor gene SbDREB2 [Sorghum bicolor]
#  ↑ Header line: starts with ">" then accession ID then description

ATGATCGGCATCGACGAGCTTCTCAAGGACTTCGAGCAGCAGCTCAAGAAGCACGGCATC
GAGCTCGTCGCGTTCGACGCGCTCAAGGAGATCATCATCGAGCGCGTCGACGACGAGCTC
ATCGAGCGCATGAAGAAGCTCGAGCAGCAGCTCAAGCACATCGGCATCGAGCTCGTCGCG
# ↑ Sequence: any number of lines, no spaces or special characters

# Multiple records in one file — simply repeat the pattern:
>Sb01g000020.1 Sorghum bicolor gene SbWRKY1 [Sorghum bicolor]
ATGGCGAGCTTCGACGAGCTCATCAAGGACTTCGAGCAGCAGCTCAAG…

5. Your first database query

The fastest way to query a biological database from the command line is with curl — a tool that sends HTTP requests and receives the response. Most major databases (NCBI, Ensembl, UniProt) offer a REST API that you can call with nothing more than a URL. No registration, no software, just a URL.

🔬 What is a REST API?

REST (Representational State Transfer) is a convention for web services. A REST API lets you retrieve data by constructing a URL with parameters — exactly like a Google search, but for scientific data. The database server receives your request, runs the query on its side, and returns the result as text (FASTA, JSON, XML, plain text). This is how bioinformatics pipelines automatically download thousands of sequences without any human clicking.

Query NCBI with curl — fetch a sequence

NCBI's Entrez API is called E-utilities (eutils). The most important tool is efetch, which retrieves a record by accession number.

📁 Run from: ~/database-queries
Bash
# First, create your working directory
mkdir -p ~/database-queries
cd ~/database-queries

# Fetch a sorghum protein sequence from NCBI in FASTA format
# Breakdown of the URL parameters:
#   db=protein        — which NCBI database to query
#   id=XP_002449040   — the accession number to retrieve
#   rettype=fasta     — return format (fasta, gb, xml, etc.)
#   retmode=text      — response encoding

curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=protein&id=XP_002449040&rettype=fasta&retmode=text"

# -s flag = silent mode (suppresses progress bar)

You will see FASTA output printed directly in your terminal:

Output
>XP_002449040.1 PREDICTED: putative DREB transcription factor [Sorghum bicolor]
MAAMAEGSGGGGGMSGPPPPPPPYGLAQHHHHHHHHHHHPPLRAAEDPMTAEQLAQEFWSD
DLEELIEALEAEMQALHADIVTGFREPDHRLLIQQVQRSAADMRGKMRGAVAKAGIEDSMS
YRMKVGKGMPWSKKERVIVGPPADIAQIAEKYWQKYAPDATRGKQLRGRSAIPVPQEKFLQ

Save the output to a file

📁 Run from: ~/database-queries
Bash
# Save directly to a FASTA file instead of printing to screen
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=protein&id=XP_002449040&rettype=fasta&retmode=text" > sorghum_dreb.fasta

# Verify the file was created and contains data
ls -lh sorghum_dreb.fasta
head -3 sorghum_dreb.fasta

The same query with Python (Biopython Entrez)

🔬 Why use Biopython instead of curl?

For a single sequence, curl is faster. But when you need to fetch hundreds of sequences, parse the results, handle errors, or integrate the query into a larger pipeline, Biopython's Entrez module is far superior. It manages rate limits automatically (NCBI allows max 3 requests/second without an API key, 10 with), handles pagination, and parses GenBank records into Python objects you can immediately work with.

📁 Run from: ~/database-queries
Python
#!/usr/bin/env python3
# fetch_sequence.py — fetch a protein sequence from NCBI using Biopython

from Bio import Entrez, SeqIO

# NCBI requires you to identify yourself with an email
# (so they can contact you if your script causes problems)
Entrez.email = "your.email@example.com"

# efetch: retrieve a record from a specific database by ID
handle = Entrez.efetch(
    db="protein",          # database name
    id="XP_002449040",    # accession number
    rettype="fasta",       # format: fasta, gb, xml
    retmode="text"         # encoding: text or xml
)

# SeqIO.read() parses the FASTA into a SeqRecord object
record = SeqIO.read(handle, "fasta")
handle.close()

# Now you can access the parts of the record as Python attributes
print(f"ID          : {record.id}")
print(f"Description : {record.description}")
print(f"Length      : {len(record.seq)} amino acids")
print(f"First 30 aa : {record.seq[:30]}")

# Save to FASTA file
with open("sorghum_dreb_biopython.fasta", "w") as out_f:
    SeqIO.write(record, out_f, "fasta")
Output
ID          : XP_002449040.1
Description : XP_002449040.1 PREDICTED: putative DREB transcription factor [Sorghum bicolor]
Length      : 217 amino acids
First 30 aa : MAAMAEGSGGGGGMSGPPPPPPPYGLAQHHH
💡

Install Biopython if you haven't yet: pip install biopython or conda install -c conda-forge biopython. Your conda environment from Module 3 is the right place to install it.

Advertisement Support free bioinformatics education

6. Quick reference — databases at a glance

Database URL Best for API?
NCBI / GenBank ncbi.nlm.nih.gov Sequences, genomes, literature, taxonomy ✅ E-utilities
RefSeq ncbi.nlm.nih.gov/refseq Curated reference sequences ✅ E-utilities
UniProt uniprot.org Protein function, domains, pathways ✅ REST API
Ensembl ensembl.org Vertebrate genomes, gene models ✅ REST API
Ensembl Plants plants.ensembl.org Plant genomes incl. sorghum, rice, maize ✅ REST API
SorghumBase sorghumbase.org Sorghum genomics, SNPs, expression Partial
PDB rcsb.org 3D protein structures ✅ REST API
KEGG kegg.jp Metabolic pathways, functional annotation ✅ KEGG API
GEO ncbi.nlm.nih.gov/geo Public RNA-seq / expression datasets ✅ E-utilities
Gene Ontology geneontology.org Functional annotation terms ✅ AmiGO API

7. Exercises

1
Identify the format

You download a file from NCBI that starts with the line @SRR12345.1 1 length=150. What format is this? What database would it have come from? Why does it have four lines per entry?

▶ Show answer
This is FASTQ format. The @ prefix on the header line (instead of >) is the distinguishing feature. It would come from NCBI SRA (Sequence Read Archive) — the database for raw sequencing reads. It has four lines per entry because: (1) the header line with @, (2) the nucleotide sequence, (3) a + separator line, and (4) the quality score string — one ASCII character per base representing the Phred quality score of that base call.
2
Curl query

Use curl and the NCBI E-utilities API to fetch the nucleotide sequence for accession NM_001078124 (a sorghum mRNA) in FASTA format. Save it to a file called sorghum_mrna.fasta. Then use grep to count the number of lines in the file.

▶ Show answer
curl -s "https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=nucleotide&id=NM_001078124&rettype=fasta&retmode=text" > sorghum_mrna.fasta
wc -l sorghum_mrna.fasta
Change db=nucleotide (not protein) since this is a nucleotide accession. The wc -l command counts lines. You should see the FASTA header on line 1 and the sequence split across subsequent lines.
3
Python + Biopython

Modify the fetch_sequence.py script to fetch three sorghum protein accessions in a loop: XP_002449040, XP_002463573, XP_002446972. Print the ID and length of each. Save all three to a single FASTA file called sorghum_proteins.fasta.

▶ Show answer
from Bio import Entrez, SeqIO
import time

Entrez.email = "your.email@example.com"

accessions = ["XP_002449040", "XP_002463573", "XP_002446972"]
records = []

for acc in accessions:
    handle = Entrez.efetch(db="protein", id=acc, rettype="fasta", retmode="text")
    rec = SeqIO.read(handle, "fasta")
    handle.close()
    records.append(rec)
    print(f"{rec.id}: {len(rec.seq)} aa")
    time.sleep(0.4)  # respect NCBI rate limit

SeqIO.write(records, "sorghum_proteins.fasta", "fasta")
The time.sleep(0.4) is critical — without it, NCBI will block your IP after 3 rapid requests per second.
4
Research task

Visit SorghumBase (sorghumbase.org) and find the reference genome version currently used for Sorghum bicolor. What is the genome assembly name? How many chromosomes does sorghum have? Where does that genome data ultimately come from (which primary database)?

▶ Show answer
The current sorghum reference genome in SorghumBase is Sbicolor_454_v3.1.1 (Sorghum bicolor v3, published by the DOE Joint Genome Institute). Sorghum has 10 chromosomes (2n = 20). The genome data originates from Phytozome (JGI Plant Portal), which is one of the primary plant genome databases. SorghumBase integrates this genome with community annotation tracks, expression data, and variant data.
Track your progress
Lesson 1 of 6 · Module 11
Advertisement Support free bioinformatics education