Atomic structure and electronic properties of single-walled carbon nanotubes