Package: pahmm
paHMM-Tree Library for Python and CpaHMM-Tree is short for "pairwise statistical phylogenetic distance estimation
using pair hidden Markov models". It's a tool developed by Marcin Bogusz and Simon Whelan.
This library, "libpahmm" exposes the tool's capabilities toPythonas well asC.What is libpahmm?It's a library for finding evolutionary distances between a set of sequences of nucleotides or amino-acids
(such as DNA, RNA, proteins, etc.).
The library lets you configure the way distance calculations are made. These distances can
then be used to createphylogenetic treesto help visualize genetic relationships.Why use libpahmm?It allows for more accurate distance calculations that take into account multiple substitutions
per site on the sequences.It has good algorithmic time complexity: O(n^2 * L^2) where n is the number of sequences
and L is their length (assuming all have the same length).It's implemented in C++ internally, most work is done by compiled code and not Python.It's free and open-source.Basic usageLet's see how libpahmm can be used in Python and C. This following examples will calculate the
distance between two sequences from a FASTA-file containing DNA-data.Using Pythonfrompahmmimport*# 1. Create a banding estimator objectbe=BandingEstimator()# 2a. (Alternative a) Load a filebe.set_file_input("sequences.fasta")# 2b. (Alternative b) Load a stringbe.set_str_input(b"[sequences in FASTA-format here]")# 3. Load the desired distance-calculation methodsequences=be.execute_hky85_model()# 4. Calculate distance between two sequencesd=sequences.get_distance_from_names(b"seq1",b"seq2")Using C1. Create a banding estimator object:EBCBandingEstimator*be=ebc_be_create();2a. (Alternative a) Load a file:ebc_be_set_input_from_file(be,"sequences.fasta");2b. (Alternative b) Load a string:ebc_be_set_input(be,"[sequences in FASTA-format here]");3. Load the desired distance-calculation method:EBCSequences*sequences=ebc_be_execute_hky85_modelv2(be);4. Calculate distance between two sequences:doubled=ebc_seq_get_distance(sequences,"seq1","seq2");5. Clean up resources:ebc_seq_free(sequences);ebc_be_free(be);InstallationPython-library installation can easily be done as such:python3-mpipinstallpahmmWindows notice:The library build-scripts (CMakeList.txt and setup.py) have not been tested
on Windows, only on Linux and MacOS. Therefore, the librarydoes not have official Windows supportat the time being.C-library notice:Currently there are no binary packages distributed for the C-library. If you wish to use libpahmm
as a C-library, you could compile it yourself by following the instructions under the Compilation-section of this README.CompilationTo compile libpahmm you'll need to installCMake. This can be done with the following command on Linux (Ubuntu):sudoaptinstallcmakeOn MacOS I'd recommend usingBrewfor easy installation:brewinstallcmakeThen navigate to "libpahmm/", and enter the following command to build for Python 3:python3setup.pyinstallNote: Instead of "install" you could write "develop" (installs, but doesn't copy any binaries to
Python's site-packages folder). Use "clean" to clean up the source directory from any build files (excludingtests/).To build and install the C-library, just run:mkdirbuildcdbuild
cmake..
make
sudomakeinstallTo uninstall, look inside install_manifest.txt and delete everything that's listed there on your system.
This can be done in the following way. Make sure to check that install_manifest.txt contains the files you
actually want to delete:catinstall_manifest.txtIf everything you want to remove is listed in the file, then run the following command:sudoxargsrm<install_manifest.txtDirectory structureThe following is a description of what's in every directory in the root of the repository.auxiliary - Files needed for the Python build script.dlib - The dlib library, it's a dependency of paHMM-dist.examples - Example code that shows how the library can be used.include - Header files for the C pahmm library.paHMM-dist - A slightly modified version of the original paHMM-dist tool.python - The pahmm Python library.src - The source code for the C pahmm library, it's a thin wrapper around paHMM-dist.tests - Tests to verify the correctness of the library.TestsThere are tests that you can run if you wish to verify the correctness of the library output, the test-suite can be found undertests/. They verify that the output from the library match the output from the paHMM-Tree tool. You need to have the pahmm Python library installed before you run the tests.LicenseLibpahmm and paHMM-Tree are licensed under the GNU General Public License version 3.0 (GPLv3).Dlib is licensed under Boost Software License - Version 1.0.CreditsMarcin Bogusz and Simon Whelan for the development of paHMM-Tree:https://github.com/marbogusz/paHMM-TreeLars Arvestad for refactoring paHMM-Tree:https://github.com/arvestad/paHMM-distMazen Mardini for the paHMM-Tree library code and more refactoring of paHMM-Tree:https://github.com/mazen-mardini/libpahmm