Molecules with hyperfine splitting of their rotational line spectra are useful probes of optical depth, via the relative line strengths of their hyperfine components. The hyperfine splitting is particularly advantageous in interpreting the physical conditions of the emitting gas because with a second rotational transition, both gas density and temperature can be derived. For HCN however, the relative strengths of the hyperfine lines are anomalous. They appear in ratios which can vary significantly from source to source, and are inconsistent with local thermodynamic equilibrium (LTE). This is the HCN hyperfine anomaly, and it prevents the use of simple LTE models of HCN emission to derive reliable optical depths. In this paper, we demonstrate how to model HCN hyperfine line emission, and derive accurate line ratios, spectral line shapes and optical depths. We show that by carrying out radiative transfer calculations over each hyperfine level individually, as opposed to summing them over each rotational level, the anomalous hyperfine emission emerges naturally. To do this requires not only accurate radiative rates between hyperfine states, but also accurate collisional rates. We investigate the effects of different sets of hyperfine collisional rates, derived via the proportional method and through direct recoupling calculations. Through an extensive parameter sweep over typical low-mass star-forming conditions, we show the HCN line ratios to be highly variable to optical depth. We also reproduce an observed effect whereby the red-blue asymmetry of the hyperfine lines (an infall signature) switches sense within a single rotational transition.