Hey guys,
I'm new with python so I'm really struggling in making a script.
So, what I need is to make a comparison between two files. One file contains all proteins of some data base, the other contain only some of the proteins presents in the other file, because it belongs to a organism. So I need to know which proteins of this data base is present in my organism. For that I want to build a output like a matrix, with 0 and 1 referring to every protein present in the data base that may or may not be in my organism.
Does anybody have any idea of how could I do that?
I'm thinking of something like this
f1 = open('file1.txt', 'r')
f2 = open('file2.txt', 'r')
FO = open('output.txt', 'w')
for line1 in file1:
for line2 in file2:
if line1 == line2:
FO.write("%d" %(1))
FO.close()
file1.close()
file2.close()
But there's a problem, that script will only add if the lines are totally equal and that will not work because I only need that one word (the protein) be the same.
Could anybody please help me?
Thanks so far.