Mapping dynamical systems into chemical reactions