Origin and evolution of metabolic pathways