<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def calc_windowed_sum(aa_mut_pos, germ_aa, somatic_aa, window=[3]):
 """Calculate the sum of mutations within a window around a particular mutated codon. Parameters aa_mut_pos : list list of mutated amino acid positions germ_aa : list Reference amino acid somatic_aa : list Somatic amino acid (if missense) window : list List of windows to calculate for Returns ------- pos_ctr : dict dictionary of mutated positions (key) with associated counts (value) pos_sum : dict of dict Window size as first key points to dictionary of mutated positions (key) with associated mutation count within the window size (value) """

    pos_ctr, pos_sum = {}, {w: {} for w in window}
    num_pos = len(aa_mut_pos)
    # figure out the missense mutations
    for i in range(num_pos):
        pos = aa_mut_pos[i]
        # make sure mutation is missense
        if germ_aa[i] and somatic_aa[i] and germ_aa[i] != '*' and \
           somatic_aa[i] != '*' and germ_aa[i] != somatic_aa[i]:
            # should have a position, but if not skip it
            if pos is not None:
                pos_ctr.setdefault(pos, 0)
                pos_ctr[pos] += 1

    # calculate windowed sum
    pos_list = sorted(pos_ctr.keys())
    max_window = max(window)
    for ix, pos in enumerate(pos_list):
        tmp_sum = {w: 0 for w in window}
        # go through the same and lower positions
        for k in reversed(range(ix+1)):
            pos2 = pos_list[k]
            if pos2 < pos-max_window: break
            for w in window:
                if pos-w <= pos2:
                    tmp_sum[w] += pos_ctr[pos2]
        # go though the higher positions
        for l in range(ix+1, len(pos_list)):
            pos2 = pos_list[l]
            if pos2 > pos+max_window: break
            for w in window:
                if pos2 <= pos+w:
                    tmp_sum[w] += pos_ctr[pos2]
        # iterate through all other positions
        #for pos2 in pos_list:
            #for w in window:
                #if pos-w <= pos2 <= pos+w:
                    #tmp_sum[w] += pos_ctr[pos2]
        # update windowed counts
        for w in window:
            pos_sum[w][pos] = tmp_sum[w]

    return pos_ctr, pos_sum