A flexible particle Markov chain Monte Carlo method