The recombination-activating genes (RAGs) encode enzymes that play an important role in the rearrangement and recombination of the genes of immunoglobulin and T cell receptor molecules during the process of VDJ recombination. There are two recombination-activating gene products known as RAG-1 and RAG-2, whose cellular expression is restricted to lymphocytes during their developmental stages. RAG-1 and RAG-2 are essential to the generation of mature B and T lymphocytes, two cell types that are crucial components of the adaptive immune system.
In the vertebrate immune system, each antibody is customized to attack one particular antigen (foreign proteins and carbohydrates) without attacking the body itself. The human genome has at most 30,000 genes, and yet it generates millions of different antibodies, which allows it to be able to respond to invasion from millions of different antigens. The immune system generates this diversity of antibodies by shuffling, cutting and recombining a few hundred genes (the VDJ genes) to create millions of permutations, in a process called VDJ recombination. RAG-1 and RAG-2 are proteins at the ends of VDJ genes that separate, shuffle, and rejoin the VDJ genes. This shuffling takes place inside B cells and T cells during their maturation.
RAG enzymes work as a multi-subunit complex to induce cleavage of a single double stranded DNA (dsDNA) molecule between the antigenreceptor coding segment and a flanking recombination signal sequence (RSS). They do this in two steps. They initially introduce a ‘nick’ in the 5' (upstream) end of the RSS heptamer (a conserved region of 7 nucleotides) that is adjacent to the coding sequence, leaving behind a specific biochemical structure on this region of DNA: a 3'-hydroxyl (OH) group at the coding end and a 5'-phosphate (PO4) group at the RSS end. The next step couples these chemical groups, binding the OH-group (on the coding end) to the PO4-group (that is sitting between the RSS and the gene segment on the opposite strand). This produces a 5'-phosphorylated double-stranded break at the RSS and a covalently closed hairpin at the coding end. The RAG proteins remain at these junctions until other enzymes repair the DNA breaks.
The RAG proteins initiate V(D)J recombination, which is essential for the maturation of pre-B and pre-T cells. Activated mature B cells also possess two other remarkable, RAG-independent phenomena of manipulating their own DNA: so-called class-switch recombination (AKA isotype switching) and somatic hypermutation (AKA affinity maturation).
As with many enzymes, RAG proteins are fairly large. For example, mouse RAG-1 contains 1040 amino acids and mouse RAG-2 contains 527 amino acids. The enzymatic activity of the RAG proteins is concentrated largely in a core region; Residues 384–1008 of RAG-1 and residues 1–387 of RAG-2 retain most of the DNA cleavage activity. The RAG-1 core contains three acidic residues (D600, D708, and E962) in what is called the DDE motif, the major active site for DNA cleavage. These residues are critical for nicking the DNA strand and for forming the DNA hairpin. Residues 384–454 of RAG-1 comprise a nonamer-binding region (NBR) that specifically binds the conserved nonomer (9 nucleotides) of the RSS and the central domain (amino acids 528–760) of RAG-1 binds specifically to the RSS heptamer. The core region of RAG-2 is predicted to form a six-bladed beta-propeller structure that appears less specific than RAG-1 for its target.
Based on core sequence homology, it is believed that the RAG-1 protein evolved from a transposon of the Transib superfamily. Although the transposon origins of these genes are well-established, there is still no consensus on when the ancestral RAG1/2 became present in the vertebrate genome. Because agnathans lack a core RAG1 element, it was traditionally assumed that RAG1 invaded after the agnathan/gnathastome split 1001 to 590 million years ago (MYA). However, recently the core sequence of RAG1 has been identified in the echinoderm Strongylocentrotus purpuratus (purple star fish)  and in the amphioxi Brachiostoma floridae (Florida lancelet). These findings indicate RAG1 may have invaded much earlier in evolutionary history than previously thought. Based on current evidence it is not clear whether RAG1 invaded in a very early ancestor of all deuterostomia (approx. 896 MYA) and was later lost in agnathans, or if RAG1 may have possibly invaded the genome multiple times  It should also be noted that RAG1/2 is only found in gnathostomes, and not in agnathans. It is currently hypothesized that the invasion of RAG1/2 is the most important evolutionary event in terms of shaping the gnathostomeadaptive immune system vs. the agnathan variable lymphocyte receptor system.
De, Pallabi; Rodgers, Karla K. (August 2004). "Putting the pieces together: identification and characterization of structural domains in the V(D)J recombination protein RAG1". Immunol. Rev.200: 70–82. doi:10.1111/j.0105-2896.2004.00154.x. PMID15242397.