Lesson 2 of 13 · 11 min
Genes, Chromosomes, and Non-coding DNA
Almost every cell in your body carries a complete copy of your genome, the full set of DNA instructions written in just four chemical letters: A, C, G, and T. DNA is a long double-stranded molecule, and one copy of the human genome is about 3.1 billion of these paired letters, called base pairs, long. Each cell actually holds two copies, one inherited from each parent, so all the DNA in a single cell stretched end to end would reach roughly two meters, which the cell has to pack very carefully.
Packaging DNA into chromosomes
To fit inside the tiny nucleus, the membrane-wrapped compartment that holds a cell's DNA, the DNA is wound tightly around proteins and bundled into structures called chromosomes. Humans have 23 pairs of chromosomes, 46 in total: 22 matching pairs called autosomes, plus one pair of sex chromosomes, which are XX in a typical female and XY in a typical male. A separate, much smaller loop of DNA lives in the mitochondria, the cell's energy-producing compartments, and is usually labeled chrM.
# A reference genome is stored as a FASTA text file (here, the human genome, hg38,
# trimmed to just its main chromosome sequences).
# Every chromosome's sequence begins with a header line that starts with the '>' character.
# grep searches text line by line; the pattern "^>" means "a line beginning with >".
# The '|' pipe sends grep's output into 'head', which prints just the first 5 lines.
grep "^>" hg38.fa | head -n 5
# The -c flag makes grep count matching lines instead of printing them.
grep -c "^>" hg38.fa
# This file keeps one copy of each distinct chromosome, so the count is 25
# (chr1-chr22, chrX, chrY, and the mitochondrial chrM), not 46.>chr1
>chr2
>chr3
>chr4
>chr5
25
What counts as a gene
A gene is a stretch of DNA that the cell copies, a step called transcription, into a related molecule named RNA. For many genes that RNA is then read, or translated, into a protein, the folded chain of building blocks (called amino acids) that carries out most of a cell's work; biologists call this one-way flow from DNA to RNA to protein the central dogma. Before translation the cell edits the RNA by splicing, snipping out internal segments called introns and stitching together the segments that remain, the exons, which hold the part of the message that is kept.
# Gene annotations live in a GTF file (here, GENCODE human release 44).
# Columns are tab-separated; column 3 is the feature type, and the last column holds
# labels such as gene_type "protein_coding" - a gene's biotype, or functional category.
# awk -F'\t' sets the tab separator; '$3 == "gene"' keeps only lines that describe a whole gene.
# grep -oP does Perl-style matching: -o prints only the match, and \K drops the leading gene_type " so we keep just the biotype word.
# sort groups identical words, uniq -c counts each group, sort -rn ranks them high-to-low, and head -n 8 shows the top 8.
awk -F'\t' '$3 == "gene"' gencode.v44.annotation.gtf \
| grep -oP 'gene_type "\K[^"]+' \
| sort | uniq -c | sort -rn | head -n 8 20046 protein_coding
19928 lncRNA
10156 processed_pseudogene
2615 unprocessed_pseudogene
2212 misc_RNA
1901 snRNA
1879 miRNA
942 snoRNA
The other 98 percent
Notice that protein-coding genes are only one biotype among many, and even they are mostly non-coding inside: their introns, plus the wide gaps between genes, mean that actual protein-coding sequence adds up to only about 1 to 2 percent of the whole genome. Many of the other entries are pseudogenes, broken copies of once-working genes that no longer make a functional protein. The rest of the genome includes regulatory regions such as promoters, which sit right in front of a gene and help switch it on, and enhancers, which can boost a gene from far away. It also includes vast stretches of repetitive elements, many of them leftover copies of mobile DNA, that together make up nearly half the genome, plus thousands of non-coding RNA genes, like the lncRNA and miRNA seen above, whose RNA does a job without ever becoming a protein.
Try it yourself: Take the awk command above, replace '$3 == "gene"' with '$3 == "exon"', and end the pipe with 'wc -l' (which counts lines) in place of the biotype tally. The result, well over a million exon records, shows just how finely genes are chopped into exons across all of their transcripts.