Scientists have transformed a common bacterial cell into a psychedelic "drug factory" capable of pumping out copious quantities of psilocybin, the chemical famously found in " magic mushrooms ," according to a new study.

Psilocybin can be found in more than 100 'shroom species, most notably in one called Psilocybe cubensis, which has a domed cap and skinny stem. Although best known for inducing mind-bending hallucinations, psilocybin is currently being tested as a potential treatment for several psychiatric conditions, including addiction, major depressive disorder and post-traumatic stress disorder, according to ClinicalTrials.gov . If 'shroom-based drugs ever come to market, scientists will need a better method for harvesting psilocybin than farming tons of fungi, the authors said.

So, the researchers turned to bacteria, which can be engineered to churn out chemicals in high amounts. Some medications — including the hormone insulin — are already produced with the help of genetically engineered bacteria.

In the new study, the Miami University, researchers manipulated the metabolism of the bacteria Escherichia coli, so that its cells began producing psilocybin.Later, the research team scaled up production to brew the hallucinogen in huge batches, according to a statement from the university.

Related: Trippy Tales: The History of 8 Hallucinogens

"We are taking the DNA from the mushroom that encodes its ability to make this product and putting it in E. coli," study co-author Andrew Jones, a professor of chemical and biological engineering, said in the statement. The team developed multiple strains of psychedelic E. coli and tested what environmental conditions — temperature, nutrients, culture medium — were required to consistently produce high concentrations of psilocybin with few unwanted side products. The team eventually selected the most efficient strain , dubbed pPsilo16, and cultivated it in a bioreactor for mass production, according to the study, published online Sept. 21 by the journal Metabolic Engineering .

"What's exciting is the speed at which we were able to achieve our high production," Jones said. Over the course of the 18-month-long study, the researchers were able to increase production by 500-fold.

According to the authors, their E. coli produced more psilocybin than any other organism retrofitted with "magic mushroom" DNA to date. The scientists assert that their results provide compelling evidence that psilocybin could be produced on an industrial scale for use in psychiatric medications .