Session Overview
This lab loads reference genome feature data directly into the PostgreSQL Chado schema using PostgreSQL's \copy command. Participants will connect to the training database and bulk-import Nipponbare reference genome features from a CSV file, then verify the load with row count queries.
What You Will Do
- Connect to the
chado_trainingdatabase usingpsql - Load the Nipponbare reference genome features with
\copy - Verify the loaded data with SQL queries
Where to Get a Quality Reference Genome
For rice, a high-quality annotated reference genome (GFF + FASTA) can be downloaded from RiceOme — a comprehensive rice omics database maintained by Huazhong Agricultural University:
🌎 riceome.hzau.edu.cn/download.html
The GFF annotation file from this source is compatible with both loadReferenceGenome.sh and loadReferenceGenomeWSeq.sh provided in the Related Files section.
Related Files
Download these before starting the lab:
📄 11-feature-nipponbare.csv 📄 loadReferenceGenome.sh 📄 loadReferenceGenomeWSeq.shOption A — Load a Pre-built CSV with \copy
Use this option when a ready-made feature CSV is already available (e.g., the Nipponbare training file). Make sure you are in the directory containing the CSV file before connecting.
Step 1: Connect to the Database
sudo -u postgres psql -d chado_training
Step 2: Load the Reference Genome Features
\copy feature FROM '11-feature-nipponbare.csv' WITH (FORMAT csv, HEADER true)
Step 3: Verify
SELECT COUNT(*) FROM feature;
Option B — Load from GFF Using a Script
When you have a raw GFF annotation file instead of a pre-built CSV, use one of the two loader scripts. Both scripts automatically look up or insert the organism, CV, and cvterm entries, then generate intermediate CSVs and bulk-load them into Chado.
Which Script to Use?
| Script | When to use | Chromosome seqlen source | Chromosome naming |
|---|---|---|---|
loadReferenceGenome.sh |
GFF has only gene rows (no explicit chromosome rows) |
Inferred from the last gene position per chromosome | Chr1, Chr2 … |
loadReferenceGenomeWSeq.sh |
GFF has explicit chromosome-type rows with real sequence lengths |
Read directly from the chromosome row in the GFF |
chr01, chr02 … (zero-padded) |
What the Scripts Do
- Look up or insert the organism in the
organismtable - Look up or insert the
sequenceCV andchromosome/genecvterms - Generate
<output>_feature.csvand<output>_featureloc.csv - Bulk-load both CSVs into Chado using
\copy
Parameters
| Flag | Description |
|---|---|
-i | Input GFF file |
-o | Output file prefix (intermediate CSVs are named <prefix>_feature.csv etc.) |
-n | Organism common name (must match what is in the database) |
-p | PostgreSQL password (training2026 for the training database) |
Step 1: Make the Script Executable
chmod +x loadReferenceGenome.sh
Step 2: Run the Script
bash loadReferenceGenome.sh -i nipponbare.gff -o nipponbare -n "Japonica nipponbare" -p training2026
Or, if using the version with explicit chromosome lengths:
bash loadReferenceGenomeWSeq.sh -i nipponbare.gff -o nipponbare -n "Japonica nipponbare" -p training2026
Step 3: Verify
sudo -u postgres psql -d chado_training -c "SELECT COUNT(*) FROM feature;" sudo -u postgres psql -d chado_training -c "SELECT COUNT(*) FROM featureloc;"
Expected Outcome
- Chromosome and gene features are inserted into the
featuretable with correct organism and cvterm linkage. - Gene locations are recorded in
featurelocwith chromosome feature as the source feature (srcfeature_id). - Data is queryable using SQL joins across
feature,featureloc, andorganism.
uploadDataset.sh.