HGVS (Human Genome Variation Society) aims to standardize representation of variants across global research communities. HGVS has set certain notations for representing genomic (DNA), coding (RNA and cDNA) and protein variations. Protein variation syntax outlines the effect of variation on protein primary structure. There are several tools that can translate genomic variants to protein variants via calculation. 

There are two common ways to represent amino acids. By single letter and By three letters.  A 3 letter representation is as follows : p.ser2ala, followed by protein accession number (some times with version). Some people prefer single letter representation like p.S2A. However, as tools are varied, these letters can be upper case, lower case, mixed case, all sorts of cases. 

I wrote a python script that converts three letter code to single letter code and single letter code to three letter code.

Example input for 3 letter code:
=====================
NP1457:p.ser2ala
p.ala3tyr
NP123.1:p.Tyr3pHe
=====================

Output for example 3 letter code:
======================
NP1457:p.ser2ala    NP1457:p.S2A
p.ala3tyr    p.A3Y
NP123.1:p.Tyr3pHe    NP123.1:p.Y3F
======================

Example input for single letter code:
======================
p.a2G
NP.2123:p.C2p
p.D3e
======================

Output for example single letter code input:
========================
p.a2G     p.Ala2Gly
NP.2123:p.C2p     NP.2123:p.Cys2Pro
p.D3e     p.Asp3Glu
=======================

here is the code:
===========================
## Import libraries
import os
import re

## Ask user about the length of the codon and path of the file.
number= input('Codon length in your file. 1 or 3?: ')
user_input=input('Please input file path. File should have one column with pSyntax: ')

## Write a function to convert one letter to 3 letter and vice versa
def psyntax_convert(number,user_input):
    ''' converts HGVS pSyntax into one and three letter representations'''
    if os.path.exists(user_input):
        print (user_input+ " file exists. Output file name is output.txt")
    else:
        print (user_input+" file doesn't exist..aborting")
        sys.exit(1)       
    with open (user_input, "r") as f:
        user_input=f.read()
    re_input=re.findall(r"(.*:*p\.)(\w+)(\d+)(\w+)",user_input,re.IGNORECASE)
    if len(re_input[0][1])==3:
        print("3 letter HGVS syntax will be converted to 1 letter syntax")
    elif len(re_input[0][1])==1:
        print("1 letter HGVS syntax will be converted to 3 letter syntax")
    re_input_list=[list(i) for i in re_input]
   
    if int(number)==1:
        for i in re_input_list:
            i[1]=single_syntax_dict.get(i[1].capitalize())
            i[3]=single_syntax_dict.get(i[3].capitalize())
       
    if int(number)==3:
        for i in re_input_list:
            i[1]=three_syntax_dict.get(i[1].capitalize())
            i[3]=three_syntax_dict.get(i[3].capitalize())      
   
    with open ("output.txt","w") as f:
        for i, j in zip(re_input, re_input_list):
            print("".join(i), "".join(j),sep='\t', file=f)

## This is the dictionary for 3 letter to 1 letter
three_syntax_dict= {'Ala': 'A', 'Arg': 'R', 'Asn': 'N', 'Asp': 'D', 'Cys': 'C',
                    'Gln': 'Q', 'Glu': 'E', 'Gly': 'G', 'His': 'H', 'Ile': 'I',
                    'Leu': 'L', 'Lys': 'K', 'Met': 'M', 'Phe': 'F', 'Pro': 'P',
                    'Pyl': 'O', 'Ser': 'S', 'Sec': 'U', 'Thr': 'T', 'Trp': 'W',
                    'Tyr': 'Y', 'Val': 'V', 'Asx': 'B', 'Glx': 'Z', 'Xaa': 'X',
                    'Xle': 'J', 'Ter': '*'}
## Invert above dictionary for 1 letter to 3 letter code
single_syntax_dict={v:k for k,v in three_syntax_dict.items()}

## Function for executing the conversion function and print the final command
def main():
    '''Executes conversion function and prints success message'''
    psyntax_convert(number,user_input)
    if os.path.exists("output.txt"):
       print ("conversion done. Output.txt is present in "+os.getcwd())
##  Execute the main function
main()
===============================

You can download  jupyter notebook on my github page from python_scripts repo.

Note: Copy/paste from the web may mess up the indentation. Take care of indentation before you execute the code.