def phosphorylate_pdb_file(pdb_fn, edition_list, pdb_mut_fname, write=True):
    """
    Mutates the serines in the pdb provided as a filename
    to phosphoserines.

    Parameters
    ----------
    pdb_fn: str, Name of the PDB file
    edition_list: list of tuples, The list of the editions to make.
        Each of the elements in the list has to be a tuple like this one:
            ('SER', 271, 'S1P')
            1st arg is the resname to change 'SER'
            2nd arg is the residue index in the original PDB file (271),
                will not be changed
            3rd arg is the new residue name, can be either 'S1P' or 'SEP'
                to choose between the two possible protonation states of
                a phosphoserine
    """
    new_pdb = []
    with open(pdb_fn, 'r') as f:
        pdb = f.readlines()
    for line in pdb:
        if 'ATOM' in line:
            l_split = line.split()
            c_atom = l_split[2]
            c_resname = l_split[3]
            c_resid = int(l_split[4])
            for change in edition_list:
                n_resname = change[0]
                n_resid = change[1]
                mut_resname = change[2]
                if c_resname == n_resname and c_resid == n_resid:
                    line = line.replace(c_resname, mut_resname)
                    if c_atom == 'HG':
                        line = '\n'
        new_pdb.append(line)
    if write:
        with open(pdb_mut_fname, 'w') as f:
            f.writelines(new_pdb)
    return new_pdb
