I have 15 .csv files with the following formats:
**File 1**
MYC
RASSF1
DAPK1
MDM2
TP53
E2F1
...
**File 2**
K06227
C00187
GLI1
PTCH1
BMP2
TP53
...
I would like to create a loop that runs through each of the 15 files and compares 2 at each time, creating unique pairs. So, File 1 and File 2 would be compared with each other giving an output telling me how many matches it found and what they were. So in the above example, the output would be:
1 match and TP53
The loops would be used to compare all the files against each other so 1,3 (File 1 against File 3), 1,4 and so on.
f1 = set(open(str(cancers[1]) + '.csv', 'r'))
f2 = set(open(str(cancers[2]) + '.csv', 'r'))
f3 = open(str(cancers[1]) + '_vs_' + str(cancers[2]) + '.txt', 'wb').writelines(f1 & f2)
The above works but I'm having a hard time creating the looping portion.