  We calculate the torus partition sum of a general $CFT_2$ with left and right
moving conserved currents $J$ and $\bar J$, perturbed by a combination of the
irrelevant operators $T\bar T$, $J\bar T$ and $T\bar J$. We use string theory
techniques to write it as an integral transform of the partition sum of the
unperturbed CFT with chemical potentials for the left and right moving
conserved charges. The resulting expression transforms in the right way under
the modular group, and reproduces the known spectrum of these models. We also
derive a formula for the partition function of deformed $CFT_2$ with
non-vanishing chemical potential.
