Genes, DNA and Chromosomes

Genetics and Heredity Fundamentals

Course 1 ยท Chapter 2 ยท Genes, DNA and Chromosomes

Genetics and Heredity Fundamentals 1 treated Mendel's "factors" as letters: A and a. This chapter asks what those letters physically are. The short answer is that an allele is a stretch of DNA, DNA is packaged into chromosomes, and the whole collection in a cell is its genome. As before, the code is Python 3, run before it is shown, and facts written from general knowledge are marked (check).

What was run, and what was not
All programs here were run and the output shown is what they printed. The biology (numbers of chromosomes, genome sizes, dates) is from general knowledge and not checked against a source while writing; items marked (check) are the ones to verify first.

What DNA Is

DNA (deoxyribonucleic acid) is a long molecule built from a chain of small units called nucleotides. Each nucleotide has a sugar, a phosphate group and one of four bases: adenine (A), thymine (T), guanine (G) and cytosine (C). The sugar and phosphate form a backbone; the bases stick out sideways. The order of the bases is the information.

That makes DNA convenient for programmers: to a good approximation a piece of DNA is just a string over a four-letter alphabet.

The Double Helix and Base Pairing

DNA normally exists as two strands wound around each other in a double helix, a structure worked out in 1953 by James Watson and Francis Crick, building on X-ray data from Rosalind Franklin and Maurice Wilkins (check the details of who contributed what). The strands are held together by bonds between bases, and the pairing is strict:

BasePairs withBonds between them (check)
A (adenine)T (thymine)2 hydrogen bonds
G (guanine)C (cytosine)3 hydrogen bonds

Because of this rule, one strand completely determines the other. The two strands also run in opposite directions: each strand has a start (called the 5' end) and a finish (the 3' end), and the partner strand is read the other way round. So the partner of ATGC, written in the usual 5' to 3' direction, is GCAT, the reverse complement.

COMP = str.maketrans("ACGT", "TGCA") def complement(s): return s.translate(COMP) def reverse_complement(s): return complement(s)[::-1] strand = "ATGCGTACCTGA" print(strand) print(complement(strand)) print(reverse_complement(strand)) print(reverse_complement(reverse_complement(strand)) == strand)

Output:

ATGCGTACCTGA TACGCATGGACT TCAGGTACGCAT True

str.translate swaps every letter at once using the table from str.maketrans. The plain complement lines up letter for letter under the original; the reverse complement is the partner strand as it would be written in its own 5' to 3' direction. Taking the reverse complement twice gives back the original, which is the check on the last line.

Counting Bases and GC Content

Pairing has a consequence: in double-stranded DNA the number of A bases equals the number of T bases, and G equals C. This was noticed by Erwin Chargaff in the late 1940s (check), before the structure was known, and is called Chargaff's rule. It holds for the two strands taken together, not for a single strand.

The share of bases that are G or C is the GC content. It varies between species and between regions of a genome, and because a G–C pair has three bonds against two for A–T, GC-rich DNA is a little harder to pull apart (check).

from collections import Counter def gc_content(s): return (s.count("G") + s.count("C")) / len(s) seq = "ATGCGTACCTGAGGCCATTA" print(len(seq), dict(Counter(seq))) print(round(gc_content(seq), 3)) print(round(gc_content("ATATATATAT"), 3), round(gc_content("GCGCGCGCGC"), 3)) other = "".join({"A": "T", "T": "A", "G": "C", "C": "G"}[b] for b in seq) both = Counter(seq + other) print(both["A"] == both["T"], both["G"] == both["C"])
20 {'A': 5, 'T': 5, 'G': 5, 'C': 5} 0.5 0.0 1.0 True True

This particular strand happens to have equal numbers of all four bases, which is a coincidence of the example, so the final line is only a real test because we build the partner strand and count both together. Try it on a lopsided strand such as AAAAGC: the single strand fails the A = T test, but the pair of strands passes.

Genes, Chromosomes and the Genome

A gene is a stretch of DNA that carries the instructions for making a product, usually a protein (chapter 3 follows how). The gene is where an allele lives: two alleles of the same gene are two versions of the same stretch of DNA, differing in some of their bases. Genes are not evenly packed; in humans most of the DNA lies between genes or inside them in non-coding regions, and the exact share that does something useful is debated (check).

A cell's DNA is divided among several long pieces, the chromosomes, each one a single enormous DNA molecule wrapped around proteins so that it fits inside the cell. The complete set of DNA in a cell is its genome. A chromosome holds many genes, and each gene sits at a fixed position on a particular chromosome, called its locus.

Mendel's rule that every plant has two copies of each factor now has a physical meaning: most cells of a plant or animal are diploid, holding chromosomes in matching pairs, one of each pair from each parent. The sex cells (eggs and pollen or sperm) are haploid, with one of each pair. The numbers differ by species:

# (name, diploid chromosome number); values from general knowledge organisms = [("pea", 14), ("fruit fly", 8), ("human", 46), ("dog", 78)] for name, n2 in organisms: print(name, n2, "chromosomes =", n2 // 2, "pairs; gamete carries", n2 // 2)
pea 14 chromosomes = 7 pairs; gamete carries 7 fruit fly 8 chromosomes = 4 pairs; gamete carries 4 human 46 chromosomes = 23 pairs; gamete carries 23 dog 78 chromosomes = 39 pairs; gamete carries 39

All four numbers are from general knowledge (check). The count says nothing about complexity: it is a fact about how the DNA happens to be packaged. A pea has seven pairs, and Mendel studied seven traits; this is a well-known coincidence, and the question of whether his traits sat on different chromosomes comes back in chapter 5 (check the details there).

Gene, allele, chromosome: keep them apart
A chromosome is a physical package of DNA. A gene is a region of it. An allele is one version of that region. A diploid cell has two copies of each chromosome (apart from the sex chromosomes, chapter 7), so two alleles of each gene, which may be the same or different.

How Big Is a Genome?

The human haploid genome is usually quoted as about 3.1 billion base pairs (check). If each base needs two bits (four choices), a quick calculation gives the raw information content:

bases = 3_100_000_000 print(bases * 2, "bases in a diploid cell") bits = bases * 2 print(round(bits / 8 / 1e9, 3), "GB at 2 bits per base (haploid)") print(round(bases * 0.34 / 1e9, 2), "metres of DNA if 0.34 nm per base (haploid)")
6200000000 bases in a diploid cell 0.775 GB at 2 bits per base (haploid) 1.05 metres of DNA if 0.34 nm per base (haploid)

So a haploid human genome would fit in under a gigabyte, and the DNA of one set of chromosomes, laid end to end, is about a metre long (using 0.34 nanometres per base, check). All of that sits inside a cell nucleus a few micrometres across, which is why DNA is so tightly wound and packaged.

Challenges

Exercise 1

Write reverse_complement(s). For ATGC, GGGATTT and AAAACCCGGT, print each sequence, its reverse complement, and whether applying the function twice returns the original. Then test whether GAATTC and GGATCC equal their own reverse complement.

๐Ÿ“„ View solution
Exercise 2

Given four sequences, print them in order of increasing GC content with the value to two decimals, and then name the one with the highest GC content.

๐Ÿ“„ View solution
Exercise 3

Write dna_bytes(bases, bits_per_base) and use it to estimate, in megabytes, the raw storage for the haploid genomes of three organisms, then the human figure in gigabytes if each base were stored as one 8-bit character instead.

๐Ÿ“„ View solution

Quick Reference

  • DNA: a chain of nucleotides with bases A, T, G, C; the base order is the information
  • Pairing: A with T, G with C; one strand fixes the other
  • Reverse complement: the partner strand written 5' to 3'
  • GC content: the fraction of bases that are G or C
  • Gene: a region of DNA; allele: a version of it; chromosome: a whole DNA package
  • Diploid cells have pairs of chromosomes; haploid sex cells have one of each
  • Check: the chromosome numbers, genome size, bond counts, and who contributed what to 1953
Coming next
Genetics and Heredity Fundamentals 3 follows a gene's instructions from DNA to protein, and what happens when a base changes.