Dry Lab

HMM generation methods

How the seed alignments were built and cleaned, how the 53 catalytic HMMs were built iteratively under a canonical-residue constraint, and the sweep over symfrac, E-value and iteration count that settled their parameters.

Why build our own HMMs?

The nr search returns sequences that are predicted to be homologous to plastic-degrading enzymes, but we cannot confidently say they contain the domains needed to catalyse the degradation of plastic polymers. To make that claim we need HMMs seeded from the catalytic domains of the verified enzymes themselves.

I realised that last time I made these HMMs, I had no way of figuring out whether they were overfitting. So this time the HMMs are built on hits below E-10 and judged on the hold-out band between E-10 and E-5. Restricting what can enter an HMM to the stronger hits forces it to represent the query sequences rather than the whole database.

The HMMs get used six ways:

  1. Extracting only the catalytic domain for the Logan search, so we do not pay to search accessory domains.
  2. Annotating catalytic domains for each sequence on the website.
  3. Annotating catalytic residues.
  4. Annotating secondary residues — important but non-catalytic.
  5. Telling us which Logan sequences are non-fragmented, since an assembly is inherently fragmented and a full HMM hit is the evidence of completeness.
  6. Finding motifs in the HMM logos, which may inform mechanistic analysis.

That fifth use needs care, because a half-covered catalytic domain has three very different causes:

  • A. Only half the domain is homologous enough to hit the HMM — a lower-quality homolog.
  • B. There is a large insertion between the two halves, so only half is hit — a higher-quality homolog with a solvable problem.
  • C. The edge of the hit is the true edge of the domain — the domain really is fragmented.

Telling A, B and C apart requires confidence that the HMMs themselves are good, which means the seed alignments have to be good. That is what this page is about.

Inputs

ComponentVersion usedNotes
MUSCLE5.3Super5 for the first pass, PPP for the final alignments
DIAMOND2.2.4.184linclust for clustering close homologs
HMMER3.4 (Aug 2023)hmmbuild, hmmalign, hmmsearch
AFRAGMENTER0.0.6Cuts structures into domains for envelope validation
HHalign / HHmake3.3.0Probability of homology between finished HMMs
Easel0.49esl-reformat
networkx3.6.1Minimum spanning tree over the HMMs

Inputs are the PETadex-PAZy proteins, their structures, and the significant nr hits from the previous step.

Annotating the catalytic residues

To decide what a good alignment even looks like, I went through each CATH domain and learned as much about it as I could: the mechanism, and which residues matter. Those annotations are what let me infer the catalytic mechanism of each component and build a reference sequence for each one. The annotations were made on a representative per CATH domain and then propagated to a representative for each sub-component.

Seeding the alignments with close homologs

A problem I keep hitting is that HMMs built from very few sequences — under ten — have terrible seed alignments. With that few sequences there is no way to tell a conserved column from an accident.

Figure 1. The C034 alignment built from PETadex-PAZy sequences alone. With this few sequences there is nothing to distinguish a conserved column from an accident, which is why the seed alignments were padded with close homologs first.

So the seeds are padded with close nr homologs, taken at DIAMOND E < 1.0 × 10⁻⁵⁰ to keep them very homologous to PETadex-PAZy. That still produces thousands of highly redundant sequences per component, so they are clustered at an identity chosen from the component's size:

Sequences in componentClustered at
50,000+30% identity
10,000+50% identity
100+70% identity
1+90% identity

Tuning the clustering to the sequence count gives a subset small enough to align without becoming gappy, but large enough to show which columns are the consensus columns. The target is roughly 100–1,000 sequences per alignment.

The first alignment pass uses MUSCLE's Super5 algorithm, which trades accuracy for speed. That is fine here, because these sequences are going to be cleaned and re-aligned anyway.

Splitting components into sub-components

Looking at the alignments at the catalytic residue columns, eleven sub-components needed to be split out of their parent: five from C001 (PL121, PL69, PL214, PL120, PL119), one from C006 (PL88), one from C008 (PL46), and four from C014 (PL453/PL164/PL166/PL187, PL114, PL74, PL115).

Dropping sequences that miss the catalytic columns

Every sequence entering an alignment has to carry the canonical catalytic residues of its CATH domain. This keeps functional diversity inside an HMM from getting too wide, so the seed alignments hold only sequences that align properly and have the right residues.

Trimming the accessory domains by hand

With smallish alignments per component, I could go through them and clean them up. The main thing I removed was accessory domains. These are why each alignment took so long to run — overnight — since they forced alignments upwards of 50,000 columns long to accommodate unalignable accessory regions.

