def add_amino_acid_to_json(code, description, letter='X', modified=None, force_add=False):
    """ Add an amino acid to the amino_acids.json file used to populate the amino_acid table.

    Parameters
    ----------
    code : str
        New code to be added to amino acid table.
    description : str
        Description of the amino acid, e.g. 'amidated terminal carboxy group'.
    letter : str, optional
        One letter code for the amino acid.
        Defaults to 'X'
    modified : str or None, optional
        Code of modified amino acid, e.g. 'ALA', or None.
        Defaults to None
    force_add : bool, optional
        If True, will over-write existing dictionary value for code if already in amino_acids.json.
        If False, then an IOError is raised if code is already in amino_acids.json.

    Raises
    ------
    IOError
        If code is already in amino_acids.json and force_add is False.

    Returns
    -------
    None

    """
    # If code is already in the dictionary, raise an error
    if (not force_add) and code in amino_acids_dict.keys():
        raise IOError("{0} is already in the amino_acids dictionary, with values: {1}".format(
            code, amino_acids_dict[code]))

    # Prepare data to be added.
    add_code = code
    add_code_dict = {'description': description, 'letter': letter, 'modified': modified}

    # Check that data does not already exist, and if not, add it to the dictionary.
    amino_acids_dict[add_code] = add_code_dict

    # Write over json file with updated dictionary.
    with open(_amino_acids_json_path, 'w') as foo:
        foo.write(json.dumps(amino_acids_dict))

    return
def add_amino_acid_to_json ( code , description , letter = 'X' , modified = None , force_add = False ) : if ( not force_add ) and code in amino_acids_dict . keys ( ) : raise IOError ( "{0} is already in the amino_acids dictionary, with values: {1}" . format ( code , amino_acids_dict [ code ] ) ) add_code = code add_code_dict = { 'description' : description , 'letter' : letter , 'modified' : modified } amino_acids_dict [ add_code ] = add_code_dict with open ( _amino_acids_json_path , 'w' ) as foo : foo . write ( json . dumps ( amino_acids_dict ) ) return
Add an amino acid to the amino_acids.json file used to populate the amino_acid table.

    Parameters
    ----------
    code : str
        New code to be added to amino acid table.
    description : str
        Description of the amino acid, e.g. 'amidated terminal carboxy group'.
    letter : str, optional
        One letter code for the amino acid.
        Defaults to 'X'
    modified : str or None, optional
        Code of modified amino acid, e.g. 'ALA', or None.
        Defaults to None
    force_add : bool, optional
        If True, will over-write existing dictionary value for code if already in amino_acids.json.
        If False, then an IOError is raised if code is already in amino_acids.json.

    Raises
    ------
    IOError
        If code is already in amino_acids.json and force_add is False.

    Returns
    -------
    None