  Biological systems have evolved to amazingly complex states, yet we do not
understand in general how evolution operates to generate increasing genetic and
functional complexity. Molecular recognition sites are short genome segments or
peptides binding a cognate recognition target of sufficient sequence
similarity. Such sites are simple, ubiquitous modules of sequence information,
cellular function, and evolution. Here we show that recognition sites, if
coupled to a time-dependent target, can rapidly evolve to complex states with
larger code length and smaller coding density than sites recognising a static
target. The underlying fitness model contains selection for recognition, which
depends on the sequence similarity between site and target, and a uniform cost
per unit of code length. Site sequences are shown to evolve in a specific
adaptive ratchet, which produces selection of different strength for code
extensions and compressions. Ratchet evolution increases the adaptive width of
evolved sites, accelerating the adaptation to moving targets and facilitating
refinement and innovation of recognition functions. We apply these results to
the recognition of fast-evolving antigens by the human immune system. Our
analysis shows how molecular complexity can evolve as a collateral to selection
for function in a dynamic environment.
