Convert Text to a DNA Sequence with Python


Before the text is mapped to a nucleotide sequence, it must be converted to a binary sequence. In digital electronics, binary sequences represent instructions to the computer and types of data using bits and bytes. Binary digits, or bits, store either 0 or 1, rendering them the smallest units of storage. 8 bits grouped together make a byte, such as 01011010 and 01000001. — Annotated by me


At first, I set a variable (original_str) with the user’s input. The text can vary in length and content; it’s all up to the user.


Next, this program could convert documents, pictures and videos to a binary sequence and thus, a nucleotide sequence. By including more than just text, different types of information can be encoded and stored in DNA. Also, a file including the resulting sequence could be downloaded to be used for in silico analyses with computational and statistical techniques. — Another way to encode characters in the English alphabet with codons



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store