Computational prediction of the interaction between human leukocyte antigen (HLA) and peptide (pHLA) can speed up epitope screening and vaccine design. Here, we develop the TransMut framework composed of TransPHLA for pHLA binding prediction and AOMP for mutated peptide optimization, which can be generalized to any binding and mutation task of biomolecules. Firstly, TransPHLA is developed by using a Transformer-derived self-attention model to predict pHLA binding, which is significantly superior to 11 previous methods on pHLA binding prediction, neoantigen and human papilloma virus vaccine identification. For vaccine design, the AOMP program is then developed to automatically optimize mutated peptides to search for mutant peptides with higher affinity to the target HLA and with high homology to the source peptide. Among 3660 non-binding pHLAs, 3630 were successfully mutated. Of these, 94% were verified by the IEDB recommended method, and 88% have homology higher than 80% to the source peptide.