A thermodynamic matcher (TDM) is a specialized RNA folding program. Instead of spanning the complete search space of general RNA folding, a TDM spans only a defined subset of it. This subset might be defined via a graphical description (see Locomotif: From Graphical Motif Description to RNA Motif Search) or via a shape string (see Faster computation of exact RNA shape probabilities).

"Grammars/gra_tdm.gap" is for the later one. Given a shape string of a specific shape level, we have to generate a specialized grammar out of one of the four prototype grammars Grammars/gra_nodangle.gap Grammars/gra_overdangle.gap Grammars/gra_microstate.gap or Grammars/gra_macrostate.gap. This process itself is done with a GAP-L program. So one could say a GAP program generates a GAP program. Due to modularity it only generates the grammar, algebras, signatures and instances could simply be re-used.

Actually, "Grammars/gra_tdm.gap" is not a single grammar, but six of them. They all use Signatures/sig_tdm.gap, but not all functions in all shape levels or with all prototype grammars.