- Data representation, binary systems, and character encoding are fundamental concepts in computer science and bioinformatics. Biological information, including DNA sequences, RNA sequences, protein sequences, gene expression measurements, molecular structures, and genomic variants, must be represented in formats that computers can store, process, transmit, and interpret. Understanding how digital systems represent numbers, text, symbols, and biological data helps bioinformaticians work effectively with biological databases, sequence files, computational algorithms, and large-scale scientific datasets.
- Computers process information using electronic circuits that distinguish between two logical states, commonly represented as 0 and 1. These states form the basis of the binary system, which underlies digital data storage, processor instructions, file formats, and communication protocols. However, biological information is not inherently binary. DNA consists of nucleotide bases, proteins consist of amino acids, and gene expression measurements may be continuous numerical values. Computers translate these biological entities into digital representations using defined encoding schemes and data structures.
- Data representation refers to the methods used to express information in a form suitable for computational processing. The same biological information can have several representations depending on the purpose of an analysis. A DNA sequence, for example, can be represented as a text string, a numerical array, a sequence of encoded symbols, or a compact binary structure. Each representation has advantages and limitations in terms of readability, memory consumption, processing speed, and compatibility with software. Choosing an appropriate representation is therefore an important aspect of bioinformatics algorithm design and data management.
- A bit, short for binary digit, is the smallest unit of digital information and can take one of two values: 0 or 1. A group of eight bits is called a byte. Bytes are commonly used to express file sizes, memory capacity, and storage requirements, although individual bits are also important for compact data structures and low-level operations. Larger units include kilobytes, megabytes, gigabytes, and terabytes. In conventional binary-based measurement, one kibibyte (KiB) equals 1,024 bytes, one mebibyte (MiB) equals 1,024 KiB, and one gibibyte (GiB) equals 1,024 MiB. In decimal-based measurement, one kilobyte (kB) equals 1,000 bytes, one megabyte (MB) equals 1,000 kB, and one gigabyte (GB) equals 1,000 MB. Distinguishing between these units can be useful when estimating storage requirements for genomic datasets.
- The binary number system, also known as base 2, uses only the digits 0 and 1. In contrast, the decimal system, or base 10, uses ten digits from 0 to 9. In a positional number system, the value of each digit depends on its position and the base of the system. For example, the decimal number 347 represents three hundreds, four tens, and seven units. Similarly, the binary number 1011 represents one eight, zero fours, one two, and one unit.
- The decimal value of a binary number can be calculated by multiplying each binary digit by its corresponding power of two and summing the results. For example:
[
1011_2=1(2^3)+0(2^2)+1(2^1)+1(2^0)
]
[
1011_2=8+0+2+1=11_{10}
]
- Thus, the binary number 1011 represents the decimal number 11. The subscripts indicate the number system being used and prevent ambiguity when discussing numerical representations.
- Decimal numbers can be converted to binary by repeatedly dividing the decimal integer by two and recording the remainders. Reading the remainders in reverse order gives the binary representation. For example, the decimal number 13 is represented as 1101 in binary because (13=8+4+1). Understanding these conversions is useful when studying memory addresses, bitwise operations, digital storage, and the internal representation of integers.
- Binary arithmetic follows rules similar to decimal arithmetic but uses only two digits. In binary addition, (0+0=0), (0+1=1), and (1+1=10_2), which means zero with a carry of one. Binary subtraction, multiplication, and division can also be performed using base-2 rules. Although bioinformatics researchers rarely need to perform extensive binary arithmetic manually, the underlying concepts help explain how processors manipulate numerical values and how algorithms operate on encoded data.
- The octal and hexadecimal number systems are also used in computing. Octal is base 8 and uses digits from 0 to 7, whereas hexadecimal is base 16 and uses digits from 0 to 9 and letters A to F. Hexadecimal is especially convenient because each hexadecimal digit corresponds to exactly four binary bits. For example, the binary sequence 1111 corresponds to hexadecimal F, while 1010 corresponds to hexadecimal A. The binary byte 11111111 can therefore be written as FF in hexadecimal. Hexadecimal notation is commonly used for memory addresses, binary file inspection, color codes, checksums, and debugging.
- Computers must represent both integer and fractional numerical values. Unsigned integers represent nonnegative whole numbers, while signed integers can represent positive and negative values. One common method of representing signed integers is two’s complement. In an (n)-bit two’s-complement representation, the range is from (-2^{n-1}) to (2^{n-1}-1). For example, an 8-bit signed integer can represent values from −128 to 127. Unsigned 8-bit integers can represent values from 0 to 255. These ranges matter when selecting data types for biological measurements, sequence counts, indices, and encoded quality values.
- Floating-point representation is used for many non-integer numerical values, such as gene expression estimates, probabilities, molecular energies, statistical parameters, and distances. Most modern systems follow the IEEE 754 standard for common binary floating-point formats. A floating-point value is represented using a sign, a significand (also called a mantissa in common usage), and an exponent. This representation supports a wide range of magnitudes, but many decimal fractions cannot be represented exactly in binary. Consequently, calculations may introduce small rounding errors. Researchers should be aware of floating-point precision when comparing values, performing repeated numerical operations, or working with very small probabilities and large datasets.
- For example, decimal 0.1 cannot be represented exactly as a finite binary fraction. Its stored floating-point approximation may differ slightly from the mathematical value 0.1. Such differences are normally negligible in routine biological analyses, but they can matter in numerical simulations, iterative algorithms, and equality comparisons. It is generally safer to compare floating-point values using a suitable tolerance when exact equality is not mathematically guaranteed.
- Boolean data represent logical values, usually true and false. At the bit level, these can be represented by 1 and 0, although programming languages and file formats may use different storage conventions. Boolean values are important in bioinformatics for recording whether a sequence satisfies a condition, whether a variant passes a quality filter, whether a gene is expressed above a threshold, or whether a sample meets specified quality-control criteria. Logical operations such as AND, OR, and NOT allow researchers to combine multiple filtering conditions.
- Digital data are not limited to numbers. Computers also represent text, symbols, images, audio, and structured objects. Text is represented through character encoding, which maps characters to numerical code points or byte sequences according to a defined standard. Character encoding makes it possible to store and exchange DNA sequence strings, protein sequences, gene names, sample identifiers, scientific annotations, and metadata. Without a consistent encoding system, the same stored bytes could be interpreted differently by different applications, producing corrupted text or incorrect data processing.
- ASCII, the American Standard Code for Information Interchange, is an early character encoding standard that defines 128 code points, including English letters, digits, punctuation, and control characters. Standard ASCII uses seven bits per character, although it is commonly stored in one byte. For example, the uppercase letter A has decimal code point 65 and hexadecimal representation 41. The digit 0 has decimal code point 48 and hexadecimal representation 30. ASCII remains relevant because many biological sequence symbols and file-format characters belong to its character set.
- Extended character encodings historically used additional values beyond standard ASCII, but these extensions were not universally consistent. Different systems assigned different meanings to byte values above 127, creating compatibility problems when text moved between platforms. Modern software generally favors Unicode-based text handling to support a much wider range of languages and symbols.
- Unicode provides a standardized system of code points for representing characters from many writing systems, as well as mathematical symbols and other characters. A Unicode code point is commonly written in the form U+ followed by hexadecimal digits. Unicode defines the identity of a character, while a Unicode Transformation Format (UTF) specifies how that character is encoded as bytes. UTF-8, UTF-16, and UTF-32 are major Unicode encoding forms.
- UTF-8 is widely used on the internet, in programming environments, and in biological data files. It encodes Unicode characters using one to four bytes and preserves the standard ASCII byte values for the first 128 code points. This compatibility makes UTF-8 convenient for files that contain English text, nucleotide sequences, protein sequences, and multilingual annotations. UTF-16 typically uses one or two 16-bit code units for a Unicode character, while UTF-32 uses one 32-bit code unit per code point. UTF-8 is often a practical choice for bioinformatics text files because it is broadly supported and efficient for ASCII-dominated content.
- Character encoding must be distinguished from character sets, file formats, and data serialization. A character set or coded character repertoire identifies the characters available for representation, while an encoding defines how those characters are mapped to bytes. A file format specifies how information is organized within a file, and serialization defines how data structures are converted into a form suitable for storage or transmission. For example, FASTA is a biological sequence file format that uses textual headers and sequence lines. The characters in a FASTA file are typically stored using an ASCII-compatible encoding such as UTF-8, but the file format and the character encoding serve different purposes.
- Biological sequences are often represented using a restricted alphabet. DNA sequences use the four primary nucleotide symbols A, C, G, and T, while RNA sequences use A, C, G, and U. Protein sequences use single-letter amino acid symbols, with additional symbols sometimes used for ambiguous residues or special cases. These textual representations are easy to read and exchange, but they are not necessarily the most memory-efficient representation for computational processing.
- A DNA sequence containing only the four canonical bases requires just two bits per nucleotide in an ideal fixed-length encoding because four distinct symbols can be represented by (2^2=4) possible bit patterns. For example, a system could assign A = 00, C = 01, G = 10, and T = 11. Under this scheme, a sequence of four bases could be encoded as a single byte. However, this is only an illustrative encoding: real software may use different assignments and additional conventions. Ambiguous nucleotide symbols such as N, R, Y, and other IUPAC symbols require extra representation rules. Software must also account for sequence length, alignment, indexing, and any metadata associated with the sequence.
- Compact sequence encodings can substantially reduce memory requirements when handling reference genomes or large collections of reads. For example, a canonical DNA sequence of one billion bases would require approximately one billion bytes if stored as one ASCII character per base, excluding file headers and formatting. At two bits per base, the theoretical packed representation would require approximately 250 million bytes, or about 250 MB in decimal units, before adding metadata and other overhead. Actual storage requirements depend on the encoding scheme, ambiguity handling, indexing structures, compression, and file format.
- Protein sequences are more complex to encode compactly because the standard amino acid alphabet contains 20 common amino acids. Five bits are sufficient to represent 32 possible symbols, so a fixed-length five-bit encoding can represent the 20 standard amino acids and leave some code patterns available for additional symbols. Nevertheless, many biological applications retain readable single-letter sequences because they simplify inspection, interoperability, annotation, and debugging. Specialized software may use compact internal representations when processing speed or memory efficiency is especially important.
- Sequence ambiguity is an important issue in biological data representation. In DNA, N commonly indicates that a nucleotide is unknown or unresolved, while other IUPAC symbols represent combinations of possible bases. For example, R represents A or G, and Y represents C or T. In protein sequences, symbols such as X may represent an unknown or unspecified amino acid. These symbols carry biological and analytical meaning; they should not be treated as ordinary errors or removed without considering the requirements of the analysis. Software that accepts only canonical bases may require special handling of ambiguous symbols.
- Quality scores in sequencing data are another example of encoded biological information. In FASTQ files, each sequence read is accompanied by a quality string that represents the estimated confidence of base calls. In widely used Phred quality scoring, the quality score (Q) is related to the estimated probability (P) of an incorrect base call by the formula
- [
Q=-10\log_{10}(P).
] - A higher quality score corresponds to a lower estimated probability of error. For example, (Q=20) corresponds to an estimated error probability of 0.01, or 1%, while (Q=30) corresponds to 0.001, or 0.1%. Quality scores are stored as characters using an agreed encoding convention. Historical FASTQ variants have used different offsets, so software must identify or correctly specify the quality encoding to avoid interpreting scores incorrectly.
- Biological file formats illustrate how data representation combines character encoding with structural rules. FASTA stores sequence identifiers and sequences in readable text. FASTQ stores identifiers, sequence strings, separator lines, and quality strings. SAM is a textual format for representing sequence alignments, while BAM is a binary representation of alignment data that supports compact storage and efficient processing. CRAM provides a reference-oriented compressed format for sequencing alignment data. VCF represents genetic variants in a structured text format, while BCF provides a corresponding binary representation. These formats differ in their organization, metadata conventions, compression, indexing support, and intended use.
- Binary file formats often provide advantages in storage efficiency and parsing speed, but they may be less convenient to inspect manually. Text-based formats are more readable and can often be processed with standard command-line utilities. The best choice depends on the task. A researcher may retain raw data in a widely supported format, use compressed binary formats for large intermediate files, and export selected results into a text-based table for inspection or reporting. Conversion between formats must preserve relevant biological information, metadata, and quality values.
- Data types are closely related to data representation. A data type specifies the kind of value a variable can hold and often determines its range, storage size, and permitted operations. Common types include integers, floating-point numbers, Boolean values, strings, arrays, and structured records. In bioinformatics, read counts may be stored as integers, normalized expression values as floating-point numbers, nucleotide sequences as strings or encoded arrays, and sample metadata as structured records. Selecting an inappropriate data type can lead to overflow, unnecessary memory consumption, loss of precision, or incorrect calculations.
- Endianness describes the order in which the bytes of a multibyte value are stored in memory or represented in certain data formats. In big-endian systems, the most significant byte is stored first; in little-endian systems, the least significant byte is stored first. For example, the 32-bit hexadecimal value 0x12345678 would be stored as 12 34 56 78 in big-endian byte order and 78 56 34 12 in little-endian byte order. Endianness matters when binary files are exchanged between systems or interpreted by software that assumes a particular byte order. Many modern file formats define their byte-order conventions explicitly to support portability.
- Compression is frequently used to reduce the size of biological data. Lossless compression preserves the original information exactly and permits reconstruction of the original data. Formats such as gzip and tools such as BGZF are commonly used in biological workflows. BGZF divides data into blocks to support efficient access and indexing in suitable formats. Other specialized formats use reference sequences, repeated patterns, or domain-specific structures to achieve additional compression. Lossy compression, by contrast, discards some information and should only be used when the loss is acceptable for the intended scientific purpose. Compression methods can affect processing speed, storage requirements, and the ability to access individual records efficiently.
- Checksums and cryptographic hashes can help verify the integrity of digital data. A checksum or hash is calculated from the contents of a file, and the resulting value can be compared with a previously recorded value to detect accidental changes or corruption. SHA-256 is a widely used cryptographic hash function. If a sequencing file is transferred between laboratories or storage systems, comparing its hash before and after transfer can help confirm that the file contents remain unchanged. A matching hash does not establish that the data are biologically correct, but it provides evidence that the file has not changed between the two checks.
- Character encoding errors can affect biological analyses in subtle ways. A text file may contain unexpected byte-order marks, inconsistent newline conventions, nonstandard whitespace, invisible control characters, or a mixture of encodings. These issues can interfere with sequence parsing, sample-name matching, metadata joins, and command-line processing. For example, two sample identifiers that appear identical on screen may differ because one contains an invisible character or a different Unicode representation. Robust workflows should validate input files, standardize encoding where necessary, preserve identifiers consistently, and report parsing errors clearly.
- Data representation also affects interoperability between programming languages and analytical tools. Python, R, C, C++, Java, and other languages support different data structures and memory-management approaches, although they can exchange data through standardized file formats, libraries, and interfaces. Python is frequently used for workflow automation, data manipulation, and machine learning, while R is widely used for statistical analysis and visualization. Lower-level languages such as C and C++ can provide efficient implementations of computationally intensive algorithms. A shared understanding of file formats, numeric types, character encoding, and data structures helps these tools work together reliably.
- In bioinformatics, data representation must preserve both the values and their biological meaning. A DNA sequence is not simply a string of characters: its orientation, reference coordinate system, ambiguity symbols, and associated metadata may affect interpretation. A gene expression matrix must preserve the relationship between rows, columns, genes, and samples. A variant table must define reference and alternate alleles, genomic coordinates, genome assembly, and relevant quality information. Errors in representation or conversion can produce results that appear computationally valid but are biologically incorrect.
- The choice of representation can influence the performance of algorithms. String-based sequence comparison is straightforward and readable, but specialized encodings and indexes can accelerate large-scale searches. Bitwise operations can efficiently compare compact binary representations, while arrays and matrices support rapid numerical computations. Sparse matrices are useful when most entries in a gene expression or single-cell dataset are zero, because they store nonzero values more efficiently than dense matrices in many cases. Graph representations are useful for modeling molecular interactions, metabolic networks, regulatory relationships, and sequence variation. Each structure should be chosen according to the relationships and operations required by the analysis.
- Data validation is essential before computational analysis begins. Researchers should verify that files follow their expected formats, that numerical values fall within plausible ranges, that sequences contain valid symbols, and that metadata are consistent. For example, a DNA sequence file may need to be checked for invalid characters, while a gene expression matrix may require checks for missing values, duplicated identifiers, and unexpected negative counts. Automated validation reduces the risk of errors spreading through downstream analyses. Maintaining the original data and recording transformations also supports reproducibility.
- Data representation, binary systems, and character encoding form an important bridge between biological information and computation. Binary systems provide the foundation for digital storage and processing, while numerical representations enable efficient calculations. Character encodings allow textual biological information to be stored and exchanged consistently, and specialized data formats organize sequences, measurements, alignments, and variants for scientific applications. A sound understanding of these concepts helps bioinformaticians manage large datasets, avoid encoding and conversion errors, optimize memory use, and develop reliable computational workflows. As biological data continue to increase in scale and complexity, efficient and accurate data representation remains essential to reproducible and scientifically meaningful bioinformatics.