Mercurial > repos > pablocarb > synbiodesign
comparison rpviz/csv_network.py @ 16:fe78fd6b315a draft
planemo upload commit 87db86a34f2d92eb2c9756bf9ee53ae2970554d5
author | pablocarb |
---|---|
date | Tue, 11 Jun 2019 11:42:40 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
15:785b6253af1f | 16:fe78fd6b315a |
---|---|
1 # -*- coding: utf-8 -*- | |
2 """ | |
3 Created on Wed May 29 17:23:04 2019 | |
4 | |
5 @author: anael | |
6 Read the output of retropath | |
7 To visualize a csv file | |
8 """ | |
9 | |
10 import csv | |
11 import argparse | |
12 import os | |
13 | |
14 def arguments(): | |
15 parser = argparse.ArgumentParser(description='Visualizing a network from csv') | |
16 parser.add_argument('infile', | |
17 help='Input csv file.') | |
18 #parser.add_argument('outfile', | |
19 # help='Input some file.') | |
20 return parser | |
21 | |
22 parser = arguments() | |
23 arg = parser.parse_args() | |
24 | |
25 assert os.path.exists('infile/'+arg.infile) | |
26 file='infile/'+arg.infile | |
27 data=csv.reader(open(file)) | |
28 tab=[] | |
29 for ligne in data : | |
30 tab.append(ligne) | |
31 | |
32 List=[] #List of different number of pathways in the file | |
33 for i in range(1,len(tab)): | |
34 List.append(int(tab[i][0])) | |
35 List=list(set(List)) | |
36 List.sort() | |
37 for i in range(len(List)) : | |
38 nb=int(List[i]) | |
39 name=file+str(nb) | |
40 LR=[] | |
41 Lreact=[] | |
42 Lprod=[] | |
43 for i in range(len(tab)): | |
44 if tab[i][0]==str(nb) :#we chose the pathway | |
45 LR.append(tab[i][2]) #reaction = Unique ID | |
46 Lreact.append(tab[i][3].split(":")) | |
47 Lprod.append([tab[i][4]]) | |
48 #print('LR = '+ str(LR)) | |
49 #print('Lreact = '+ str(Lreact)) | |
50 #print('Lprod = '+ str(Lprod)) | |
51 #from nxvisualizer import network | |
52 #network(LR,Lreact,Lprod,name) | |
53 from network2json import network2 #to convert the lists in a json network | |
54 network2(LR,Lreact,Lprod,name) | |
55 | |
56 | |
57 | |
58 | |
59 | |
60 |