Humans have been turning to the poppy plant to get high or relieve pain for thousands of years. And despite all our other staggering pharmaceutical progress, our reliance on the plant hasn't changed much; poppies are used to make two of the world's most widely used painkillers, morphine and codeine, and the cough suppressant noscapine.

But how did the opium poppy plant (Papaver somniferum) get its pain-relieving properties to begin with?

A team of researchers in the United Kingdom, China and Australia has been digging into this question for the past several years, examining the opium poppy genome to figure out how this plant developed its unusually potent and useful therapeutic properties. Now, a new study, published today (Aug. 30) in the journal Science, details the majority of the opium poppy genome. The study highlights when and how the key pharmaceutical-producing genes came into play. [10 Interesting Facts About Heroin]

The task was difficult, thanks to the plant's abundance of genetic material that contains several repeated sections. Still, piecing together the genome was helpful for tracking the opium poppy's development.

The first important poppy genetic event, the researchers found, took place about 110 million years ago. That was when the entire genome, or at least very large chunks of it, duplicated. This isn't unusual for angiosperms, the category of flowering plants that includes poppies. But the duplication can be consequential. When organisms have double the genetic material, one half of the genome is free to evolve, while the other half remains stable, said study co-author Ian Graham, a biomedical genetics professor at the University of York in the United Kingdom.

In the case of poppies, that extra genetic material evolved in one very important way, the researchers found: More than 7.8 million years ago, two genes fused and became the single gene responsible for poppy's morphine and codeine production. This "megagene" codes for an enzyme that converts a precursor poppy molecule into the compounds that eventually become codeine and morphine. Without it, poppies would just transform that same precursor molecule into the compound noscapine, and the plants wouldn't be painkillers.

To Graham, this is one of the most important finds in their research. "It's really satisfying to know how that gene has arisen," he told Live Science.

After that gene fusion, the poppy genome replicated again and lost some pieces, the study found. But the megagene crucial for forming opiatesstuck around. Like with most useful genes, odds are that this gene was a random mutation that kept getting passed on because it was useful to the plant. It's not totally clear to biologists why opium poppies kept their morphine- and codeine-producing skills around, but it's likely because the chemicals ward off hungry herbivores, Graham said.

Some other poppy mysteries remain to be solved, too. For example, the other enzymes involved in producing morphine and codeine probably appeared earlier than the megagene's arrival 7.8 million years ago, though the research team doesn't know when exactly. (In other words, the megagene isn't the only player involved in painkiller production in poppies.) Graham said that he also hopes to study the genomes of related plant species to see why some of them do or don't make narcotics.

But for now, deducing how poppies got their medicinal qualities, and what the genome looks like, is enough to help the painkiller industry, Graham said. (Despite abuse of opioids, there's still a need for quality painkillers and palliative care drugs, he added.) Even though horticulturalists have developed hyper-specific strains that mostly produce the opiates or noscapine, opium poppy growers are always looking for ways to make production more sustainable and cost-effective, he said.

And like any other crop, there might be room for genetic modifications to make the poppies produce more of the pharmaceutical agents, grow faster or withstand infection. "Genome analysis provides us with a platform to do all of that more effectively," Graham said.

Originally published on Live Science.