Effective interaction for 1P shell nuclei calculated from the Hamada-Johnston potential