First principles and atomistic calculation of the magnetic anisotropy of Y2Fe14B