The potential of carbon nanotubes (CNTs) as nanosensors in detection of genes through a vibration analysis is investigated with molecular dynamics. The carbon nanotube based nanosensor under investigation is wrapped by a gene whose structure includes a single strand deoxyribose nucleic acid (DNA) with a certain number of distinct nucleobases. Different genes are differentiated or detected by identifying a differentiable sensitivity index that is defined to be the shifts of the resonant frequency of the nanotube. Simulation results indicate that the nanosensor is able to differentiate distinct genes, i.e., small proline-rich protein 2 A, small proline-rich protein 2B, small proline-rich protein 2D, and small proline-rich protein 2E, with a recognizable sensitivity. The research provides a rapid, effective, and practical method for detection of genes.