
CAZyLingua
Predict carbohydrate-active enzyme families from protein embeddings using a random forest model with a neural network.
About this notebook
CAZyLingua predicts carbohydrate-active enzyme families from protein sequences. You upload an H5 file with ProtT5 protein embeddings, one 1024-dimension vector per sequence. A random forest classifier first labels each protein as a CAZyme or not. A neural network then predicts the specific CAZyme family for each hit. The notebook uses marimo, h5py, numpy, scikit- learn, PyTorch, PyTorch Lightning, polars, and altair.
A file area accepts the H5 upload. A slider sets the random forest probability threshold between 0.5 and 1.0, with a default of 0.97. A button starts the CAZyme prediction, and a progress bar reports the count, rate, and estimated time. A callout states how many CAZymes the model found among the input sequences. A second button starts the family classification. The reader then sees a result table, a top-ten families bar chart, a CAZy class distribution arc chart, and a prediction probability histogram. Download buttons export the predicted CAZyme embeddings as H5 and the family predictions as a TSV file.
The random forest model loads from a joblib file with memory mapping, and functools.cache keeps it in memory across reruns. The family model is a PyTorch Lightning checkpoint with linear layers that map 1024 inputs to 574 output classes. The notebook runs proteins through the random forest in batches of 50000 and through the neural network in batches of 128. A scikit- learn LabelEncoder maps model outputs back to family names, read from a JSON taxa mapping file. The method comes from Thurimella et al., BMC Bioinformatics 2025.











