In [3]:
import hdsubnetfinder
# Location of the human net SIF file
!ls ../
In [16]:
entrez2symbol = {}
for line in open('../HumanNet.v1.nodes.gene_symbol.txt', 'r'):
entrez, gene_symbol = line[:-1].split('\t')
entrez2symbol[entrez] = gene_symbol
out = open('HumanNet.v1.symbol.sif', 'w')
for line in open('../HumanNet.v1.sif', 'r'):
source, interaction, target = line[:-1].split('\t')
if target is '':
print('+++++++++++++++++++ ' + line)
if source in entrez2symbol.keys():
source_symbol = entrez2symbol[source]
else:
source_symbol = source
if target in entrez2symbol.keys():
target_symbol = entrez2symbol[target]
else:
target_symbol = target
out.write(source_symbol + '\t-\t' + target_symbol + '\n')
out.close()
In [14]:
import pandas as pd
hndf = pd.read_csv('HumanNet.v1.symbol.sif', sep='\t')
hndf.tail()
Out[14]: