Apr-05-2019, 09:36 AM
Hello all,
I have to write a code to convert a .blastp file into a .sif one. For those of you that don't know what these are, a .blastp file look like that :
ProtA ProtB xx xxxxx xx xx.xxx E-value
ProtA ProtC xx xxxxx xx xx.xxx E-value
ProtD ProtE xx xxxxx xx xx.xxx E-value
.
.
.
and a sif one look like that :
ProtA <relationship type> ProtB
ProtC <relationship type> ProtA
ProtD <relationship type> ProtE ProtF ProtB
.
.
.
Prot being a protein
I need to ask for a S value, if that value is greater than the e-value, then those two protein are linked and I have to put them in the sif file as :
ProtA linked ProtB
I have started by creating a dictionary that store the first protein as a key and all the protein that are linked as a list in the value of the key.That worked well, but now I am stucked at writing the sif file, here are my code so far:
Thanks
I have to write a code to convert a .blastp file into a .sif one. For those of you that don't know what these are, a .blastp file look like that :
ProtA ProtB xx xxxxx xx xx.xxx E-value
ProtA ProtC xx xxxxx xx xx.xxx E-value
ProtD ProtE xx xxxxx xx xx.xxx E-value
.
.
.
and a sif one look like that :
ProtA <relationship type> ProtB
ProtC <relationship type> ProtA
ProtD <relationship type> ProtE ProtF ProtB
.
.
.
Prot being a protein
I need to ask for a S value, if that value is greater than the e-value, then those two protein are linked and I have to put them in the sif file as :
ProtA linked ProtB
I have started by creating a dictionary that store the first protein as a key and all the protein that are linked as a list in the value of the key.That worked well, but now I am stucked at writing the sif file, here are my code so far:
import re namF = "xxxxxxxxxxx.blastp" of = open(namF,'r') Sif="Output.sif" fo = open(Sif, 'w') S = str(input('Choisissez le seuil ')) dico={} ligne = of.readline() while (ligne != ""): ligne.rstrip('\n') L= ligne.split('\t') E= L[-1:] A=L[0] B=L[1] if E[0] <= S: if A in dico: dico[A].append(B) else: dico[A]=list() dico[A].append(B) if B in dico: dico[B].append(A) else: dico[B]=list() dico[B].append(A) for key in dico: fo.write(key+ ' lié '+ dico[key]+'\n') ligne= of.readline() print(D)Then I tried to put it in function as demanded :
import re namF = "xxxxxxxxxxx.blastp" of = open(namF,'r') Sif="Output.sif" fo = open(Sif, 'w') S = str(input('Choisissez le seuil ')) def sif(S): for key in dico: fo.write(key+ ' lié '+ dico[key]+'\n') def dic(): dico={} ligne = of.readline() while (ligne != ""): ligne.rstrip('\n') L= ligne.split('\t') E= L[-1:] A=L[0] B=L[1] if E[0] <= S: if A in dico: dico[A].append(B) else: dico[A]=list() dico[A].append(B) if B in dico: dico[B].append(A) else: dico[B]=list() dico[B].append(A) ligne= of.readline() print(D)I tried to use my dic function in the sif one to create my output.sif but I can't manage to do it. Any help ?
Thanks