Electronic structure and optical properties of quantum crystals from first principles calculations in the Born–Oppenheimer approximation