Genes are the functional segments of DNA. They are the smallest units of DNA which are capable of performing an independent function. The main function of DNA at a molecular level is the production of mRNA (messenger RNA) which ultimately signals the ribosomes to form proteins.