A fast tool to calculate Hamming distances
Project description
A small C++ tool to calculate pairwise distances between gene sequences given in fasta format.
Python interface
To use the Python interface, you should install it from PyPI:
python -m pip install hammingdist
Distances matrix
Then, you can e.g. use it in the following way from Python:
import hammingdist
# To see the different optional arguments available:
help(hammingdist.from_fasta)
# To import all sequences from a fasta file
data = hammingdist.from_fasta("example.fasta")
# To import only the first 100 sequences from a fasta file
data = hammingdist.from_fasta("example.fasta", n=100)
# To import all sequences and remove any duplicates
data = hammingdist.from_fasta("example.fasta", remove_duplicates=True)
# To import all sequences from a fasta file, also treating 'X' as a valid character
data = hammingdist.from_fasta("example.fasta", include_x=True)
# The distance data can be accessed point-wise, though looping over all distances might be quite inefficient
print(data[14,42])
# The data can be written to disk in csv format (default `distance` Ripser format) and retrieved:
data.dump("backup.csv")
retrieval = hammingdist.from_csv("backup.csv")
# It can also be written in lower triangular format (comma-delimited row-major, `lower-distance` Ripser format):
data.dump_lower_triangular("lt.txt")
retrieval = hammingdist.from_lower_triangular("lt.txt")
# If the `remove_duplicates` option was used, the sequence indices can also be written.
# For each input sequence, this prints the corresponding index in the output:
data.dump_sequence_indices("indices.txt")
# Finally, we can pass the data as a list of strings in Python:
data = hammingdist.from_stringlist(["ACGTACGT", "ACGTAGGT", "ATTTACGT"])
Distances from reference sequence
The distance of each sequence in a fasta file from a given reference sequence can be calculated using:
import hammingdist
distances = hammingdist.fasta_reference_distances(sequence, fasta_file, include_x=True)
This function returns a numpy array that contains the distance of each sequence from the reference sequence.
You can also calculate the distance between two individual sequences:
import hammingdist
distance = hammingdist.distance("ACGTX", "AAGTX", include_x=True)
OpenMP on linux
The latest versions of hammingdist on linux are now built with OpenMP (multithreading) support. If this causes any issues, you can install a previous version of hammingdist without OpenMP support:
pip install hammingdist==0.11.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for hammingdist-0.17.0-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53e0547015f87de4752d8136c4c343cc4b63e9719b5b69b7785bd04e95a3168a |
|
MD5 | 56f5f98e639e9130c4ba7b3c92d5941e |
|
BLAKE2b-256 | 854cbf46ef8c88a13f4ee6e68dc59fd5e0a97dd0461dcad6b715e510490a4cb4 |
Hashes for hammingdist-0.17.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69b4f180728e888d261a7de66ed138b732eef82dd9314faeba5a4cced0cbc183 |
|
MD5 | 3830bcc103e14aa8a52f2b09844a1ee9 |
|
BLAKE2b-256 | a2a341fd64c7bcb32585a7bcdca12764a0b95a57c54ac49197cdbab3ceac19da |
Hashes for hammingdist-0.17.0-pp39-pypy39_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99f7cecbb2fc736954e1cd24758ad623fed9c3c806a82ee3720711bbac63e71c |
|
MD5 | 8409ee85077b940b4b3c1c8e22b9e105 |
|
BLAKE2b-256 | 995a25b3db180396038cb2ca522a4e982e999d545ee5df62419fb764f31eb3e7 |
Hashes for hammingdist-0.17.0-pp38-pypy38_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e9b77ea915b8528ce53331601575ce0b1a977903f93c0d2ef0ae2802ce1f41e |
|
MD5 | e4772063458e532e66f9d59d6845eb2c |
|
BLAKE2b-256 | c244e12c8727ee1ac7335a9e6fb0f1445ddcf89d95e2066db9581aa87e258a14 |
Hashes for hammingdist-0.17.0-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7ba54b9d31fed0466f582cbafcfc1b0fa5fdb09091270b56e03940d948c768a |
|
MD5 | 4e6d160d0e3f7b17b723442fb75e6d57 |
|
BLAKE2b-256 | a4ec6b56af6b1ccb0408f54594b8eac14d4a98305d2e4c9f51bd6b25a7a09c25 |
Hashes for hammingdist-0.17.0-pp38-pypy38_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31855c56c6ce45e2d5b0b28375a743c7d8bb2b30ca166f8d0fcfa763c228d824 |
|
MD5 | 5de19562a81138a5498ea28c1e211a03 |
|
BLAKE2b-256 | 28465dd0229039d6013594bcf158d3a5089e9ca6aa0440bc73804e4360850a7c |
Hashes for hammingdist-0.17.0-pp37-pypy37_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06586314a1676873add5d6a981c66b089108ca5362798f8e5e2ad4b43826fbda |
|
MD5 | b93a11ffe831bb1be9d62a6b8e4124ae |
|
BLAKE2b-256 | 9b3cc7585b7ecb8a62d8cd90e6bae02f6c2e72f3fb3292b7f03c5687c6f9916d |
Hashes for hammingdist-0.17.0-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 305e1a1f01887b3c8458b6c5b2043fa23b4607004d68c29f0c633983964ed5ad |
|
MD5 | adc7a74e80c9267c330a3890d9c98b3f |
|
BLAKE2b-256 | e84e85e3387290d9a27db7363bb832c092748570b4f3603c8bce42e472abaaff |
Hashes for hammingdist-0.17.0-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaca5a0c99d9f1fb62c5bd8dd3be4cb035ddc28591d86c027b6a26efaead070a |
|
MD5 | a7bdd1672190f458584380fedc1b5770 |
|
BLAKE2b-256 | 6f11d92e7347a5b6c5607882c97389ac71f3bf5bbf749eb930abc5bae6973b30 |
Hashes for hammingdist-0.17.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3027e910bc09bb851a41c555b1b593c247322569e204c25d7d36bf543041eb15 |
|
MD5 | 771334bd979847fad6cf5ca427da56f8 |
|
BLAKE2b-256 | 5a3715ea86431ea610e3c63c42054bccf2d5c044b21548d62033a59cc776606c |
Hashes for hammingdist-0.17.0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a294e05e831c169ad9c1db89ab716f9070e152de8b84e4f2dd2c16aec094446 |
|
MD5 | f041601039827437c4597d8249236a31 |
|
BLAKE2b-256 | 44234577b3f892feabda02a68c81018a2b0d6c673cca033986449ed64a1b27fb |
Hashes for hammingdist-0.17.0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5057cb5c7c089a8472758760e47bdb1a6c6dfb98d2ce99fca84e7044f09cb157 |
|
MD5 | e7912c8f269c9abd141760dbb9b28f30 |
|
BLAKE2b-256 | d7771e0ef8323fba17e25138073e638d6ce9bdf864c29958cf6eee41da809486 |
Hashes for hammingdist-0.17.0-cp311-cp311-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 572ae4c9af1d903cfe779ac54c81514f05b851a8a4b95888734541a391c44d58 |
|
MD5 | 8842828167d980c72df7f9ac9c8533f1 |
|
BLAKE2b-256 | 429c9683a65f9cd174bf7bbe0453d26fd83de617ddcf058229d59e1f9bae5120 |
Hashes for hammingdist-0.17.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | db41c01338317327fbdb53651a182eb36b7942711dc8c9372cc3f4908c951e1d |
|
MD5 | ec349fd796f1626b9dd94bb5828c2f63 |
|
BLAKE2b-256 | 8a0eade6a61182054b652a5579bcb5d1f34055f5a473ea6cbcbeee23504e70b3 |
Hashes for hammingdist-0.17.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41a3f8b9c385c1875e61b0a383af0513fe9d84b01aeb9b7d1835190ad0497eea |
|
MD5 | a61ca669a26ce118bdef1bd09c14a416 |
|
BLAKE2b-256 | 4529ead300e9b3802308d931c19d86db41534397cf9def15ed0c01ee837bf17b |
Hashes for hammingdist-0.17.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c16d77da6ad667f2bf36a351224d9d8b12a69cf5f959c03f814ff10e5bc27f62 |
|
MD5 | 31a0d788a6c38c2086b5973339e364e4 |
|
BLAKE2b-256 | ec1ff53e05e6211f5a13d0238e805662dadcae31bb6d2bc8f17615f64f077da2 |
Hashes for hammingdist-0.17.0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cbf5e704da6f4db52453ad0ab0022c0f4bef2fe2eed1387e825255a6eeebc06 |
|
MD5 | d60d1333e848d8cff478718c45ae2fee |
|
BLAKE2b-256 | 6916049f860c117fc35840083eb5953b63be9219ffd47cd894f6a6993e423d55 |
Hashes for hammingdist-0.17.0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e77b4bb6b3195b315f50f321937c99ef2e1838dcc3c26d51021867dc3a40d1ea |
|
MD5 | 3da59377d1c7b7de4ea3ecf5f5780abc |
|
BLAKE2b-256 | 603b2fd8263636776fa2e5e937ff0398a79e9b9aa7158c9c7f8d1a1951bcbb9a |
Hashes for hammingdist-0.17.0-cp310-cp310-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c1e34ad3fa870df52fbc17fd97311d3d2372a1cf975ed5ed400cc8223403c69 |
|
MD5 | 034b271e66cb5cf76a74a77996b82f73 |
|
BLAKE2b-256 | 4421776174d07e93ce1ac628fe1b573f1c55894646b721879ba3428e075cf7f6 |
Hashes for hammingdist-0.17.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c369539c63e0a4a1ebe178d63f2ea516f33144761c05ce9d338a030a47cca6ca |
|
MD5 | da05ffa92ee6226779053b804c78cdde |
|
BLAKE2b-256 | 2406d11f82c435a8822b5d4b325f400ff6d0b7ac54489c3fc96db7d3c8126641 |
Hashes for hammingdist-0.17.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f133fb3a1f25f3a00c0b0350516ecea7ae7f3d95568b4015ffe054de1f1c9657 |
|
MD5 | 789d01798a0d241c24571437fbe3b75c |
|
BLAKE2b-256 | 95d17f792f5c668ca912781be7c8c851a91e107b7d3be32c64d6d70bdfdc8e12 |
Hashes for hammingdist-0.17.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21cc96ac0504ba8e731256e6878204fa826a3c09bee27737da54ce83d82dea8b |
|
MD5 | 285d7f75ca79a4a7bff1ea6469bc037f |
|
BLAKE2b-256 | 7524024569a6dbcd1fc689b1f6b95c1a633d8abae2f70f405c6c1aa70c88c70c |
Hashes for hammingdist-0.17.0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f354a6e4c441023c83f227f26dd18e90c92210806234bf25b59015c7c529aa4 |
|
MD5 | 9ff443f99f9f2351f9f2ee9feb8605a4 |
|
BLAKE2b-256 | 95fae8c88a84537090905ca43faa4804375da5a256b1840bb23819db90e97326 |
Hashes for hammingdist-0.17.0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d4bc1bec6c72dc6c6971fda3eb224c3b7a27c7acac589bfe7048ad5aaa70771 |
|
MD5 | cc45236638d79d88e5cb2aec8afb3049 |
|
BLAKE2b-256 | 40ac16c92d2b24862343d6c8eb60bb6852df8853416793e0394ef94ec018d490 |
Hashes for hammingdist-0.17.0-cp39-cp39-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95564e5068c48296bdbd551e3b62693bfaff8d89f065a2d2c43a64f3c2878727 |
|
MD5 | 0cc0cf4cba6d7a08d1a8ae123e7dad40 |
|
BLAKE2b-256 | bbc33b7b85e49e11cd5656f5e7a746ea57ab90ebcef168d17916b64dd1c36b77 |
Hashes for hammingdist-0.17.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 317f604d65261d3ebe6193259f32a6b98c45935b2a41b6e06ca3f1ddd22a9967 |
|
MD5 | da8a0d2b03aec1fb2afc5986480bcc3a |
|
BLAKE2b-256 | 910eb783c10ffff702b7637c690988ef33416a3ea3939b27edc8d1513e9d49fe |
Hashes for hammingdist-0.17.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7e9b474fb8b275d703f58c72e30f449164953b0955e3b4c7f05955f5723b0e2 |
|
MD5 | 0d2df624e99ce6d4efcd4ff2873ee918 |
|
BLAKE2b-256 | bfe7daeb4c56caa96a677b7fa2850b7e9fe03c74ed7634ac9d914553923b7c0e |
Hashes for hammingdist-0.17.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf6e94a8f4de617f3a0b6dc5ed3fc780c839a0a78ef94c6f03f794cfedab97d0 |
|
MD5 | eebc5440b6b304834813d04d57698811 |
|
BLAKE2b-256 | 9ff6227fdd920568182a593920b5890bb3124ab8091dfa5e80c7fc850ad9531f |
Hashes for hammingdist-0.17.0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6ce377900cb482f720986700962a25889deb690b6781dc1c536fbdb81b3534a |
|
MD5 | 01d94c0eece11eb7e70b7adaabd657ad |
|
BLAKE2b-256 | e0c9cdfa795cc5d8f2f1aa94a4742b3947bde2e14967bcf11b9e3d6bc20f6921 |
Hashes for hammingdist-0.17.0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41c7a8e8d5c6204593ae2c6a740b8713795c372ab9eb73e4b2dcdf2fa7ea132 |
|
MD5 | 9d1db9bbb70cd9ec0a1ed1a123972d02 |
|
BLAKE2b-256 | 383c92ab7e45f734a644efd34fc6b4cbd4d35b4c52e00f7475500505036967a5 |
Hashes for hammingdist-0.17.0-cp38-cp38-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47d3c62c2b2befc364edee36be7a1376d79c66fe0c5e5b4ffb9b40f9ce24935b |
|
MD5 | 4b96629163be3301e81d5e01de9ce10f |
|
BLAKE2b-256 | a96c51a84de077a2bd104f1f5f245bca60922819bd695ca22618b83c90d9d15c |
Hashes for hammingdist-0.17.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e707ee7ad3b477eab196f7f5428928a3a284703bb457d75acc35a8736fc3de8d |
|
MD5 | 46b4f121a6e65076cf267372ffee0966 |
|
BLAKE2b-256 | 225ba7110ccc23daacfe2f46bef789405c8238feb8d3566f8ec281d87bd8b057 |
Hashes for hammingdist-0.17.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 485bca7501aeb9f29f75ac0073bb70e2efbd342ad5a70887a811e0c96a462788 |
|
MD5 | b43f9c5ad604864095bc7176f7c71c23 |
|
BLAKE2b-256 | 60dd3742cf7953afb456b28705871664b2d6190bef804b6eb85022137457ad03 |
Hashes for hammingdist-0.17.0-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324a26b27ecd88f744ed43334b0fff857ca975b3698fced5b2cee1507e9380c5 |
|
MD5 | efe4bb6ca1339b34255c61543cb8f591 |
|
BLAKE2b-256 | 8b80f661966e79f37ef0c2c1f5b5ac76edd3a8755c16b0a036bb9a6e23e67d29 |
Hashes for hammingdist-0.17.0-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ada193691aa5af2d0ad0922dbbfad2b22c46bed1f58b8c2760bd629e04850dc |
|
MD5 | 5438ae401db972778c0d5441de314f20 |
|
BLAKE2b-256 | 58dede447660ab949b238b1447aa04784a9538aa2bc18b01c83a17fa8475ed4a |
Hashes for hammingdist-0.17.0-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46a230c557adf1bf8c672a1230e5f7e4747278b58abdde990a10635beb039780 |
|
MD5 | 3e4215c9999b7a09f29d03ca686acf62 |
|
BLAKE2b-256 | ac5247ee161e79507c4a1bd73a7830dfa92117ce888bca0a13eca757333c934c |
Hashes for hammingdist-0.17.0-cp37-cp37m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 771478a25e70aa42cb57d186b38221e646c751bc0303cc8fd72a3362e2d768e4 |
|
MD5 | d36cf08226303e8d380d9347e57df819 |
|
BLAKE2b-256 | f351f77a9871b10d1e9b422d0190b6604f6c8d6a0c0d07d4d28de1ebcd19bc8f |
Hashes for hammingdist-0.17.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 144d8ee70630e09b4fe8a8efa5f8c5e06a03ca1430b6f7596dcf93355085f360 |
|
MD5 | 7385b16dd99a39ea45cd6da0f9073ae3 |
|
BLAKE2b-256 | 00761e45bf6bc741b21a8a6fed7500238fefd3834d32a75b27c4d00676dd64f0 |
Hashes for hammingdist-0.17.0-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5422d715ddef17d5600655e99c01b7205256f537053a88ecdad26dcdf72c5905 |
|
MD5 | 7e38b301ccc873f64d25bf3879a988da |
|
BLAKE2b-256 | 0098a90573cbed1e99940163395ce9d0ce5cc4e3beabc48e7ca2cbc4b883ac71 |
Hashes for hammingdist-0.17.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 129606407adf9fce6302849bc4852aa6dc23ae2762128a27fba43a2726dbb3a4 |
|
MD5 | 5439f93862168b9a8bd7e01a2314c09c |
|
BLAKE2b-256 | 8c1aa472f05ca15f99080397f0e9ee6c9501257dad653c34110ad89cee203c20 |
Hashes for hammingdist-0.17.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea58e2f7070bcbf9a4a0086d70681ad6476fc01166f1eacb0cc9170ea62abf7f |
|
MD5 | e2c8cd4fab952b4d4f5a78166f03f68c |
|
BLAKE2b-256 | 71a7d8f986663ad2010cc4028e4f3159f7fa015abb694eb4c069cb70eb394bc4 |
Hashes for hammingdist-0.17.0-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccc928c2b0000c0f3bf27da50fbee4200f594b0c509aa7a0a9b9c367a1f431e3 |
|
MD5 | 5c8c9b63b9268778a8a4c9b6501fd10d |
|
BLAKE2b-256 | 2f611376bfac6105195cc17a8786b4e189bacf22a49c6b3154fc1a0b2856f170 |
Hashes for hammingdist-0.17.0-cp36-cp36m-musllinux_1_1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72f0a1d53e420f8afc745a2ec72a226b5717cd3023c5ebe3bf0817d0ad425156 |
|
MD5 | 6cd8e05456f9081e754becd518499e01 |
|
BLAKE2b-256 | 25b4f089546bfff3e680af23815c4fe8a810a190ae0c602d4995838c1c010c5b |
Hashes for hammingdist-0.17.0-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ac959fa5eeb7db57f705346aa49b0dc0af141a83ad288e0d7be2e188a98c79d |
|
MD5 | 0ec032a6841d2c7b83590e7b2e2b3e4d |
|
BLAKE2b-256 | 920b4b1f703d3f60cec89560bbfa4df9e5834f3ccbe41f2c529c9a40f0ae26ed |
Hashes for hammingdist-0.17.0-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a70e956e0ccd425110a6eb3971199f0c5ad3d32936075b5eadaba45656b3490 |
|
MD5 | 4759dd6e9e9d3e0ac798d8ec9e0abb8c |
|
BLAKE2b-256 | 0c840a04edc7f9bcbe22a08ded10bb70f8c88084a8496146760187b96e551b89 |