The rule I used: find the first column that is highly conserved for a residue — no hard cutoff, but generally above 50% conservation and above 50% of maximum quality — and remove everything to its left. Then do the same with the last highly conserved column and remove everything to its right. Having the first and last column of the alignment be highly conserved is what keeps the HMM on the catalytic domain.

Re-aligning with PPP

With accessory domains gone, the alignments were rebuilt with MUSCLE's PPP algorithm instead of Super5, which improves their quality. C016 was taking far too long under PPP, so it stayed on Super5.

Four sub-components with no HMM

Four sub-components were dropped rather than modelled:

  • C001-5 and C008-1 have about one nr homolog each, and building an HMM off one sequence is not worthwhile. On investigation, PL119 (the C001-5 representative) is actually a fragment that somehow had activity — my guess is the 6×His tag helped — and for PL46 I have no idea what the mechanism is.
  • C001-4 and C014-4 were suspiciously missing catalytic residues. C001-4 turns out to be a fragment, and for C014-4 I cannot work out what the mechanism could be. Without a mechanism there is no way to measure HMM quality, so neither got one.

All four keep their annotations in the reference sheet.

Figure 2. C001-4's representative, PL120, against its component. The sequence stops partway through the catalytic domain — it is a fragment, which is why C001-4 never got an HMM.

The iterative build

The build pipeline is comparable to JackHMMER, with one addition: a sequence can only enter the next iteration if it carries the canonical catalytic residues.

  1. hmmbuild the HMM from the input MSA.
  2. hmmalign the HMM to the reference sequence, to transfer the catalytic site annotations.
  3. hmmsearch the HMM against its component's fasta.
  4. Parse the output into an alignment of only those domain hits that contain every catalytic residue — exact matches to the residue identity — and fall below the E-value cutoff. If a sequence has two catalytic domains that both pass, both are added.
  5. Annotate columns above the coverage threshold as match states and the rest as insertions.
  6. Seed the resulting MSA into the next iteration and repeat.

Training and validation sets

The sets are the significant nr hits plus the PETadex-PAZy proteins, which go into training only:

SetDefinitionSequences
Trainingnr hits below E-10, plus the PETadex-PAZy proteins5,997,120
Validationnr hits between E-10 and E-51,828,480

Those sum to 7,825,600, which is the 7,825,107 significant nr sequences plus the 493 PETadex-PAZy proteins. Both sets are split per component, which cuts the pipeline's run time substantially.

Choosing symfrac, E-value and iteration count

I wanted to test different --symfrac values, E-value cutoffs and iteration counts, so the sweep ran only on components whose hmmsearch takes about three seconds — C001, C013, C041 and C045 — rather than overnight on everything.

COMBOS=("0.5 1e-5" "0.5 1e-10" "0.5 1e-15"
        "0.7 1e-5" "0.7 1e-10" "0.7 1e-15"
        "0.9 1e-5" "0.9 1e-10" "0.9 1e-15")
ITERATIONS="1_plasticome.v2,2_unrefined_petadex,3_refined_petadex,4_overkill,5_overkill_overkill"
NCBI_SIZE=1101054423   # passed to hmmsearch as --total-search-size

Five iterations because JackHMMER's maximum is five, so that is the number worth testing to.

Does the HMM stay inside the catalytic domain?

It is hard to tell how good an HMM is without looking at where it hits on a protein. Making that automatic meant taking as many structures of the nr hits as possible and finding their domain boundaries, then measuring what portion of the catalytic domain the HMM covers. The structure mapping holds 575,770 rows (126 skipped for a malformed component id); up to 1,000 structures per component were sampled, giving 36,322 structures, of which 36,321 were cut successfully by AFRAGMENTER — the one failure was a 404 from AlphaFold DB.

One thing the analysis has to allow for: catalytic domains are often cut at lids or caps, because those regions are flexible. A hit spanning a lid has to be compared against the whole catalytic domain, not against half of one.

Figure 3. AFRAGMENTER cutting an α/β hydrolase at its lid and its N-terminal extension rather than at a true domain boundary. This is why hit ranges are scored against the whole catalytic domain.
Figure 4. Share of the AFRAGMENTER domain covered by the HMM hit, one violin per iteration at symfrac 0.7. Coverage plateaus after iteration 2, while the number of domains with no hit at all creeps up across the five iterations.

Coverage is about 90% of the domain for most components. The exceptions: C001, C012, C026, C028 and C039 average about 80%, C014 and C027 about 70%, and C015 about 50%. Out-of-domain coverage averages 10% or less almost everywhere, with C006 around 25% — bimodal near 0 and 50 — and C008 around 30%. There are stragglers that hit far outside the catalytic domain; C014's apparent 1400% is an AFRAGMENTER artefact, where a cut site landed about five residues inside the catalytic domain and that five-residue insert became the thing being measured against. I could fix that by tuning AFRAGMENTER, but I do not think it is worth the time.

