What if you could design a drug that has all the pain-relieving power of morphine but none of its dangerous or addictive side effects?

Scientists have spent years trying to do just that, and on Wednesday, they unveiled one of their most promising compounds yet – a chemical concoction they dubbed “PZM21.”

When tested in mice that were placed on a hot surface, PZM21 offered nearly as much pain relief as morphine and lasted for up to three hours. That’s “substantially longer” than morphine or other experimental drugs, the scientists wrote in the journal Nature.

Mice treated with PZM21 did not find it addictive, as evidenced by the fact that they were no more likely to return to a place where they got the drug than to visit a similar chamber where they could get a saline solution. Plus, while the animals became hyperactive after a dose of morphine – considered a sign of the drug’s addictive power – they remained perfectly calm after getting a comparable dose of PZM21.

They also were less constipated, a side effect of opioid drugs.

But the drug isn’t perfect. Like morphine and other opioids, PZM21 caused mice to slow their breathing to dangerously low levels. However, their breathing improved before the drug’s painkilling properties wore off. That’s in contrast to morphine, which continues to cause respiratory depression even after it allows pain to return.

The researchers, led by Dr. Aashish Manglik of the Stanford University School of Medicine and Henry Lin of UC San Francisco, found their way to PZM21 by searching for a compound that would precisely fit a specific type of opioid receptor in the brain and spinal cord. They used powerful computers to test more than 3 million compounds, each in an average of 1.3 million configurations.

The top 2,500 contenders – representing 0.08 percent of the possible candidates – were checked manually. Among these, 23 were selected for further testing, of which seven were deemed most promising. The researchers then tested 500 analogs of three of them and narrowed the field to 15, then seven, then finally one.

But they weren’t done. They tweaked this compound, rearranging the atoms in the molecule to get the best possible fit. Their creation was PZM21.

In the tests with mice, the higher the dose of PZM21, the more pain relief they felt. Ultimately, the compound ameliorated 87 percent of their pain, compared with 92 percent for morphine, according to the study.

Although their computer-assisted approach wasn’t able to find the optimal drug – one that had no effect on breathing – it did allow the researchers to create something that is tantalizingly close.

The need for such a drug is clear. According to the Centers for Disease Control and Prevention, sales of prescription opioids like morphine, OxyContin and Vicodin have quadrupled since 1999, and so has the number of overdose deaths. By 2014, the number of annual overdose deaths in America reached 14,000.