Energetics and electronic structure of semiconducting single-walled carbon nanotubes adsorbed on metal surfaces