An anonymous reader writes: Aside from being a schedule 1 drug, scientists haven't fully understood the chemistry behind how mushrooms produce the chemical psilocybin -- until now. A new study may finally lay the groundwork for a medical-grade psilocybin patients can take. Gizmodo reports: "Living things make molecules through a series of chemical reactions, similar to how car makers produce cars on assembly lines. Enzymes act as the workers/robots, speeding up the reactions by helping put the pieces together. Actually making psilocybin requires mapping the biological factory. A 1968 paper (obviously it was in 1968) offered a proposed order of events leading to a finished psilocybin molecule, by adding radioactive elements and watching what happened to them on the assembly line. The researchers thought that maybe tryptophan, the amino acid everyone wrongly says makes you sleepy, was the first piece, which then went through four successive steps to become the finished product. The new study shows that the 1968 paper got the order wrong, and introduces the responsible genes and enzymes, the workers that do the specific task to get the final product. This time around, mapping the factory required sequencing the genomes of two magic mushroom species, Psilocybe cubensis and Psilocybe cyanescens. Then, the researchers found exactly which genes produce the required enzymes and spliced them into E. coli bacteria. Using those enzymes, they were able to rebuild the factory and create their own psilocybin." The study has been published in the German journal Angewandte Chemie.