Will you please remind me the command or tool to calculate the average B factor for the whole protein or a fragment of the whole protein?

phenix.refine log file has it. Also, phenix.model_vs_data outputs it. Also, model_statistics=true of phenix.pdbtools will give it to you.

Pavel