Package: dnazip-bioinfo
dnazipA Python implementation ofThe Burrows-Wheeler Transform (BWT)alongsideHuffman compressionon DNA sequences.Hosted onGitHubDocumentation?hereDemoA demo for installation and using the GUI can be foundhereInstallationYou can install the package either from pip or from the source code hosted on github.With pippipinstalldnazip-bioinfoFrom sourcegitclonehttps://github.com/dabane-ghassan/dnazip.gitcddnazip
sudopython3setup.pyinstallGetting startedGUIAfter installing the package from source or using pip, the interface can be launched simply from the command line:dnazipIf problems occur with the installation, an interface instance can be imported and launched:fromdnazip.interfaceimportInterfacegui=Interface()gui.main()Using the libraryGenerating a random DNA sequenceA random DNA sequence with an alphabet of ATCGN can be generated for any given length specified in the parameter.fromdnazip.sequenceimportSequencerandseq=Sequence.generate(length=5000)Sequence('/path/to/new/seq').write(randseq)Encoding a DNA sequence with Burrows-Wheeler + Huffman CodingTo encode a DNA sequence using BWT and Huffman coding, you can use a FullEncoder object that will save two files to the same directory as the sequence, the Burrows-Wheeler transform and the UTF-8 zipped format of the sequence:fromdnazip.encoderimportFullEncoderencode=FullEncoder('/path/to/seq')encode.full_zip()The attributes of the object can be accessed to see intermediary results:encode.bw_encoder.rotations# a matrix of string rotations from a sequenceencode.bw_encoder.bwm# The Burrows-Wheeler Matrixencode.bw_encoder.bwt# The Burrows-Wheeler Transformencode.huff_encoder.header# The header of the zip file that contains Huffman codes for each character as well as the sequence binary paddingencode.huff_encoder.binary# The binary sequence of the BW transformencode.huff_encoder.unicode# 8-bits encoded binary sequenceA random sequence of size 1kB was compressed efficiently to 549 bytes.Decoding a DNA sequence with Huffman decoding + Reversing Burrows-Wheeler transformTo decode a zipped DNA sequence using Huffman decoding and the inverse of BWT, you can use a FullDecoder object that will work in the same manner as the FullEncoder object:fromdnazip.decoderimportFullDecoderdecode=FullDecoder('path/to/seq')decode.full_unzip()The attributes can also be accessed to see intermediary results:decode.huff_decoder.header# The header of the zip file that contains Huffman codes for each character as well as the sequence binary padding that where saved when the Huffman tree was createddecode.huff_decoder.unicode# 8-bits encoded sequencedecode.huff_decoder.binary# The binary sequencedecode.bw_decoder.bwm# The Burrows-Wheeler reconstructed matrixdecode.bw_decoder.original# The original sequenceBuilding the Burrows-Wheeler transform using the advanced algorithmThe BWT can be constructed using a Suffix Array (SA) based algorithm that has a better time and space complexities:fromdnazip.sequenceimportSequencefromdnazip.burros_wheelerimportBurrosWheelerseq=Sequence('/path/to/seq').read()BurrosWheeler.bwt_advanced(seq)DocumentationDetailed documentation on the architecture can be foundhereAbout:scroll: LicenseMIT Licensed©Ghassan Dabane, 2021.