Patterns of genetic variation in populations of infectious agents