This happened to me a lot of times! It is possible to clean it out! The only thing that you can do is never use the Pokeballs again and then after a while, it may go away. That happened to me a about 10 times. If it doesn't go away, you can trade all of your Pokemon into a different Ruby or Sapphire from your glitched up Ruby and the start new game in it and trade the Pokemon back. The won't have the virus! If you don't have another Ruby or Sapphire, you have no choice but to restart.
EDIT: When it gets glitchy, are there any weirdo symbols? If there are, I know the problem. You turned on more than 10 codes on your Action Replay. You can only turn on less than 5 codes at a time. Once you use an Action Replay on your game, You must check for any glitches before saving your game. To clean this problem, you must turn on all of the Item Codes in your AR and check if it is cleaned. If not, your game is ruined forever.
The bad thing is that AR can glitch your game. Unless you have PAR (Pro Action Replay), that glitch can be fixed. But for now, if my ideas did not work, I'm not sure that you can clean the glirch out. Try my ideas and tell me how things turn out! :)
EDIT: That is not the worst glitch! The worst glitch is when you take a step and the game freezes which once happened to me! I had to start new game. With your glitch, if your that not that serious, you can simply ignore it. It wont spread. I have one question to ask you. What type of codes did you turn on when that glitch happened? Maybe if you tell me, I may have a solution to your glitch problem! Thank You :)