Correlation of the chemical properties of carbon nanotubes with their atomic and electronic structures