Created
December 15, 2022 03:49
-
-
Save kwcooper/2174cb4aea0299c824ed0cbd19015907 to your computer and use it in GitHub Desktop.
Simple function to mutate a string of amino acids given their indicies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mutate_amino(protein_str, mutations, offset=1): | |
''' mutations: {int>mutation_idx:str>AminoID}''' | |
mut_protein_str = list(protein_str) | |
for mut_idx in mutations.keys(): | |
mut_protein_str[mut_idx-offset] = mutations[mut_idx] # Arg 71 His | R > H | |
mut_protein_str = ''.join(mut_protein_str) | |
return mut_protein_str | |
protein_str = "MISPFLVLAIGTCLTNSLVPEKEKDPKYWRDQAQETLKYALELQKLNTNVAKNVIMFLGDGMGVSTVTAARILKGQLHHNPGEETRLEMDKFPFVALSKTYNTNAQVPDSAGTATAYLCGVKANEGTVGVSAATERSRCNTTQGNEVTSILRWAKDAGKSVGIVTTTRVNHATPSAAYAHSADRDWYSDNEMPPEALSQGCKDIAYQLMHNIRDIDVIMGGGRKYMYPKNKTDVEYESDEKARGTRLDGLDLVDTWKSFKPRYKHSHFIWNRTELLTLDPHNVDYLLGLFEPGDMQYELNRNNVTDPSLSEMVVVAIQILRKNPKGFFLLVEGGRIDHGHHEGKAKQALHEAVEMDRAIGQAGSLTSSEDTLTVVTADHSHVFTFGGYTPRGNSIFGLAPMLSDTDKKPFTAILYGNGPGYKVVGGERENVSMVDYAHNNYQAQSAVPLRHETHGGEDVAVFSKGPMAHLLHGVHEQNYVPHVMAYAACIGANLGHCAPASSAGSLAAGPLLLALALYPLSVLF" | |
mutations = {71:'H', 263:'H', 522:'A'} | |
mut_str = mutate_amino(protein_str, mutations) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment