Skip to content

ostash-group/dna-data-compressor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DNA DATA COMPRESSOR

Visitor count GitHub GitHub issues GitHub Repo stars GitHub contributors

dna-data-compessor is a tiny library, it can quick convert (and compress) DNA sequences data (string data type in javascript) to binary data and vice versa. It can provide maximum level of DNA data compression (we suppose that allocation of nucleotides is random).

This can be useful for data transfering or fast data analysis of DNA sequences.
So, every nucleotide is encoded by 2 bytes (UTF-16), in some cases - 1 byte (ASCII, UTF-8). But, actualy, we need just two bits to encode one nucleotide. For example:
A - 00
C - 01
G - 10
T - 11
By this way, we can compress DNA sequences data in 4-8 times.

Web

In order to use dna-data-compressor on a webpage, download dna-compressor.js from the web folder of this repository and include it in a script, like so (assuming it is in the same directory as your page):

<script src="dna-compressor.js"></script>

And use it, like so:

<script>
	const compressor = new Compressor();
<script>

Node

You can use dna-data-compressor in your node project. Download dna-data-compressor.umd.js from the dist folder of this repository. Then include it in your script:

const compressor = require('../path/dna-data-compressor.umd');

Usage

// Some DNA sequence
const sequence = 'ATTGGTACGACTGCAGCTGCATATTATAATGATCGATCGATCGTAC'

// Compress string to binary data (ArrayBuffer)
const buffer = compressor.sequenceToBinaryData(sequence);

// Decompess binary data to string
const decompressed = compressor.binaryDataToSequence(buffer);

NPM scripts

  • npm test: Run simple test (test folder)

Author

The tool was created by Serhii Silov. Contact e-mail: [email protected]

About

A small javascript tool for DNA data compression. Can compress the DNA string up to 4-8 times.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published