A quantum gate between a flying optical photon and a single trapped atom