#!/usr/bin/env python#coding:utf-8#import pandas as pd, numpy as np;
‘‘‘将csv文件转换为对应的邻接矩阵mat‘‘‘
from numpy import *;defprotein_complexes_trans():
file= open(‘protein_complexes.csv‘);
filePro= open(‘complexes‘, ‘a‘);
fileTarget= open(‘targets(complexes)‘,‘a‘);
fileInter= open(‘protein_complexes_interaction_matrix‘, ‘a‘);
proteins=[];
targets=[];while 1:
line=file.readline();if notline:break;
token= line.split(‘;‘);
targ= token[1].split(‘,‘);for i inrange(0,len(targ)):
targets.append(targ[i]);
proteins.append(token[0]);
file.seek(0);#将指针重置回第一行
proArr= unique(array(proteins)).tolist(); #去重,并删去最后一项(标题)
tarArr = unique(array(targets)).tolist(); #删去最后
#mat为邻接矩阵
mat = zeros((len(proArr),len(tarArr)), dtype =int16);while 1:
line=f