A General Method for Calculating Likelihoods Under the Coalescent Process