Mechanisms for establishing primary and secondary endosymbiosis in Paramecium