Nitrogen-substituted nanotubes and nanojunctions: Conformation and electronic properties