Cancer immunotherapy has been among the most promising breakthroughs in oncology, particularly in the case of immune check point inhibitors, however, the effective response rate remains quite low, only about 20-30%. In this talk, I will talk about our recent collaborative work which solves one mystery behind this low response rate with molecular modeling and machine learning techniques. We found that patients with certain HLA genotype (HLA-B44) have consistently higher survival rate, while patients with some other type (HLA-B15) have much poorer survival rates. It’s also shown that patients harboring tumors with very high mutation rates responded disproportionately well to these immune checkpoint inhibitor treatments. Large scale molecular dynamics simulations further reveal that HLA-B15 proteins with poorer therapeutic outcomes had structural appendages (HLA bridges with residues Arg62, Ile66, and Leu163) that closed over the cancer neoantigens with much less flexibility. The same techniques have also been applied to the design and development of vaccines for HIV and T1D, which has been of great interest as well in recent years. With a combined in silico and in vivo approach, we studied the TCR/peptide/HLA interactions from multiple clonotypes specific for a well-defined HIV-1 epitope, and found that effective and ineffective clonotypes bind to the terminal portions of the peptide-HLA through similar salt bridges, but their hydrophobic side-chain packings can be very different, which accounts for the major part of the differences among these clonotypes. Meanwhile, a novel super potent autoantigen has been identified for T1D, which opens new door for potential T1D vaccine. Together with state-of-the-art free energy perturbation calculations for point mutations on antigens, our results clearly indicate a direct structural basis for heterogeneous T cell function.