Crates.io | base_sequence_compression |
lib.rs | base_sequence_compression |
version | 0.1.2 |
source | src |
created_at | 2024-06-18 10:46:52.456298 |
updated_at | 2024-07-31 22:38:52.722668 |
description | Library for compressing and decompressing DNA sequences |
homepage | |
repository | https://github.com/marshallku/base-sequence-compression |
max_upload_size | |
id | 1275373 |
size | 19,125 |
Base Sequence Compression is a Rust library for compressing and decompressing DNA sequences. This library efficiently encodes DNA sequences, reducing storage space while preserving the integrity of the original data. The DNA bases (A, C, T, G) are encoded using 2 bits each, allowing for significant compression.
Add the following to your Cargo.toml
:
[dependencies]
base_sequence_compression = "0.1.0"
Here's an example of how to use the library:
use base_sequence_compression::{compress_sequence, decompress_sequence};
fn main() {
let dna_sequence = "ACGTACGTACGT";
let compressed = compress_sequence(dna_sequence);
let decompressed = decompress_sequence(&compressed);
assert_eq!(dna_sequence, decompressed);
println!("Compression successful!");
}
compress_sequence
Compresses a DNA sequence into a binary format.
pub fn compress_sequence(sequence: &str) -> Vec<u8>
&str
- The DNA sequence to be compressed.Vec<u8>
- The compressed binary data.decompress_sequence
Decompresses binary data back into the original DNA sequence.
pub fn decompress_sequence(compressed: &[u8]) -> String
&[u8]
- The compressed binary data.String
- The decompressed DNA sequence.The library includes a comprehensive set of tests to ensure the correctness of the compression and decompression functions. To run the tests, use the following command:
cargo test
Here's an example test that checks the compression and decompression of a DNA sequence:
#[test]
fn test_compress_decompress() {
let dna_sequence = "ACGTACGTACGT";
let compressed = compress_sequence(dna_sequence);
let decompressed = decompress_sequence(&compressed);
assert_eq!(dna_sequence, decompressed);
}
This project is licensed under the MIT License. See the LICENSE
file for more details.
Contributions are welcome! Please open an issue or submit a pull request if you have any improvements or bug fixes.
Thanks to the contributors and the open-source community for their invaluable feedback and support.
Repository: Base Sequence Compression
Feel free to reach out for any questions or suggestions regarding the library.