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,
'keep_coord' : True,
'alpha' : 20,
'film': False,
+ 'com' : 0,
+ 'communities' : 0,
+ 'halo' : 0
}
# self.tableau.actives = {}
# self.tableau.lchi = self.lchi
# 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)
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 :
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)
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')
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):
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
'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)