Resonating valence bond wave function: from lattice models to realistic systems