Package: pyhmmer
🐍🟡♦️🟦 PyHMMERCythonbindings and Python interface toHMMER3.🗺️ OverviewHMMER is a biological sequence analysis tool that uses profile hidden Markov
models to search for sequence homologs. HMMER3 is developed and maintained by
theEddy/Rivas Laboratoryat Harvard University.pyhmmeris a Python package, implemented using theCythonlanguage, that provides bindings to HMMER3. It directly interacts with the
HMMER internals, which has the following advantages over CLI wrappers
(likehmmer-py):single dependency: If your software or your analysis pipeline is
distributed as a Python package, you can addpyhmmeras a dependency to
your project, and stop worrying about the HMMER binaries being properly
setup on the end-user machine.no intermediate files: Everything happens in memory, in Python objects
you have control on, making it easier to pass your inputs to HMMER without
needing to write them to a temporary file. Output retrieval is also done
in memory, via instances of thepyhmmer.plan7.TopHitsclass.no input formatting: The Easel object model is exposed in thepyhmmer.easelmodule, and you have the possibility to build aDigitalSequenceobject yourself to pass to the HMMER pipeline. This is useful if your sequences are already
loaded in memory, for instance because you obtained them from another
Python library (such asPyrodigalorBiopython).no output formatting: HMMER3 is notorious for its numerous output files
and its fixed-width tabular output, which is hard to parse (evenBio.SearchIO.HmmerIOis struggling on some sequences).efficient: Usingpyhmmerto launchhmmsearchon sequences
and HMMs in disk storage is typically as fast as directly using thehmmsearchbinary (see theBenchmarks section).pyhmmer.hmmer.hmmsearchuses a different parallelisation strategy compared to
thehmmsearchbinary from HMMER, which can help getting the most of
multiple CPUs when annotating smaller sequence databases.This library is still a work-in-progress, and in an experimental stage,
but it should already pack enough features to run biological analyses or
workflows involvinghmmsearch,hmmscan,nhmmer,phmmer,hmmbuildandhmmalign.🔧 Installingpyhmmercan be installed fromPyPI,
which hosts some pre-built CPython wheels for Linux and MacOS on x86-64 and Arm64, as well as the code required to compile from source with Cython:$pipinstallpyhmmerCompilation for UNIX PowerPC is not tested in CI, but should work out of the
box. Note than non-UNIX operating systems (such as Windows) are not
supported by HMMER.ABiocondapackage is also available:$condainstall-cbiocondapyhmmer🔖 CitationPyHMMER is scientific software, with apublished paperin theBioinformatics. Please
cite bothPyHMMERandHMMERif you are using it in
an academic work, for instance as:PyHMMER (Larraldeet al., 2023), a Python library binding to HMMER (Eddy, 2011).Detailed references are available on thePublications pageof theonline documentation.📖 DocumentationA completeAPI referencecan
be found in theonline documentation, or
directly from the command line usingpydoc:$pydocpyhmmer.easel$pydocpyhmmer.plan7💡 ExampleUsepyhmmerto runhmmsearchto search for Type 2 PKS domains
(t2pks.hmm)
inside proteins extracted from the genome ofAnaerococcus provencensis(938293.PRJEB85.HG003687.faa).
This will produce an iterable overTopHitsthat can be used for further sorting/querying in Python.
Processing happens in parallel using Python threads, and aTopHitsobject is yielded for everyHMMpassed in the input iterable.importpyhmmerwithpyhmmer.easel.SequenceFile("pyhmmer/tests/data/seqs/938293.PRJEB85.HG003687.faa",digital=True)asseq_file:sequences=list(seq_file)withpyhmmer.plan7.HMMFile("pyhmmer/tests/data/hmms/txt/t2pks.hmm")ashmm_file:forhitsinpyhmmer.hmmsearch(hmm_file,sequences,cpus=4):print(f"HMM{hits.query_name.decode()}found{len(hits)}hits in the target sequences")Have a look at more in-depth examples such asbuilding a HMM from an alignment,analysing the active site of a hit,
orfetching marker genes from a genomein theExamplespage of theonline documentation.💭 Feedback⚠️ Issue TrackerFound a bug ? Have an enhancement request ? Head over to theGitHub issue
trackerif you need to report
or ask something. If you are filing in on a bug, please include as much
information as you can about the issue, and try to recreate the same bug
in a simple, easily reproducible situation.🏗️ ContributingContributions are more than welcome! SeeCONTRIBUTING.mdfor more details.⏱️ BenchmarksBenchmarks were run on ai7-10710U CPUrunning @1.10GHz with 6 physical / 12
logical cores, using a FASTA file containing 4,489 protein sequences extracted
from the genome ofEscherichia coli(562.PRJEB4685)
and the version 33.1 of thePfamHMM library containing
18,259 domains. Commands were run 3 times on a warm SSD.Plain lines show
the times for pressed HMMs, and dashed-lines the times for HMMs in text format.Raw numbers can be found in thebenchesfolder.
They suggest thatphmmershould be run with the number oflogicalcores,
whilehmmsearchshould be run with the number ofphysicalcores (or less).
A possible explanation for this observation would be that HMMER
platform-specific code requires too manySIMDregisters per thread to benefit fromsimultaneous multi-threading.To read more about how PyHMMER achieves better parallelism than HMMER for
many-to-many searches, have a look at thePerformance pageof the documentation.🔍 See AlsoBuilding a HMM from scratch? Then you may be interested in thepyfamsapackage, providing bindings toFAMSA,
a very fast multiple sequence aligner. In addition, you may want to trim alignments:
in that case, considerpytrimal, which
wrapstrimAl 2.0.If despite of all the advantages listed earlier, you would rather use HMMER
through its CLI, this package will not be of great help. You can instead check
thehmmer-pypackage developed
byDanilo Hortaat theEMBL-EBI.⚖️ LicenseThis library is provided under theMIT License.
The HMMER3 and Easel code is available under theBSD 3-clauselicense.
Seevendor/hmmer/LICENSEandvendor/easel/LICENSEfor more information.This project is in no way affiliated, sponsored, or otherwise endorsed by
theoriginal HMMER authors. It was developed byMartin Larraldeduring his PhD project
at theEuropean Molecular Biology Laboratoryin
theZeller team.