def withinPro(file2, mutation):
    """ PTMs (predicted) involved in the crosstalk within a given protein at baker's years (Minguez el 2012)"""
    with open('within_protein.txt', 'w') as file1:
        with open(file2, 'rU') as f:
            for l in f:
                line = l.split()
                if len(line) > 19:
                    take = line[15] + '\t' + line[16] + '\t' + line[3
                        ] + '\t' + line[17] + '\t' + line[7] + '\t' + line[19]
                    take = take.split()
                    with open(mutation, 'r') as mu:
                        for m in mu:
                            m = m.split()
                            if m[0] == take[1] and m[1] == take[3]:
                                take2 = take[0] + '\t' + take[1] + '\t' + take[
                                    2] + '\t' + take[3] + '\t' + 'PTMcode'
                                fi = take2.split()
                                with open('yeastID.txt') as id:
                                    for di in id:
                                        di = di.split()
                                        if len(di) > 2 and di[2] == fi[1]:
                                            summary = open('summary.txt', 'a+')
                                            summary.write(di[0] + '\t' + di[2] +
                                                '\t' + fi[3] + '\t' + fi[2] + '\t' +
                                                'WithinProtein' + '\t' + 'PTMcode' +
                                                '\n')
                                            if take2 > str(0):
                                                with open('within_protein.txt', 'a'
                                                    ) as file1:
                                                    file1.write(take2 + '\n')
                                                    continue
                            if m[0] == take[1] and m[1] == take[5]:
                                take3 = take[0] + '\t' + take[1] + '\t' + take[
                                    4] + '\t' + take[5] + '\t' + 'PTMcode'
                                fi = take3.split()
                                with open('yeastID.txt') as id:
                                    for di in id:
                                        di = di.split()
                                        if len(di) > 2 and di[2] == fi[1]:
                                            summary = open('summary.txt', 'a+')
                                            summary.write(di[0] + '\t' + di[2] +
                                                '\t' + fi[3] + '\t' + fi[2] + '\t' +
                                                'WithinProtein' + '\t' + 'PTMcode' +
                                                '\n')
                                            if take3 > str(0):
                                                with open('within_protein.txt', 'a+'
                                                    ) as file1:
                                                    file1.write(take3 + '\n')
