Predict the residue type of a spin system and the optimal arrangement of residue types