hmm-profile-database-querying
Summary
Query biological sequences against profile hidden Markov model (pHMM) databases to identify homologous domains and functional annotations. This skill enables fast, memory-efficient HMM-based domain detection on biosynthetic gene clusters or protein sequences using Python bindings to HMMER3, replacing slower CLI-based approaches.
When to use
When you have BGC sequences (FASTA or GenBank format) or protein sequences and need to annotate them with biosynthetic or functional domains from a curated pHMM database (e.g., PFAM 35.0). Use this skill when you need domain hit coordinates, e-values, bit-scores, and normalized feature vectors for downstream clustering or similarity analysis, and when you want to avoid external HMMER binary dependencies or temporary file I/O.
When NOT to use
- Input sequences are already annotated with domain calls from another tool—use the existing annotations directly rather than re-scanning.
- You require alignment output or multiple sequence alignment of domain regions—pyHMMER returns hit coordinates and scores but does not generate MSAs by default.
- Your pHMM database is not available in binary format or your HMMER version is incompatible with the pyHMMER bindings you have installed.
Inputs
- BGC sequences in FASTA or GenBank format
- Protein sequences in FASTA or DigitalSequence objects
- Profile HMM database (e.g., PFAM 35.0 models from bigslice-models-2022-11-30)
Outputs
- Domain hit table (gene identifier, Pfam accession, domain coordinates, e-value, bit-score)
- Normalized domain-feature matrix (l2-normalized; rows = sequences, columns = Pfam domains or bit-scores)
- TSV export of BGCs, GCFs, and hit details for visualization and downstream clustering
How to apply
Load BGC or protein sequences into memory (FASTA or GenBank format) and initialize a pyHMMER interface with the target pHMM database (e.g., bigslice-models-2022-11-30 containing PFAM 35.0 HMMs). Scan each sequence against the HMM models using pyHMMER's hmmsearch or hmmscan with default e-value and bit-score cutoffs to extract domain hits (Pfam accessions, coordinates, e-values, bit-scores). Aggregate hits into a feature table indexed by gene/sequence identifier. Normalize the resulting domain presence/absence or bit-score vectors using l2-normalization to prepare for cosine-like distance metrics in downstream clustering. Export the normalized feature matrix and raw hit details to TSV format for reproducibility and downstream analysis.
Related tools
- pyHMMER (Cython-based Python bindings to HMMER3 for fast, in-memory HMM scanning without external binary dependencies) — https://github.com/althonos/pyhmmer
- BiG-SLiCE (Biosynthetic gene cluster clustering engine that uses pyHMMER for domain detection on BGCs and exports normalized domain-feature matrices for GCF construction) — https://github.com/medema-group/bigslice
- PFAM 35.0 (Curated profile HMM database used for domain annotation in BiG-SLiCE v2.0)
- HMMER3 (Underlying sequence analysis tool and profile HMM library; pyHMMER provides direct Cython bindings to HMMER internals) — http://hmmer.org/
Examples
from pyhmmer.plan7 import HMM, SequenceFile
from pyhmmer.hmmer import hmmsearch
hmmdb = HMMFile('pfam35.0.h3m')
seqs = SequenceFile('bgcs.fasta')
hits = hmmsearch(hmmdb, seqs)
for hit in hits:
print(hit.accession, hit.bitscore, hit.evalue)
Evaluation signals
- Domain hit table contains non-empty rows for all input sequences or a documented subset; check for presence of Pfam accessions, coordinates, and bit-scores meeting the cutoff threshold.
- Normalized feature matrix has l2-norm = 1.0 (or close, within floating-point tolerance) for each row, confirming cosine-distance compatibility.
- E-values and bit-scores are consistent with HMMER3 output ranges (e-values ≥ 0, bit-scores typically > 0 for significant hits).
- TSV exports are machine-readable and parseable; row and column counts match the number of input sequences and Pfam domains, respectively.
- Memory usage stays constant or grows linearly with input size (no temporary file artifacts); runtime is faster than equivalent CLI HMMER commands on the same hardware.
Limitations
- pyHMMER speed-ups depend on pre-built wheels for your CPU architecture (x86-64, Arm64); non-UNIX and exotic CPU targets may require compilation or fallback to CLI HMMER.
- Domain detection depends on e-value and bit-score cutoffs; the article does not specify how cutoffs are tuned for different Pfam subsets (e.g., biosynthetic vs. sub-Pfam), so threshold sensitivity should be validated per use case.
- L2-normalization assumes domain hit counts or bit-scores are comparable across sequences; skewed distributions or sequences with very few or many domains may require additional scaling.
- pHMM databases must be downloaded separately (e.g., ~271 MB gzipped for bigslice-models-2022-11-30); updates require manual re-download and re-indexing.
Evidence
- [readme] Switching from HMMER to pyHMMER for speed improvements and full pip installation: "Switching from HMMER to pyHMMER (speed-ups, can now be fully installed via pip)"
- [readme] pyHMMER provides in-memory HMM scanning without intermediate files: "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."
- [other] Domain hits are extracted and aggregated into a feature table: "Extract domain hits (gene identifiers, Pfam accessions, domain coordinates, e-values, bit-scores) and aggregate into a feature table."
- [other] L2-normalization prepares domain features for cosine-like distance clustering: "Normalize domain presence/absence or bit-score vectors using l2-normalization to prepare for downstream cosine-like distance clustering."
- [readme] BiG-SLiCE v2 uses PFAM 35.0 for domain annotation: "pHMM databases have been updated to PFAM 35.0"
- [readme] TSV export capability for pre-calculated results: "Ability to export pre-calculated BGCs and GCFs table into TSVs (use --export-csv parameter)"
1---2name: hmm-profile-database-querying3description: Use when when you have BGC sequences (FASTA or GenBank format) or protein sequences and need to annotate them with biosynthetic or functional domains from a curated pHMM database (e.g., PFAM 35.0).4license: CC-BY-4.05---67# hmm-profile-database-querying89## Summary1011Query biological sequences against profile hidden Markov model (pHMM) databases to identify homologous domains and functional annotations. This skill enables fast, memory-efficient HMM-based domain detection on biosynthetic gene clusters or protein sequences using Python bindings to HMMER3, replacing slower CLI-based approaches.1213## When to use1415When you have BGC sequences (FASTA or GenBank format) or protein sequences and need to annotate them with biosynthetic or functional domains from a curated pHMM database (e.g., PFAM 35.0). Use this skill when you need domain hit coordinates, e-values, bit-scores, and normalized feature vectors for downstream clustering or similarity analysis, and when you want to avoid external HMMER binary dependencies or temporary file I/O.1617## When NOT to use1819- Input sequences are already annotated with domain calls from another tool—use the existing annotations directly rather than re-scanning.20- You require alignment output or multiple sequence alignment of domain regions—pyHMMER returns hit coordinates and scores but does not generate MSAs by default.21- Your pHMM database is not available in binary format or your HMMER version is incompatible with the pyHMMER bindings you have installed.2223## Inputs2425- BGC sequences in FASTA or GenBank format26- Protein sequences in FASTA or DigitalSequence objects27- Profile HMM database (e.g., PFAM 35.0 models from bigslice-models-2022-11-30)2829## Outputs3031- Domain hit table (gene identifier, Pfam accession, domain coordinates, e-value, bit-score)32- Normalized domain-feature matrix (l2-normalized; rows = sequences, columns = Pfam domains or bit-scores)33- TSV export of BGCs, GCFs, and hit details for visualization and downstream clustering3435## How to apply3637Load BGC or protein sequences into memory (FASTA or GenBank format) and initialize a pyHMMER interface with the target pHMM database (e.g., bigslice-models-2022-11-30 containing PFAM 35.0 HMMs). Scan each sequence against the HMM models using pyHMMER's hmmsearch or hmmscan with default e-value and bit-score cutoffs to extract domain hits (Pfam accessions, coordinates, e-values, bit-scores). Aggregate hits into a feature table indexed by gene/sequence identifier. Normalize the resulting domain presence/absence or bit-score vectors using l2-normalization to prepare for cosine-like distance metrics in downstream clustering. Export the normalized feature matrix and raw hit details to TSV format for reproducibility and downstream analysis.3839## Related tools4041- **pyHMMER** (Cython-based Python bindings to HMMER3 for fast, in-memory HMM scanning without external binary dependencies) — https://github.com/althonos/pyhmmer42- **BiG-SLiCE** (Biosynthetic gene cluster clustering engine that uses pyHMMER for domain detection on BGCs and exports normalized domain-feature matrices for GCF construction) — https://github.com/medema-group/bigslice43- **PFAM 35.0** (Curated profile HMM database used for domain annotation in BiG-SLiCE v2.0)44- **HMMER3** (Underlying sequence analysis tool and profile HMM library; pyHMMER provides direct Cython bindings to HMMER internals) — http://hmmer.org/4546## Examples4748```49from pyhmmer.plan7 import HMM, SequenceFile50from pyhmmer.hmmer import hmmsearch51hmmdb = HMMFile('pfam35.0.h3m')52seqs = SequenceFile('bgcs.fasta')53hits = hmmsearch(hmmdb, seqs)54for hit in hits:55 print(hit.accession, hit.bitscore, hit.evalue)56```5758## Evaluation signals5960- Domain hit table contains non-empty rows for all input sequences or a documented subset; check for presence of Pfam accessions, coordinates, and bit-scores meeting the cutoff threshold.61- Normalized feature matrix has l2-norm = 1.0 (or close, within floating-point tolerance) for each row, confirming cosine-distance compatibility.62- E-values and bit-scores are consistent with HMMER3 output ranges (e-values ≥ 0, bit-scores typically > 0 for significant hits).63- TSV exports are machine-readable and parseable; row and column counts match the number of input sequences and Pfam domains, respectively.64- Memory usage stays constant or grows linearly with input size (no temporary file artifacts); runtime is faster than equivalent CLI HMMER commands on the same hardware.6566## Limitations6768- pyHMMER speed-ups depend on pre-built wheels for your CPU architecture (x86-64, Arm64); non-UNIX and exotic CPU targets may require compilation or fallback to CLI HMMER.69- Domain detection depends on e-value and bit-score cutoffs; the article does not specify how cutoffs are tuned for different Pfam subsets (e.g., biosynthetic vs. sub-Pfam), so threshold sensitivity should be validated per use case.70- L2-normalization assumes domain hit counts or bit-scores are comparable across sequences; skewed distributions or sequences with very few or many domains may require additional scaling.71- pHMM databases must be downloaded separately (e.g., ~271 MB gzipped for bigslice-models-2022-11-30); updates require manual re-download and re-indexing.7273## Evidence7475- [readme] Switching from HMMER to pyHMMER for speed improvements and full pip installation: "Switching from HMMER to [pyHMMER](https://github.com/althonos/pyhmmer) (__speed-ups__, can now be fully installed via __pip__)"76- [readme] pyHMMER provides in-memory HMM scanning without intermediate files: "**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."77- [other] Domain hits are extracted and aggregated into a feature table: "Extract domain hits (gene identifiers, Pfam accessions, domain coordinates, e-values, bit-scores) and aggregate into a feature table."78- [other] L2-normalization prepares domain features for cosine-like distance clustering: "Normalize domain presence/absence or bit-score vectors using l2-normalization to prepare for downstream cosine-like distance clustering."79- [readme] BiG-SLiCE v2 uses PFAM 35.0 for domain annotation: "pHMM databases have been updated to __PFAM 35.0__"80- [readme] TSV export capability for pre-calculated results: "Ability to __export pre-calculated BGCs and GCFs table into TSVs__ (use __--export-csv__ parameter)"