A multi-scale examination of protein surface layer assembly and function in bacteria and archaea