A Hidden Markov model for exploring function and evolution of immunoglobulin domains