As the Giro d'Italia bicycle race sets off in Ireland this weekend, the shadow of doping will not be far behind. In a competition to beat the cheaters, scientists are constantly trying to improve drug testing.

While it can be hard for regulators to keep up with new habits, when an athlete is finally caught doping, the result can be revolutionary.

Performance-enhancing drugs have plagued the sport of cycling for years, with Lance Armstrong at the center of the scandal. But he was not alone.

From 1998 to 2001, Tyler Hamilton was Lance Armstrong's trusted lieutenant on the U.S. Postal Service team, and a member of Armstrong's inner circle.

Hamilton says that for the first two-and-a-half years of his professional career, he raced clean. But a grueling ride in Southern Spain had taken everything out of him. Lying exhausted on his hotel bed, a team doctor offered him something.

"He was concerned, sympathetic, almost fatherly," Hamilton tells NPR's Arun Rath. "He was wearing this fly fishing vest and pulled out a little red egg-shaped capsule, and there it was — a little pill of testosterone."

Hamilton swallowed it, and everything changed.

"Within a couple years, I was up to my neck in doping," he says.

The Doping Arms Race

Not far from the Santa Monica Pier in Los Angeles is the biggest anti-doping lab in the world. The Olympic Analytical Laboratory at the University of California, Los Angeles, performs drug tests for the Olympics, the NBA, MLB, NFL, the NCAA and many other clients who come to them as needed.

"We probably have more urine than anyone in the world," says director Anthony Butch.

The lab tests more than 40,000 samples each year and is packed with millions of dollars' worth of the most cutting-edge scientific gear in existence. They also employ more than 40 top-level scientists to go with it.

There are no signs outside to mark this amazing facility. They prefer to keep it nondescript, because they're developing the latest weapons in what many people call an arms race.

Boxes arrive with glass vials of urine samples from around the world. As the boxes pass through the building, every set of hands they pass through are logged. Like with police evidence, maintaining the chain of custody is essential for security. The samples are wheeled back to the lab where scientists store them in giant refrigerators. The bottles are impenetrable; the only way to open them is to use a machine that cracks the lid.

Just as cyclists like Armstrong and Hamilton were able to keep ahead of the tests for so long, Butch says it's only a matter of time before something new slips by undetected. It can be hard to have a sense if they're winning the war or not.

"If you're a pessimist, you probably believe everybody's doping and nobody's getting caught. Because the positive rate is very, very low," he says. "If you're an optimist, you think that very few people are doping and we're catching them all."

Butch says he falls somewhere in between. He thinks that they are catching some of athletes, but that others are using compounds that the lab can't currently catch. He says every new drug that comes on the scene requires developing a new test, giving athletes who dope a window of opportunity.

"[It] constantly seems like we're running behind the athletes to catch them," he says. "We're getting closer to them. As they change their doping patterns, we can detect lower concentrations, [and] I think we're picking up more cheaters."

The problem, Butch says, is that as new compounds come out, some are extremely difficult to detect, even if you have the technology. For example, there are drugs that stimulate the athlete's pituitary gland to produce more growth hormone.

"These have a very, very short half-life — in the order of minutes," he says. This makes the drug almost impossible to detect. The window for testing is there, he says, but it is getting smaller and smaller as the drugs get more sophisticated.

Testing At The Genetic Level

To latest weapon in the doping wars is being developed by Yannis Pitsiladis, a professor of sport and exercise science at the University of Brighton in the U.K. Instead of looking for drugs in blood, he's looking for the fingerprints that substances leave behind at the cellular level.

With research supported by the World Anti-Doping Agency, Pitsiladis looks at the evidence of doping in the genetic sequence of RNA, the partner of DNA.

"It's at the highest level of sensitivity. Because what we're looking at is the switching on and switching off of genes as a result of taking a particular drug," Pitsiladis says.

Pitsiladis says they develop a genetic profile, or signature, of a particular drug by taking test subjects, typically athletes not currently competing, and administering the drug to them in a controlled environment. They then analyze which genes are being affected by a drug, and use that to create its genetic footprint.

Pitsiladis says that if everything goes as planned, his test will be ready in a year and a half. He says the beauty of this genetic approach is that it is almost un-cheatable because of the number of genes that the drugs affect.

"There are just far too many genes to try and manipulate, and if you ended up trying to do that, you'll probably end up killing yourself," he says.

'Killing Me From The Inside'

Tyler Hamilton knows all about the race to stay ahead of testing technology. He was winning for a while.

When he began doping, Hamilton was taking EPO, a synthetic form of a hormone that stimulates the creation of red blood cells. Having more red blood cells means more oxygen in the blood and more endurance.

The drug allowed athletes to train harder and longer. In a race like the Tour de France, it was an absolute game changer, Hamilton says.

During this time, Hamilton was passing doping tests. But then tests became more thorough, including tests for EPO. "When we heard that, the doctors came up with a new plan: blood doping," he says.

Blood doping involves athletes taking their own blood or someone else's blood, storing it and then re-injecting it during an event. The action provides a boost of red blood cells, which is great for endurance sports. Hamilton says the U.S. Postal team had its own blood-doping doctor. Ten days into the 2000 Tour de France, they met the doctor in a hotel room.

"He'd put one of those big extraction needles into your arm and fill you back up, so to speak," he says. Typically it would be almost a half-liter of blood injected, he says.

Once, Hamilton accidentally re-infused bad blood, basically giving himself blood poisoning. He had a horrendous fever, and his urine turned black. There was pressure to win and money at stake.

"We created a monster and then ... [the] pressure just got bigger and bigger," he says.

It finally caught up with him when, in 2004, Hamilton tested positive. He was suspended for two years, then returned to racing. After testing positive for a banned substance in 2009, he finally retired.

In 2010, the U.S. government opened a grand jury investigation into Armstrong and the U.S. Postal team.

Witnesses were subpoenaed, including Hamilton, who spent hours on the stand confessing to everything. He says he was told to "tell the truth or go to jail." Hamilton picked the former. He says it was the best thing that ever happened to him.

Copyright 2016 NPR. To see more, visit http://www.npr.org/.