Package: evo-prot-grad
EvoProtGradA Python package for directedevolution on aprotein sequence withgradient-based discrete Markov chain monte carlo (MCMC). Users are able to compose their custom protein models that map sequence to function with various pretrained models, including protein language models (PLMs), to guide and constrain search. The library is designed to natively integrate with 🤗 HuggingFace and supports PLMs from thetransformerslibrary.The underlying search technique is based on a variant of discrete MCMC that uses gradients of adifferentiablecompositional target function to rapidly explore a protein's fitness landscape in sequence space.
We allow users to compose their own custom target function for MCMC by leveraging the Product of Experts MCMC paradigm.
Each model is an "expert" that contributes its own knowledge about the protein's fitness landscape to the overall target function.
Our MCMC sampler is designed to be more efficient and effective than brute force and random search while maintaining most of the generality and flexibility.See ourpublicationand ourdocumentationfor more details.InstallationEvoProtGrad is available on PyPI and can be installed with pip:pipinstallevo_prot_gradIf you wish to run tests or register a new expert model with EvoProtGrad, please clone this repo and install in editable mode as follows:gitclonehttps://github.com/NREL/EvoProtGrad.gitcdEvoProtGrad
pipinstall-e.Basic UsageCreate aProtBERTexpert from a pretrained HuggingFace protein language model (PLM) usingevo_prot_grad.get_expert:importevo_prot_gradprot_bert_expert=evo_prot_grad.get_expert('bert',temperature=1.0)The default BERT-style PLM inEvoProtGradisRostlab/prot_bert. Normally, we would need to also specify the model and tokenizer. When using a default PLM expert, we automatically pull these from the HuggingFace Hub. The temperature parameter rescales the expert scores and can be used to trade off the importance of different experts. For masked language models likeprot_bert, we score variant sequences with the sum of amino acid log probabilities by default.Then, create an instance ofDirectedEvolutionand run the search, returning a list of the best variant per Markov chain (as measured by theprot_bertexpert):variants,scores=evo_prot_grad.DirectedEvolution(wt_fasta='test/gfp.fasta',# path to wild type fasta fileoutput='best',# return best, last, all variantsexperts=[prot_bert_expert],# list of experts to composeparallel_chains=1,# number of parallel chains to runn_steps=20,# number of MCMC steps per chainmax_mutations=10,# maximum number of mutations per variantverbose=True# print debug info to command line)()We provide a few  experts inevo_prot_grad/expertsthat you can use out of the box, such as:Protein Language Models (PLMs)bert, BERT-style PLMs, default:Rostlab/prot_bertcausallm, CausalLM-style PLMs, default:lightonai/RITA_sesm, ESM-style PLMs, default:facebook/esm2_t6_8M_UR50DPotts modelsevcouplingsand an generic expert for supervised downstream regression modelsonehot_downstream_regressionSeedemo.ipynbto get started right away in a Jupyter notebook.CitationIf you use EvoProtGrad in your research, please cite the following publication:@article{emami2023plug,title={Plug \& play directed evolution of proteins with gradient-based discrete MCMC},author={Emami, Patrick and Perreault, Aidan and Law, Jeffrey and Biagioni, David and John, Peter St},journal={Machine Learning: Science and Technology},volume={4},number={2},pages={025014},year={2023},publisher={IOP Publishing}}