When this ant feels an infection coming on, it doses itself with the precise amount of medicine it needs. Only, the "pharmacy" it heads to is not exactly a clean, well-lit room.

Instead, it goes to find rotting animal carcasses, nectar or honeydew secretions from aphids. 

The ant, Formica fusca nests in soil or under rotten logs and stones. Nearby, a deadly fungus lurks. Once tiny spores of the fungus Beauveria bassiana touch the ant, they start germinating. 

These spores first secrete enzymes that dissolve the outer covering of the ant. The fungus then multiplies and feeds off the ant’s juices until it becomes a dead, fluffy ball of mould full of spores waiting to burst onto other unsuspecting critters. 

Infected ants may sound helpless, but that is not the case, according to a recent study by Nick Bos and colleagues at the University of Helsinki, Finland.

Laboratory experiments show that after getting exposed to the fungus, the ants seek out and feed on "harmful" substances, which end up killing the fungal spores and helping the ants survive.

That is, they could smell it in the food. That ants can smell their medicine is not that surprising, says Bos, lead author of the paper.

"They have an extraordinary amount of sensilla on their antennae with which they can smell an incredible amount of different substances, so it's very likely they can indeed smell the medicine," added Bos.

Such "self-medication" has been observed in other animals too, from birds, bees to lizards. Organisms can respond to infection by seeking out and consuming potentially harmful compounds to clear any disease symptoms.

The ants did exactly this, using a substance called Reactive Oxygen Species, or ROS. These molecules contain oxygen capable of suppressing infection by killing off the pathogen. While some animals can produce this themselves, the ants get it from the food they eat.

To discover this, Bos and his colleagues divided the ants into groups and exposed some of them to fungal spores. Some ants were fed with normal honey-based food, while others were fed with food supplemented with 4% hydrogen peroxide (H2O2), which is a ROS.

There is one downside, ROS is also harmful. Uninfected ants that were fed this hydrogen peroxide infused diet were more likely to die. This is to be expected, because ROS is a toxic substance that can be lethal. However, the ants that were exposed to a fungus had a higher survival rate when they ate the H2O2 rich food. 

In fact, ants infected with the fungus preferred the food supplemented with H2O2 when given a choice. This revealed that they can seek out this potentially toxic compound to "medicate".

The researchers discovered that the ants could even foresee an infection after being exposed to the fungus. In other words, they were medicating in order to protect themselves.

The ants were even smarter than that. They also moderated the amount of medicine they took in. When two options were presented they preferred a lower dosage of H2O2. A smart choice considering its toxic status. 

Jacobus De Roode from Emory University in Atlanta, US, who was not involved in the study, said: "It's a bit like us knowing the difference between light beer and a strong one." He added that the results were convincing but what ants might do in nature is another question.

Another researcher Jessica Abbot of Lund University in Sweden said: "It is amazing that the ants are able to sense concentration of hydrogen peroxide and modulate their intake, but it fits in with what we know about insects. Insects are very aware of their internal state."

The new study is published in the journal Evolution