The parameters we settled on

symfrac. There is no significant difference between 0.7 and 0.9: both give about the same number of catalytically complete hits and total hits, and hit about the same regions. The one real difference is that 0.9 fails for C015 while 0.7 works, so 0.7 it is.

Iterations. Little separates iterations 3 through 5, but 5 has slightly negative effects — reducing hits, and the hit region becoming less accurate — and 3 does not plateau. So 4, as the middle of the two, minimising both problems.

The final HMMs are the symfrac 0.7, E 1e-10, iteration 4 builds, and the file name is the parameter record:

cp symfrac0.7_evalue1e-10__4_overkill__plasticome.component_${id}.hmm \
   petadex.v260701-${id}.hmm

Per-component quality, as it stands:

Component% outside domain% inside domainFragmentation
C001~80%under half the hits are fragments (C001-1) or missing fragments (C001-2)
C003under half the hits are fragments
C006~25% (bimodal, ~0 and ~50)missing fragments (C006-1)
C008~30%under half the hits are fragments
C009missing fragments
C010under half the hits are fragments
C012~80%
C014~70%missing fragments
C015~50%
C018missing fragments
C023under half the hits are fragments
C026~80%
C027~70%missing fragments
C028~80%missing fragments
C039~80%

Looking at the hits on the structures

I also wanted to look at the hit regions on the structures by hand, to see how much of each domain is really covered and whether the catalytic residue annotations are right. For each final HMM the script samples up to four complete hits, three fragment hits missing a catalytic position, and three structures with no hit at all. A structure is only picked for the HMM that gives it its lowest E-value within its component.

The annotation style, for reading those images:

  • the protein is a white cartoon
  • each HMM domain hit gets its own colour in sequence order
  • catalytic residues are hot pink sticks, labelled with the residue actually found there, with a yellow outline where it is not the expected amino acid
  • residues within 5 Å of a catalytic residue are thin, element-coloured sticks

Three findings from that pass are worth keeping on the record:

  • C010, C017, C019 and C030 have non-hydrolase regions inside the HMM envelope. They are genuinely part of the protein and arguably the same domain, but I believe they have another function — a transmembrane domain — so they should come out of the input MSAs.
  • C001-2 and C014-2 have no AlphaFold DB structures to look at, so this validation was never run on them. They have very few nr hits, which makes those two HMMs hard to evaluate at all.
  • C001-1's histidine looks to be in the wrong position. The actual protein does have a histidine there, but all of its homologs have it somewhere else. This protein is one of the strange Erickson fragments. I am keeping the annotation, in the hope it tells us something about that protein, but otherwise this one should be taken with a grain of salt.

How the 53 HMMs relate to each other

Finally, I wanted to see how similar the finished HMMs are, so the 53 of them are laid out as a minimum spanning tree whose edges are the probability of homology given by HHalign. In theory each component should be its own cluster; in practice that is only partly true.

Figure 5. Minimum spanning tree over the 53 final HMMs, edges labelled with the HHalign probability of homology. The α/β hydrolases dominate and cluster around C001 and C034, while the DD-peptidase and serine protease groups sit apart and a number of HMMs stand alone.

Limitations

  • Four sub-components have no HMM (C001-4, C001-5, C008-1, C014-4), so sequences belonging to them are only ever caught by their parent component's model.
  • C001-2 and C014-2 were never structurally validated, for want of AlphaFold DB structures.
  • C015 is the weakest model, covering about half its catalytic domain on average, and it is also the component that forced symfrac 0.7 over 0.9.
  • The AFRAGMENTER boundaries are predictions, not truth. C014's 1400% out-of-domain figure is a cut-site artefact rather than an HMM failure, and the same class of error will inflate other out-of-domain numbers to a smaller degree.
  • The non-hydrolase regions in C010, C017, C019 and C030 are still inside the envelope of the HMMs as built here.

Reproducing

# per component: build, transfer catalytic annotations, search, re-seed, four times
./iterative_hmmbuild.sh \
  --msa plasticome.component_${id}.afa \
  --targets training/${id}.fastaa \
  --symfrac 0.7 --evalue 1e-10 --iterations 4 \
  --total-search-size 1101054423

# the iteration-4 build is the shipped model
cp symfrac0.7_evalue1e-10__4_overkill__plasticome.component_${id}.hmm \
   petadex_hmms/petadex.v260701-${id}.hmm