Cobalamin biosynthesis
Cobalamin biosynthesis is the process by which bacteria and archea make cobalamin, vitamin B12. Many steps are involved in converting aminolevulinic acid via uroporphyrinogen III and adenosylcobyric acid to the final forms in which it is used by enzymes in both the producing organisms and other species, including humans who acquire it through their diet. The feature which distinguishes the two main biosynthetic routes is whether the cobalt that is at the catalytic site in the coenzyme is incorporated early (in anaerobic organisms) or late (in aerobic organisms) and whether oxygen is required. In both cases, the macrocycle that will form a coordination complex with the cobalt ion is a corrin ring, specifically one with seven carboxylate groups called cobyrinic acid. Subsequently, amide groups are formed on all but one of the carboxylates, giving cobyric acid, and the cobalt is ligated by an adenosyl group. In the final part of the biosynthesis, common to all organisms, an aminopropanol sidechain is added to the one free carboxylic group and assembly of the nucleotide loop, which will provide the second ligand for the cobalt, is completed. Many prokaryotic species cannot biosynthesize adenosylcobalamin, but can make it from cobalamin which they assimilate from external sources. In humans, dietary sources of cobalamin are bound after ingestion as transcobalamins and converted to the coenzyme forms in which they are used. Cobalamin

Cobalamin (vitamin B12) is the largest and most structurally complex vitamin. It consists of a modified tetrapyrrole, a corrin, with a centrally chelated cobalt ion and is usually found in one of two biologically active forms: methylcobalamin and adenosylcobalamin. Most prokaryotes, as well as animals, have cobalamin-dependent enzymes that use it as a cofactor, whereas plants and fungi do not use it. In bacteria and archaea, these enzymes include methionine synthase, ribonucleotide reductase, glutamate and methylmalonyl-CoA mutases, ethanolamine ammonia-lyase, and diol dehydratase. In certain mammals, cobalamin is obtained through the diet, and is required for methionine synthase and methylmalonyl-CoA mutase. In humans, it plays essential roles in folate metabolism and in the synthesis of the citric acid cycle intermediate, succinyl-CoA. Overview of cobalamin biosynthesis
There are at least two distinct cobalamin biosynthetic pathways in bacteria:

Aerobic pathway that requires oxygen and in which cobalt is inserted late in the pathway; found in Pseudomonas denitrificans and Rhodobacter capsulatus. Anaerobic pathway in which cobalt insertion is the first committed step towards cobalamin synthesis;  found in Salmonella typhimurium, Bacillus megaterium, and Propionibacterium freudenreichii subsp. shermanii. Either pathway can be divided into two parts: 
Corrin ring synthesis leading to cobyrinic acid, with seven carboxylate groups. In the anaerobic pathway this already contains cobalt but in the aerobic pathway the material formed at that stage is hydrogenobyrinic acid, without the bound cobalt. Insertion of cobalt, where not already present; formation of amides on all but one of the carboxylate groups to give cobyric acid; attachment of an adenosyl group as ligand to the cobalt;  attachment of an aminopropanol sidechain to the one free carboxylic group and assembly of the nucleotide loop which will provide the second ligand for the cobalt. A further type of synthesis occurs through a salvage pathway, where outside corrinoids are absorbed to make B12. Species from the following genera and the following individual species are known to synthesize cobalamin: Propionibacterium shermanii, Pseudomonas denitrificans, Streptomyces griseus, Acetobacterium, Aerobacter, Agrobacterium, Alcaligenes, Azotobacter, Bacillus, Clostridium, Corynebacterium, Flavobacterium, Lactobacillus, Micromonospora, Mycobacterium, Nocardia, Proteus,
Rhizobium, Salmonella, Serratia, Streptococcus and Xanthomonas. Detail of steps up to formation of uroporphyrinogen III

In the early steps of the biosynthesis, a tetrapyrrolic structural framework is created by the enzymes deaminase and cosynthetase which transform aminolevulinic acid via porphobilinogen and hydroxymethylbilane to uroporphyrinogen III. The latter is the first macrocyclic intermediate common to haem, chlorophyll, sirohaem and cobalamin itself. Detail of steps from uroporphyrinogen III to  acid a,c-diamide in aerobic organisms
The biosynthesis of cobalamin diverges from that of haem and chlorophyll at uroporphrinogen III: its transformation involves the sequential addition of methyl (CH3) groups to give intermediates that were given trivial names according to the number of these groups that have been incorporated. Hence, the first intermediate is precorrin-1, the next is precorrin-2 and so on. The incorporation of all eight additional methyl groups which occur in cobyric acid was investigated using 13C methyl-labelled S-adenosyl methionine. It was not until scientists at Rhône-Poulenc Rorer used a genetically-engineered strain of Pseudomonas denitrificans, in which eight of the cob genes involved in the biosynthesis of the vitamin had been overexpressed, that the complete sequence of methylation and other steps could be determined, thus fully establishing all the intermediates in the pathway. From uroporphyrinogen III to precorrin-2
The enzyme CobA   catalyses two methylations, to give precorrin-2:

(1a) uroporphyrinogen III + S-adenosyl methionine   precorrin-1 + S-adenosyl-L-homocysteine
(1b) precorrin-1 + S-adenosyl methionine    precorrin-2 + S-adenosyl-L-homocysteine

From precorrin-2 to precorrin-3A
The enzyme CobI then converts this to precorrin-3A:
precorrin-2 + S-adenosyl methionine   precorrin-3A + S-adenosyl-L-homocysteine

From precorrin-3A to precorrin-3B
Next, the enzyme CobG transforms precorrin-3A to precorrin-3B: 
precorrin-3A + NADH + H+ + O2  precorrin-3B + NAD+ + H2O
This enzyme is an oxidoreductase that requires oxygen and hence the reaction can only operate under aerobic conditions. The naming of these precorrins as 3A and 3B reflects the fact that each contains three more methyl groups than uroporphyrinogen III but with different structures: in particular, precorrin-3B has an internal γ-lactone ring formed from the ring A acetic acid sidechain closing back on to the macrocycle. From precorrin-3B to precorrin-4
The enzyme CobJ continues the theme of methyl group insertion. Importantly, during this step the macrocycle ring-contracts so that the product contains for the first time the corrin core which characterises cobalamin. precorrin-3B + S-adenosyl methionine   precorrin-4 + S-adenosyl-L-homocysteine

From precorrin-4 to precorrin-5
Methyl group insertions continue as the enzyme CobM acts on precorrin-4:
precorrin-4 + S-adenosyl methionine  precorrin-5 + S-adenosyl-L-homocysteine
The newly-inserted methyl group is added to ring C at the carbon attached to the methylene (CH2) bridge to ring B. This is not its final location on cobalamin as a later step involves its rearrangement to an adjacent ring carbon. From precorrin-5 to precorrin-6A
The enzyme CobF now removes the acetyl group located at position 1 of the ring system in precorrin-4 and replaces it with a newly-introduced methyl group. The name of the product,  precorrin-6A, reflects the fact that six methyl groups in total have been added to uroporphyrinogen III up to this point. However, since one of these has been extruded with the acetate group, the structure of precorrin-6A contains just the remaining five. precorrin-5 + S-adenosyl methionine + H2O  precorrin-6A + S-adenosyl-L-homocysteine + acetate

From precorrin-6A to precorrin-6B
The enzyme CobK now reduces a double bond in ring D using NADPH:
precorrin-6A + NADPH + H+  precorrin-6B + NADP+
Precorrin-6B therefore differs in structure from precorrin-6A only by having an extra two hydrogen atoms. From precorrin-6B to precorrin-8
The enzyme CobL has two active sites, one catalysing two methyl group additions and the other the decarboxylation of the CH2COOH group on ring D, so that this substituent becomes a simple methyl group:

precorrin-6B + 2 S-adenosyl methionine  precorrin-8X + 2 S-adenosyl-L-homocysteine + CO2

From precorrin-8 to hydrogenobyrinic acid
The enzyme CobH catalyzes a rearrangement reaction, with the result that the methyl group that had been added to ring C is isomerised to its final location, an example of intramolecular transfer:
precorrin-8X  hydrogenobyrinate

From hydrogenobyrinic acid to hydrogenobyrinic acid a,c-diamide
The next enzyme in the pathway, CobB, selectively converts two of the eight carboxylic acid groups into their primary amides. ATP is used to provide the energy for amide bond formation, with the transferred ammonia coming from glutamine:
hydrogenobyrinic acid + 2 ATP + 2 glutamine + 2 H2O  hydrogenobyrinic acid a,c-diamide + 2 ADP + 2 phosphate + 2 glutamic acid

From hydrogenobyrinic acid a,c-diamide to  acid a,c-diamide
Cobalt(II) insertion into the macrocycle is catalysed by the enzyme Cobalt chelatase (CobNST):
hydrogenobyrinic acid a,c-diamide + Co2+ + ATP + H2O    acid a,c-diamide + ADP + phosphate + H+
It is at this stage that the aerobic pathway and the anaerobic pathway merge, with later steps being chemically identical. Detail of steps from uroporphyrinogen III to  a,c-diamide in anaerobic organisms
Many of the steps beyond uroporphyrinogen III in anaerobic organisms such as Bacillus megaterium involve chemically similar but genetically distinct transformations to those in the aerobic pathway. From precorrin-2 to cobalt-sirohydrochlorin
The key difference in the pathways is that cobalt is inserted early in anaerobic organisms by first oxidising precorrin-2 to its fully aromatised form sirohydrochlorin and then to that compound's cobalt(II) complex. These reactions are catalysed by CysG and Sirohydrochlorin cobaltochelatase. From cobalt-sirohydrochlorin to cobalt-factor III
As in the aerobic pathway, the third methyl group is introduced by a methyltransferase enzyme, CbiL:
cobalt-sirohydrochlorin + S-adenosyl methionine   cobalt-factor III + S-adenosyl-L-homocysteine

From cobalt-factor III to cobalt-precorrin-4
Methylation and ring contraction to form the corrin macrocycle occurs next, catalysed by the enzyme Cobalt-factor III methyltransferase (CbiH, )

cobalt-factor III + S-adenosyl methionine   cobalt-precorrin-4 + S-adenosyl-L-homocysteine
In this pathway, the resulting material contains a δ-lactone, a six-membered ring, rather than the γ-lactone (five-membered ring) of precorrin-3B. From cobalt-precorrin-4 to cobalt-precorrin-5A
The introduction of the methyl group at C-11 in the next step is catalysed by Cobalt-precorrin-4 methyltransferase (CbiF, )
cobalt-precorrin-4 + S-adenosyl methionine   cobalt-precorrin-5 + S-adenosyl-L-homocysteine

From cobalt-precorrin-5A to cobalt-precorrin-5B
The scene is now set for the extrusion of the two-carbon fragment corresponding to the acetate released in the formation of precorrin-6A in the aerobic pathway. In this case the fragment released is acetaldehyde and this is catalysed by CbiG:
 cobalt-precorrin-5A + H2O  cobalt-precorrin-5B + acetaldehyde + 2 H+

From cobalt-precorrin-5B to  acid a,c-diamide
The steps from cobalt-precorrin-5B to  acid a,c-diamide in the anaerobic pathway are essentially chemically identical to those in the aerobic sequence. The intermediates are called cobalt-precorrin-6A, cobalt-precorrin-6B, cobalt-precorrin-8 and cobyrinic acid. The enzymes in sequence are CbiD; Cobalt-precorrin-6A reductase (CbiJ, ); CbiT, Cobalt-precorrin-8 methylmutase (CbiC, ) and CbiA. The final enzyme forms  acid a,c-diamide as the two pathways converge. Detail of steps from  acid a,c-diamide to adenosylcobalamin
Aerobic and anaerobic organisms share the same chemical pathway beyond  acid a,c-diamide and this is illustrated for the cob gene products. From  acid a,c-diamide to adenosylcobyric acid
The cobalt(II) is reduced to  by the enzyme CobR and then the enzyme CobO attaches an adenosyl ligand to the metal. Next, the enzyme CobQ converts all the carboxylic acids, except the propionic acid on ring D, to their primary amides. From adenosylcobyric acid to adenosylcobinamide phosphate
In aerobic organisms, the enzyme CobCD now attaches (R)-1-amino-2-propanol (derived from threonine) to the propionic acid, forming adenosylcobinamide and the enzyme CobU phosphorylates the terminal hydroxy group to form adenosylcobinamide phosphate. The same final product is formed in anaerobic organisms by direct reaction of adenosylcobyric acid with (R)-1-amino-2-propanol O-2-phosphate (derived from threonine-O-phosphate by the enzyme CobD) catalysed by the enzyme CbiB. From adenosylcobinamide phosphate to adenosylcobalamin
In a separate branch of the pathway, 5,6-dimethylbenzimidazole is biosynthesised from flavin mononucleotide by the enzyme 5,6-dimethylbenzimidazole synthase and converted by CobT to alpha-ribazole 5' phosphate. Then the enzyme CobU activates adenosylcobinamide phosphate by formation of adenosylcobinamide-GDP and CobV links the two substrates to form Adenosylcobalamin-5'-phosphate. In the final step to the coenzyme, CobC removes the 5' phosphate group:
Adenosylcobalamin-5'-phosphate + H2O  adenosylcobalamin + phosphate
The complete biosynthetic route involves a long linear path that requires about 25 contributing enzyme steps. Other pathways of cobalamin metabolism

Salvage pathways in prokaryotes
Many prokaryotic species cannot biosynthesize adenosylcobalamin, but can make it from cobalamin. These organisms are capable of cobalamin transport into the cell and its conversion to the required coenzyme form. Even organisms such as Salmonella typhimurium that can make cobalamin also assimilate it from external sources when available. Uptake into cells is facilitated by ABC transporters which absorb the cobalamin through the cell membrane. Cobalamin metabolism in humans

In humans, dietary sources of cobalamin are bound after ingestion as transcobalamins. They are then converted to the coenzyme forms in which they are used. Methylmalonic aciduria and homocystinuria type C protein is the enzyme which catalyzes the decyanation of cyanocobalamin as well as the dealkylation of alkylcobalamins including methylcobalamin and adenosylcobalamin. Further reading

References

External links 
 Prof Sir Alan Battersby: the biosynthesis of Vitamin B12 St. Catharine's College, Cambridge, video

Protein families
Vitamin B12
Biosynthesis