The immune system protects organisms from infection with layered defenses of increasing specificity. In simple terms, physical barriers prevent pathogens such as bacteria and viruses from entering the organism. If a pathogen breaches these barriers, the innate immune system provides an immediate, but non-specific response. Innate immune systems are found in all plants and animals. If pathogens successfully evade the innate response, vertebrates possess a second layer of protection, the adaptive immune system, which is activated by the innate response. Here, the immune system adapts its response during an infection to improve its recognition of the pathogen. This improved response is then retained after the pathogen has been eliminated, in the form of an immunological memory, and allows the adaptive immune system to mount faster and stronger attacks each time this pathogen is encountered.

immuunsysteem
A scanning electron microscope image of a single neutrophil1 (yellow), engulfing anthrax bacteria (Bacillus anthracis2; orange).

Assignment

Define a class Organism that can be used to represent organisms that have a simplified model of an immune system. This immune system has both innate and adaptive properties that protect the organism against viruses — other kinds of pathogens are ignored in this exercise for the sake of simplicity. A certain type of virus is represented in this model as an integer. The innate component of the immune system protects the organism against a given series of virus types. In addition, over time the adaptive component of the immune system can make the organism resistant for other virus types. The latter happens if sufficient antibodies for a particular virus type have been formed. When a certain type of virus mutates, the organism looses its resistance (both innate and adaptive) against the old form of the virus, and if necessary, should start making new antibodies against the new form of the virus. The class Organism must support at least the following methods:

Example

In the following interactive session we assume that the text file immune_system.txt3 is located in the current directory. This file has five lines containing the integers 1, 2, 3, 4 and 5.

>>> organism = Organism('immune_system.txt4')
>>> organism.isresistant(1)
True
>>> organism.isresistant(88)
False
>>> organism.isresistant(virus=99)
False
>>> organism.isresistant(2)
True
>>> organism.isresistant(virus=99)
False
>>> organism.isresistant(virus=99)
True
>>> organism.isresistant(virus=99)
True
>>> organism.mutation(virus=1)
>>> organism.isresistant(virus=1)
False
>>> organism.isresistant(virus=1)
False
>>> organism.isresistant(virus=1)
True
>>> organism.mutation(virus=99)
>>> organism.isresistant(virus=99)
False
>>> organism.isresistant(virus=99)
False
>>> organism.isresistant(virus=99)
True