As the use of the computer is popularized, the damage from computer viruses and hacking by malicious users is increasing rapidly. To block the hacking that is an intrusion into a person's computer, and the viruses that destroy data, a study into an intrusion detection and virus detection system based on the biological immune system is in progress. In this article, we describe a model of positive and negative selection for self-recognition, which has a similar function to the cytotoxic T cells that play an important role in the biological immune system. We propose a self/nonself discrimination algorithm for a computer system, which will the important when we detect data infected by a computer virus, of data modified by an intrusion from outside. We also show the validity and effectiveness of the proposed self-recognition algorithm by a computer simulation of some infected data obtained from cell changes and string changes in the self-file.