Can someone explain to me what I am doing wrong ?
I have two files:
file1
looks like this
NOP7 305
CDC24 78
SSA1 41
NOP7 334
LCB5 94
FUS3 183
file2
looks like this
SSA1 550 S HSP70 1YUW
FUS3 181 Y Pkinase 1QMZ
FUS3 179 T Pkinase 1QMZ
CDC28 18 Y Pkinase 1QMZ
And I'm using the following code-lit to get protein names that match in lists from other files
file = open('file1')
for line in file1:
line=line.strip().split()
with open('file2') as file2:
for l in out:
l=l.strip().split()
if line[0]==l[0]:
take=line[0]
with open('file3', 'w') as file3:
file3.write("{}".format(take))
What I get is a file with one protein name only
CDC28
And what I want is all the proteins that match, eg
SSA1
CDC28
FUS3
Please guide ...... ??
PS: when I print the result I get the required values (protein names) printed, but I am not able to write this to a file.