From 7007f89913612375b1f1d34c71193ba8257f5091 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 27 Jan 2013 23:30:18 +0100 Subject: [PATCH] ... --- ProfList.py | 17 ++++++++------ iramuteq.py | 3 +++ layout.py | 76 ++++++++++++++++++++++--------------------------------------- tabsimi.py | 40 ++++++++++++++++++++------------ 4 files changed, 65 insertions(+), 71 deletions(-) diff --git a/ProfList.py b/ProfList.py index a3c5c94..09b30a2 100644 --- a/ProfList.py +++ b/ProfList.py @@ -411,13 +411,13 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col def quest_simi(self, evt) : tableau = self.Source.tableau tab = tableau.make_table_from_classe(self.cl, self.la) - pathout = ConstructPathOut(os.path.join(self.Source.pathout, 'simi_classe_%i' %self.cl)) + pathout = ConstructPathOut(os.path.join(self.Source.pathout.dirout, 'simi_classe_%i' %self.cl), 'simi_classe_%i' %self.cl) self.filename = os.path.join(pathout,'mat01.csv') tableau.printtable(self.filename, tab) del tab paramsimi = {'coeff' : 0, 'layout' : 2, - 'type' : 1, + 'type_graph' : 1, 'arbremax' : 1, 'coeff_tv' : 1, 'coeff_tv_nb' : 0, @@ -445,6 +445,9 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col 'keep_coord' : True, 'alpha' : 20, 'film': False, + 'com' : 0, + 'communities' : 0, + 'halo' : 0 } # self.tableau.actives = {} # self.tableau.lchi = self.lchi @@ -454,13 +457,13 @@ class ProfListctrlPanel(wx.ListCtrl, listmix.ListCtrlAutoWidthMixin, listmix.Col # self.tableau.chi[val] = [self.lchi[i]] act = {} - self.tableau.chi = {} - self.tableau.lchi = self.lchi - self.tableau.parametre['fromprof'] = True + tableau.chi = {} + tableau.lchi = self.lchi + tableau.parametre['fromprof'] = True for i, val in enumerate(self.la) : act[val] = [self.lfreq[i]] - self.tableau.chi[val] = [self.lchi[i]] - DoSimi(self, param = paramsimi, fromprof = ffr(self.filename), pathout = pathout, listactives = self.la, actives = act) + tableau.chi[val] = [self.lchi[i]] + self.parent.SimiCluster(parametres = paramsimi, fromprof = ffr(self.filename), pathout = pathout, listactives = self.la, actives = act, tableau = tableau) def onwordgraph(self, evt): word = self.getColumnText(self.GetFirstSelected(), 6) diff --git a/iramuteq.py b/iramuteq.py index ed574e4..c211567 100644 --- a/iramuteq.py +++ b/iramuteq.py @@ -970,6 +970,9 @@ Voulez-vous fermer quand même ?""" PlaySound(self) except: BugReport(self) + + def SimiCluster(self, parametres = {}, fromprof = False, pathout = '', listactives = [], actives = [], tableau = None) : + DoSimi(self, param = parametres, fromprof = fromprof, pathout = pathout, listactives = listactives, actives = actives, tableau = tableau) def OnSimi(self,evt): #try : diff --git a/layout.py b/layout.py index 8efccbf..b2eeb4e 100644 --- a/layout.py +++ b/layout.py @@ -990,7 +990,7 @@ class SimiLayout(DefaultTextLayout) : V(graph)$x <- graph.simi$layout[,1] V(graph)$y <- graph.simi$layout[,2] V(graph)$weight <- graph.simi$label.cex - V(graph)$colors <- cols + V(graph)$colors <- vertex.label.color E(graph)$weigth <- graph.simi$we.width write.graph(graph, fileout, format = 'graphml') """ % (self.pathout['RData.RData'], fileout) @@ -1029,7 +1029,7 @@ class SimiMatLayout(DefaultMatLayout) : self.tabsimi.SetArtProvider(aui.ChromeTabArt()) self.graphpan = GraphPanelSimi(self.tabsimi, self.pathout, list_graph) self.graphpan.Bind(wx.EVT_BUTTON, self.redosimi, self.graphpan.butafc) - #self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport) + self.graphpan.Bind(wx.EVT_BUTTON, self.export, self.graphpan.butexport) self.tabsimi.AddPage(self.graphpan, 'Graph') self.tabsimi.parametres = self.parametres self.parent.nb.AddPage(self.tabsimi, 'Analyse de graph') @@ -1162,53 +1162,31 @@ class SimiMatLayout(DefaultMatLayout) : sleep(0.2) check_Rresult(self.parent, pid) - #return paramsimi - -# if self.openfromprof : -# if 'cexfromchi' not in self.paramsimi: -# self.paramsimi['cexfromchi'] = False -# self.paramsimi['sfromchi'] = False -# self.dial = PrefSimi(self.parent, -1, self.paramsimi, self.types) -# self.dial.CenterOnParent() -# val = self.dial.ShowModal() -# if val == wx.ID_OK : -# self.paramsimi = self.make_param() -# self.dial.Destroy() -# if self.paramsimi.get('bystar',False) : -# variables = treat_var_mod(self.paramsimi['stars']) -# dial = OptLexi(self.parent) -# dial.listet = self.paramsimi['stars'] -# var = [v for v in variables] -# dial.variables = var -# for et in var : -# dial.list_box_1.Append(et) -# dial.CenterOnParent() -# val = dial.ShowModal() -# if val == wx.ID_OK : -# if dial.choice.GetSelection() == 1 : -# listet = [dial.listet[i] for i in dial.list_box_1.GetSelections()] -# else : -# listet = variables[var[dial.list_box_1.GetSelections()[0]]] -# self.tableau.etline = self.Source.corpus.make_etline(listet) -# -# dlg = wx.ProgressDialog("Traitements", -# "Veuillez patienter...", -# maximum=2, -# parent=self.parent, -# style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME | wx.PD_CAN_ABORT) -# dlg.Center() -# self.PrintScript() -# self.DoR(dlg) -# dlg.Destroy() -# self.make_ira() -# if self.paramsimi['type'] == 1: -# self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) -# self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1,self.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0) -# self.graphpan.sizer_3.Fit(self.graphpan.panel_1) -# self.graphpan.Layout() -# self.graphpan.panel_1.Scroll(0,self.graphpan.panel_1.GetScrollRange(wx.VERTICAL)) -# else : -# self.dial.Destroy() + def export(self, evt) : + nb = 1 + while os.path.exists(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')): + nb +=1 + fileout = ffr(os.path.join(self.pathout.dirout,'graph_'+str(nb)+'.graphml')) + txt = """ + library(igraph) + load("%s") + fileout <- "%s" + graph <- graph.simi$graph + V(graph)$x <- graph.simi$layout[,1] + V(graph)$y <- graph.simi$layout[,2] + V(graph)$weight <- graph.simi$label.cex + V(graph)$colors <- vertex.label.color + E(graph)$weigth <- graph.simi$we.width + write.graph(graph, fileout, format = 'graphml') + """ % (self.pathout['RData.RData'], fileout) + filetmp = tempfile.mktemp() + with open(filetmp, 'w') as f : + f.write(txt) + exec_rcode(self.ira.RPath, filetmp) + mss = wx.MessageDialog(self.ira, fileout, u'Fichier exporté', wx.OK) + mss.CenterOnParent() + mss.ShowModal() + mss.Destroy() class GraphPanelSimi(wx.Panel): diff --git a/tabsimi.py b/tabsimi.py index d2facad..081b2fa 100644 --- a/tabsimi.py +++ b/tabsimi.py @@ -25,7 +25,7 @@ from uuid import uuid4 class DoSimi(AnalyseMatrix): - def __init__(self, parent, param = None, isopen = False, fromprof = False, pathout = False, filename ='', gparent = False, wordgraph = False, listactives = False, actives = False, cmd = False, openfromprof=False): + def __init__(self, parent, param = None, isopen = False, fromprof = False, pathout = False, filename ='', gparent = False, wordgraph = False, listactives = False, actives = False, cmd = False, openfromprof=False, tableau = None): #------------------------------------------------------------------- self.fromprof = fromprof self.wordgraph = wordgraph @@ -70,26 +70,36 @@ class DoSimi(AnalyseMatrix): 'communities' : 0, } self.indices = indices_simi - if fromprof : - self.parent = parent.parent - self.Source = parent - else : - self.parent = parent - self.Source = None + #if fromprof : + # self.parent = parent.parent + # self.Source = parent + #else : + self.parent = parent + self.Source = None self.RPath = self.parent.PathPath.get('PATHS', 'rpath') if not isopen : - if not fromprof : - self.tableau = self.parent.tableau - else : + #if not fromprof : + # self.tableau = self.parent.tableau + #else : + # self.tableau = parent.tableau + if tableau is not None : + self.tableau = tableau + else : self.tableau = parent.tableau self.tableau.parametre['mineff'] = 0 - dialcol = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Sélectionnez les colonnes", size=(600, 250)) - dialcol.CenterOnParent() - res = dialcol.ShowModal() + if not fromprof : + dialcol = FreqDialog(self.parent, -1, self.tableau.get_colnames(), u"Sélectionnez les colonnes", size=(600, 250)) + dialcol.CenterOnParent() + res = dialcol.ShowModal() + else : + res = wx.ID_OK if res == wx.ID_OK : - self.tableau.selected_col = dialcol.list_box_1.GetSelections() - actives = self.tableau.getactlistfromselection(self.tableau.selected_col) + if not self.actives : + self.tableau.selected_col = dialcol.list_box_1.GetSelections() + actives = self.tableau.getactlistfromselection(self.tableau.selected_col) + else : + actives = self.actives self.tableau.make_listactives() actives = dict([[i, val] for i, val in enumerate(actives)]) self.dial = PrefSimi(parent, -1, self.paramsimi, self.indices, wordlist = actives) -- 2.7.4