backend/py/vcf_parser.py
def convert_protein_mutations_from_3_to_1_letters(muts: [list, set], is_strict_check=True):
        """
        Convert protein mutations from 3-letter acids to 1-letter acid format. Example: "p.Thr5262Ile" -> "T5262I"
        """
        new_muts = []
        for mut in muts:
            m = re.match(r"p\.(?P<acid1>[A-Z][a-z][a-z])(?P<pos>\d+)(?P<acid2>[A-Z][a-z][a-z])", mut)
            try:
                assert m, "Unexpected format (correct example: 'p.Thr42Ser')."
                acid1 = m['acid1']
                acid2 = m['acid2']
                assert acid1 in protein_letters_3to1_extended, f'Cannot recognize acid1: {acid1}'
                assert acid2 in protein_letters_3to1_extended, f'Cannot recognize acid2: {acid2}'
                new_acid1 = protein_letters_3to1_extended[acid1]
                new_acid2 = protein_letters_3to1_extended[acid2]
                new_mut = f"{new_acid1}{m['pos']}{new_acid2}"
                new_muts.append(new_mut)
            except AssertionError as e:
                if is_strict_check:
                    raise ValueError(f"Error while parsing protein mutation '{mut}': {e}.")
                # Cannot sort out stderr from stdout on the backend side, so no warnings for now
                #else:
                #    eprint(f"Warning while parsing protein mutation '{mut}' -> it will be skipped. Details: {e}")
        return new_muts

        Convert protein mutations from 3-letter acids to 1-letter acid format. Example: "p.Thr5262Ile" -> "T5262I"
        
Convert protein mutations from 3-letter acids to 1-letter acid format.
Convert protein mutations from 3 - letter acids to 1 - letter acid format .
def convert_protein_mutations_from_3_to_1_letters(muts: [list, set], is_strict_check=True):
        new_muts = []
        for mut in muts:
            m = re.match(r"p\.(?P<acid1>[A-Z][a-z][a-z])(?P<pos>\d+)(?P<acid2>[A-Z][a-z][a-z])", mut)
            try:
                assert m, "Unexpected format (correct example: 'p.Thr42Ser')."
                acid1 = m['acid1']
                acid2 = m['acid2']
                assert acid1 in protein_letters_3to1_extended, f'Cannot recognize acid1: {acid1}'
                assert acid2 in protein_letters_3to1_extended, f'Cannot recognize acid2: {acid2}'
                new_acid1 = protein_letters_3to1_extended[acid1]
                new_acid2 = protein_letters_3to1_extended[acid2]
                new_mut = f"{new_acid1}{m['pos']}{new_acid2}"
                new_muts.append(new_mut)
            except AssertionError as e:
                if is_strict_check:
                    raise ValueError(f"Error while parsing protein mutation '{mut}': {e}.")
        return new_muts
def convert_protein_mutations_from_3_to_1_letters ( muts : [ list , set ] , is_strict_check = True ) : new_muts = [ ] for mut in muts : m = re . match ( r"p\.(?P<acid1>[A-Z][a-z][a-z])(?P<pos>\d+)(?P<acid2>[A-Z][a-z][a-z])" , mut ) try : assert m , "Unexpected format (correct example: 'p.Thr42Ser')." acid1 = m [ 'acid1' ] acid2 = m [ 'acid2' ] assert acid1 in protein_letters_3to1_extended , f'Cannot recognize acid1: {acid1}' assert acid2 in protein_letters_3to1_extended , f'Cannot recognize acid2: {acid2}' new_acid1 = protein_letters_3to1_extended [ acid1 ] new_acid2 = protein_letters_3to1_extended [ acid2 ] new_mut = f"{new_acid1}{m['pos']}{new_acid2}" new_muts . append ( new_mut ) except AssertionError as e : if is_strict_check : raise ValueError ( f"Error while parsing protein mutation '{mut}': {e}." ) return new_muts
Convert protein mutations from 3-letter acids to 1-letter acid format.
Convert protein mutations from 3 - letter acids to 1 - letter acid format .
"""
        Convert protein mutations from 3-letter acids to 1-letter acid format. Example: "p.Thr5262Ile" -> "T5262I"
        """ # Cannot sort out stderr from stdout on the backend side, so no warnings for now #else: #    eprint(f"Warning while parsing protein mutation '{mut}' -> it will be skipped. Details: {e}")
muts
[list, set]
is_strict_check