A recent study published in the journal Genome Research Dr. Laverty and colleagues out of the University of Toronto suggests that the molecules delta9-tetrahydrocannabinol (THC) and cannabidiol (CBC) may have come from a virus that infected the cannabis plant several millions of years ago. The scientists published a full map of the cannabis genome. They found some interesting results. It turns out that the genes that encode for THC and CBD production evolved thanks to bits of DNA introduced by viruses that infected the plant and successfully colonized its genome millions of years ago.
Many of the major cannabinoids have pharmaceutical and psychoactive properties. But the endocannabinoid system (ECS) is also made up of enzymes designed to denigrate endocannabinoids such as anandamide and 2-AG. These enzymes, THCAS and CBDAS, are closely linked on the chromosome. This model was derived from the discovery of a THCAS-like gene in hemp plants. The genetic code for these enzymes is on a strand of DNA that is surrounded by junk DNA that scientists call "retrotransposons". These retrotransposons, the study says, came from viruses.
Cannabis, like most plants and animals, is also subject to viral infection. Over a million years the Cannabis plant evolved, and the constant viral infections could have weaved some of its genetic material into the plant. This DNA seems to code for these particular enzymes, THCAS and CBDAS.
This type of incorporation of genetic material into another species genome is not new. Bacteria have been doing it for millennia using the famous CRISPR-cas9 of selecting out particular genes and then keeping them for themselves. It acts as a sort of immune memory. Mitochondria are another example, where an entire cell incorporated a complete organelle for faster energy creation.
The genes that produce THC and CBD came from a single gene, and the viral retrotransposons, as they jumped around and expanded, drove the mutation of the synthase gene sequences in different cannabis strains, spurring the divergence of the gene into THCA (producing THC) in marijuana, and CBDA (producing CBD) in hemp.
So, to be clear, there are not viruses in marijuana that may pass to you, and you will not pick up any viral genes from it. You will not get infected from smoking pot. This is just another example of how species can interact to form something new.