CoolFace
Modelpublic

adibvafa/CodonTransformer-base

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
1likes313downloads
README.md126 linesDownload Raw Back to root
1---2library_name: transformers3tags:4- CodonTransformer5- Computational Biology6- Machine Learning7- Bioinformatics8- Synthetic Biology9license: apache-2.010pipeline_tag: token-classification11---12 13![image/png](https://github.com/Adibvafa/CodonTransformer/raw/main/src/banner_final.png)14 15**CodonTransformer** is the ultimate tool for codon optimization, transforming protein sequences into optimized DNA sequences specific for your target organisms. Whether you are a researcher or a practitioner in genetic engineering, CodonTransformer provides a comprehensive suite of features to facilitate your work. By leveraging the Transformer architecture and a user-friendly Jupyter notebook, it reduces the complexity of codon optimization, saving you time and effort.16<br>17 18**This is the pretrained model, for best results please use the [finetuned model](https://huggingface.co/adibvafa/CodonTransformer)**.19 20## Authors21Adibvafa Fallahpour<sup>1,2</sup>\*, Vincent Gureghian<sup>3</sup>\*, Guillaume J. Filion<sup>2</sup>‡,  Ariel B. Lindner<sup>3</sup>‡,  Amir Pandi<sup>3</sup>‡22 23<sup>1</sup> Vector Institute for Artificial Intelligence, Toronto ON, Canada  24<sup>2</sup> University of Toronto Scarborough; Department of Biological Science; Scarborough ON, Canada  25<sup>3</sup> Université Paris Cité, INSERM U1284, Center for Research and Interdisciplinarity, F-75006 Paris, France  26\* These authors contributed equally to this work.  27‡ To whom correspondence should be addressed: <br>28guillaume.filion@utoronto.ca, ariel.lindner@inserm.fr, amir.pandi@cri-paris.org29<br>30 31## Use Case32**For a guide on finetuning CodonTransformer, check out our [GitHub.](https://github.com/Adibvafa/CodonTransformer/tree/main?tab=readme-ov-file#finetuning-codontransformer)**33<br>**For an interactive demo, check out our [Google Colab Notebook.](https://adibvafa.github.io/CodonTransformer/GoogleColab)**34<br></br>35After installing CodonTransformer, you can use:36```python37import torch38from transformers import AutoTokenizer, BigBirdForMaskedLM39from CodonTransformer.CodonPrediction import predict_dna_sequence40from CodonTransformer.CodonJupyter import format_model_output41device = torch.device("cuda" if torch.cuda.is_available() else "cpu")42 43 44# Load model and tokenizer45tokenizer = AutoTokenizer.from_pretrained("adibvafa/CodonTransformer")46model = BigBirdForMaskedLM.from_pretrained("adibvafa/CodonTransformer-base").to(device)47 48 49# Set your input data50protein = "MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGG"51organism = "Escherichia coli general"52 53 54# Predict with CodonTransformer55output = predict_dna_sequence(56    protein=protein,57    organism=organism,58    device=device,59    tokenizer=tokenizer,60    model=model,61    attention_type="original_full",62    deterministic=True63)64print(format_model_output(output))65```66The output is:67<br>68 69 70```python71-----------------------------72|          Organism         |73-----------------------------74Escherichia coli general75 76-----------------------------77|       Input Protein       |78-----------------------------79MALWMRLLPLLALLALWGPDPAAAFVNQHLCGSHLVEALYLVCGERGFFYTPKTRREAEDLQVGQVELGG80 81-----------------------------82|      Processed Input      |83-----------------------------84M_UNK A_UNK L_UNK W_UNK M_UNK R_UNK L_UNK L_UNK P_UNK L_UNK L_UNK A_UNK L_UNK L_UNK A_UNK L_UNK W_UNK G_UNK P_UNK D_UNK P_UNK A_UNK A_UNK A_UNK F_UNK V_UNK N_UNK Q_UNK H_UNK L_UNK C_UNK G_UNK S_UNK H_UNK L_UNK V_UNK E_UNK A_UNK L_UNK Y_UNK L_UNK V_UNK C_UNK G_UNK E_UNK R_UNK G_UNK F_UNK F_UNK Y_UNK T_UNK P_UNK K_UNK T_UNK R_UNK R_UNK E_UNK A_UNK E_UNK D_UNK L_UNK Q_UNK V_UNK G_UNK Q_UNK V_UNK E_UNK L_UNK G_UNK G_UNK __UNK85 86-----------------------------87|       Predicted DNA       |88-----------------------------89ATGGCTTTATGGATGCGTCTGCTGCCGCTGCTGGCGCTGCTGGCGCTGTGGGGCCCGGACCCGGCGGCGGCGTTTGTGAATCAGCACCTGTGCGGCAGCCACCTGGTGGAAGCGCTGTATCTGGTGTGCGGTGAGCGCGGCTTCTTCTACACGCCCAAAACCCGCCGCGAAGCGGAAGATCTGCAGGTGGGCCAGGTGGAGCTGGGCGGCTAA90```91 92 93## Additional Resources94- **Project Website** <br>95  https://adibvafa.github.io/CodonTransformer/96 97- **GitHub Repository** <br>98  https://github.com/Adibvafa/CodonTransformer99 100- **Google Colab Demo** <br>101  https://adibvafa.github.io/CodonTransformer/GoogleColab102 103- **PyPI Package** <br>104  https://pypi.org/project/CodonTransformer/105 106- **Paper** <br>107  https://www.nature.com/articles/s41467-025-58588-7108 109 110## Citation111```112@article{Fallahpour_Gureghian_Filion_Lindner_Pandi_2025,113  title={CodonTransformer: a multispecies codon optimizer using context-aware neural networks},114  volume={16},115  ISSN={2041-1723},116  url={https://www.nature.com/articles/s41467-025-58588-7},117  DOI={10.1038/s41467-025-58588-7},118  number={1},119  journal={Nature Communications},120  author={Fallahpour, Adibvafa and Gureghian, Vincent and Filion, Guillaume J. and Lindner, Ariel B. and Pandi, Amir},121  year={2025},122  month=apr,123  pages={3205},124  language={en}125}126```