Merge branch 'master' of http://www.iramuteq.org/git/iramuteq
authorpierre <ratinaud@univ-tlse2.fr>
Mon, 3 Nov 2014 22:20:14 +0000 (23:20 +0100)
committerpierre <ratinaud@univ-tlse2.fr>
Mon, 3 Nov 2014 22:20:14 +0000 (23:20 +0100)
Conflicts:
layout.py

PrintRScript.py
analysematrix.py
chemins.py
functions.py
iramuteq.py
layout.py
tabchi2.py
tabsimi.py
textsimi.py
textwordcloud.py

index 120e4ff..90a4398 100644 (file)
@@ -33,7 +33,7 @@ class PrintRScript :
 
     def sources(self, lsources) :
         for source in lsources :
 
     def sources(self, lsources) :
         for source in lsources :
-            self.add('source("%s", encoding = \'utf8\')' % source)
+            self.add('source("%s", encoding = \'utf8\')' % ffr(source))
 
     def packages(self, lpks) :
         for pk in lpks :
 
     def packages(self, lpks) :
         for pk in lpks :
@@ -41,7 +41,7 @@ class PrintRScript :
 
     def load(self, l) :
         for val in l :
 
     def load(self, l) :
         for val in l :
-            self.add('load("%s")' % val)
+            self.add('load("%s")' % ffr(val))
 
     def write(self) :
         with open(self.scriptout, 'w') as f :
 
     def write(self) :
         with open(self.scriptout, 'w') as f :
@@ -709,7 +709,7 @@ class PrintSimiScript(PrintRScript) :
             dm.path <- "%s"
             cn.path <- "%s"
             selected.col <- "%s"
             dm.path <- "%s"
             cn.path <- "%s"
             selected.col <- "%s"
-            """ % (self.pathout['mat01.csv'], self.pathout['actives.csv'], self.pathout['selected.csv'])
+            """ % (ffr(self.pathout['mat01.csv']), ffr(self.pathout['actives.csv']), ffr(self.pathout['selected.csv']))
             if 'word' in self.parametres :
                 txt += """
                 word <- TRUE
             if 'word' in self.parametres :
                 txt += """
                 word <- TRUE
@@ -744,7 +744,7 @@ class PrintSimiScript(PrintRScript) :
             txt += """
             dm.path <- "%s"
             selected.col <- "%s"
             txt += """
             dm.path <- "%s"
             selected.col <- "%s"
-            """ % (self.pathout['mat01.csv'], self.pathout['selected.csv'])
+            """ % (ffr(self.pathout['mat01.csv']), ffr(self.pathout['selected.csv']))
             if 'word' in self.parametres :
                 txt += """
                 word <- TRUE
             if 'word' in self.parametres :
                 txt += """
                 word <- TRUE
@@ -777,7 +777,7 @@ class PrintSimiScript(PrintRScript) :
         else :
             txt += """
             load("%s")
         else :
             txt += """
             load("%s")
-            """ % self.pathout['RData.RData']
+            """ % ffr(self.pathout['RData.RData'])
         
         if self.parametres['coeff'] == 0 :
             method = 'cooc'
         
         if self.parametres['coeff'] == 0 :
             method = 'cooc'
@@ -1005,7 +1005,7 @@ class PrintSimiScript(PrintRScript) :
             cols <- vertex.label.color
             chivertex.size <- norm.vec(toblack, vcexminmax[1],  vcexminmax[2])
             
             cols <- vertex.label.color
             chivertex.size <- norm.vec(toblack, vcexminmax[1],  vcexminmax[2])
             
-            """ % (self.analyse.parent.RscriptsPath['chdfunct'])
+            """ % (ffr(self.analyse.parent.RscriptsPath['chdfunct']))
         else :
             txt += """
             vertex.label.color <- 'black' 
         else :
             txt += """
             vertex.label.color <- 'black' 
@@ -1125,7 +1125,7 @@ class PrintSimiScript(PrintRScript) :
         }
         coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, svg = svg)
         save.image(file="%s")
         }
         coords <- plot.simi(graph.simi, p.type='%s',filename="%s", vertex.label = label.v, edge.label = label.e, vertex.col = vertex.col, vertex.label.color = vertex.label.color, vertex.label.cex=label.cex, vertex.size = vertex.size, edge.col = cola, leg=leg, width = width, height = height, alpha = alpha, movie = film, svg = svg)
         save.image(file="%s")
-        """ % (type, self.filename, self.pathout['RData'])
+        """ % (type, self.filename, ffr(self.pathout['RData']))
         
         self.add(txt)
         self.write()
         
         self.add(txt)
         self.write()
index 7fe67b5..9803994 100644 (file)
@@ -9,16 +9,14 @@
 import logging
 import os
 from uuid import uuid4
 import logging
 import os
 from uuid import uuid4
-
-
 from chemins import PathOut
 from chemins import PathOut
-from functions import exec_rcode, check_Rresult, DoConf
+from functions import exec_rcode, check_Rresult, DoConf, progressbar
 from time import time, sleep
 from openanalyse import OpenAnalyse
 
 
 class AnalyseMatrix :
 from time import time, sleep
 from openanalyse import OpenAnalyse
 
 
 class AnalyseMatrix :
-    def __init__(self, ira, tableau, parametres = None, dlg = False) :
+    def __init__(self, ira, tableau, parametres = None, dlg = None) :
         self.tableau = tableau
         if self.tableau.csvtable is None :
             self.tableau.open()
         self.tableau = tableau
         if self.tableau.csvtable is None :
             self.tableau.open()
@@ -40,6 +38,8 @@ class AnalyseMatrix :
         self.parametres['matrix'] = self.tableau.parametres['uuid']
         self.tableau.pathout.dirout = self.parametres['pathout']
         self.doparametres(dlg = dlg)
         self.parametres['matrix'] = self.tableau.parametres['uuid']
         self.tableau.pathout.dirout = self.parametres['pathout']
         self.doparametres(dlg = dlg)
+        if self.dlg is not None :
+            self.dlg = progressbar(self.ira, self.dlg)
         if self.parametres is not None :
             self.t1 = time()
             if not os.path.exists(self.parametres['pathout']) :
         if self.parametres is not None :
             self.t1 = time()
             if not os.path.exists(self.parametres['pathout']) :
@@ -55,15 +55,15 @@ class AnalyseMatrix :
             self.parametres['ira'] = self.pathout['Analyse.ira']
             DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
             self.ira.history.addMatrixAnalyse(self.parametres)
             self.parametres['ira'] = self.pathout['Analyse.ira']
             DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
             self.ira.history.addMatrixAnalyse(self.parametres)
-            if dlg :
-                dlg.Destroy()
+            if self.dlg is not None :
+                self.dlg.Destroy()
                 OpenAnalyse(self.parent, self.parametres['ira'])
                 self.ira.tree.AddMatAnalyse(self.parametres)
                 self.val = 5100
         else :
             self.val = False
                 OpenAnalyse(self.parent, self.parametres['ira'])
                 self.ira.tree.AddMatAnalyse(self.parametres)
                 self.val = 5100
         else :
             self.val = False
-            if dlg :
-                dlg.Destroy()
+            if self.dlg is not None :
+                self.dlg.Destroy()
  
     def doanalyse(self) :
         pass
  
     def doanalyse(self) :
         pass
index 24a76de..3217a4f 100644 (file)
@@ -5,12 +5,22 @@
 #License: GNU/GPL
 
 import os
 #License: GNU/GPL
 
 import os
+import sys
 import tempfile
 import logging
 
 log = logging.getLogger('iramuteq.chemins')
 
 
 import tempfile
 import logging
 
 log = logging.getLogger('iramuteq.chemins')
 
 
+def normpath_win32(path) :
+    if not sys.platform == 'win32' :
+        return path
+    while '\\\\' in path :
+        path = path.replace('\\\\', '\\')
+    if sys.platform == 'win32' and path.startswith('\\') and not path.startswith('\\\\') :
+        path = '\\' + path
+    return path
+    
 class PathOut :
     def __init__(self, filename = None, analyse_type = '', dirout = None) :
         if filename is not None :
 class PathOut :
     def __init__(self, filename = None, analyse_type = '', dirout = None) :
         if filename is not None :
@@ -48,9 +58,13 @@ class PathOut :
             self.temp = tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\')
             return self.temp
         elif key not in self.d :
             self.temp = tempfile.mkstemp(prefix='iramuteq')[1].replace('\\', '\\\\')
             return self.temp
         elif key not in self.d :
-            return os.path.join(self.dirout, key).replace('\\', '\\\\')
+            f = os.path.join(self.dirout, key).replace('\\', '\\\\')
+            return normpath_win32(f)
+            #return os.path.join(self.dirout, key).replace('\\', '\\\\')
         else :
         else :
-            return os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\')
+            f = os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\')
+            return normpath_win32(f)
+            #return os.path.join(self.dirout, self.d[key]).replace('\\', '\\\\')
     
     def getF(self, key) :
         return self.__getitem__(key).replace('\\', '/')
     
     def getF(self, key) :
         return self.__getitem__(key).replace('\\', '/')
index e93f34e..9b1c8bf 100644 (file)
@@ -30,6 +30,15 @@ log = logging.getLogger('iramuteq')
 indices_simi = [u'cooccurrence' ,'pourcentage de cooccurrence',u'Russel',u'Jaccard', 'Kulczynski1', 'Kulczynski2', 'Mountford', 'Fager', 'simple matching', 'Hamman', 'Faith', 'Tanimoto', 'Dice', 'Phi', 'Stiles', 'Michael', 'Mozley', 'Yule', 'Yule2', 'Ochiai', 'Simpson', 'Braun-Blanquet','Chi-squared', 'Phi-squared', 'Tschuprow', 'Cramer', 'Pearson', 'binomial']
 
 
 indices_simi = [u'cooccurrence' ,'pourcentage de cooccurrence',u'Russel',u'Jaccard', 'Kulczynski1', 'Kulczynski2', 'Mountford', 'Fager', 'simple matching', 'Hamman', 'Faith', 'Tanimoto', 'Dice', 'Phi', 'Stiles', 'Michael', 'Mozley', 'Yule', 'Yule2', 'Ochiai', 'Simpson', 'Braun-Blanquet','Chi-squared', 'Phi-squared', 'Tschuprow', 'Cramer', 'Pearson', 'binomial']
 
 
+def normpath_win32(path) :
+    if not sys.platform == 'win32' :
+        return path
+    while '\\\\' in path :
+        path = path.replace('\\\\', '\\')
+    if sys.platform == 'win32' and path.startswith('\\') and not path.startswith('\\\\') :
+        path = '\\' + path
+    return path
+
 class TGen :
     def __init__(self, path = None, encoding = 'utf8'):
         self.path = path
 class TGen :
     def __init__(self, path = None, encoding = 'utf8'):
         self.path = path
@@ -197,7 +206,9 @@ class DoConf :
     def __init__(self, configfile=None, diff = None, parametres = None) :
         self.configfile = configfile
         self.conf = ConfigParser()
     def __init__(self, configfile=None, diff = None, parametres = None) :
         self.configfile = configfile
         self.conf = ConfigParser()
+        
         if configfile is not None :
         if configfile is not None :
+            configfile = normpath_win32(configfile)
             self.conf.readfp(codecs.open(configfile, 'r', 'utf8'))
         self.parametres = {}
         if parametres is not None :
             self.conf.readfp(codecs.open(configfile, 'r', 'utf8'))
         self.parametres = {}
         if parametres is not None :
@@ -253,6 +264,7 @@ class DoConf :
                     txt += '%s = %s\n' % (option, `parametres[i][option]`)
         if outfile is None :
             outfile = self.configfile
                     txt += '%s = %s\n' % (option, `parametres[i][option]`)
         if outfile is None :
             outfile = self.configfile
+        outfile = normpath_win32(outfile)
         with open(outfile, 'w') as f :
             f.write(txt.encode('utf8'))
             #self.conf.write(f)
         with open(outfile, 'w') as f :
             f.write(txt.encode('utf8'))
             #self.conf.write(f)
index 1aee272..6abc278 100644 (file)
@@ -827,33 +827,19 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, États-Unis."""
     def analyse_matrix(self, analyse, analyse_type = '', matrix = None, dlgnb = 1):
         if matrix is None :
             matrix = self.tree.getmatrix()
     def analyse_matrix(self, analyse, analyse_type = '', matrix = None, dlgnb = 1):
         if matrix is None :
             matrix = self.tree.getmatrix()
-        #try :
-        analyse(self, matrix, parametres = {'type' : analyse_type}, dlg = progressbar(self, dlgnb))
-        #except:
-        #    BugReport(self)           
+        try :
+            analyse(self, matrix, parametres = {'type' : analyse_type}, dlg = dlgnb)
+        except:
+            BugReport(self)           
 
     def OnFreq(self, event, matrix = None):
         self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
 
     def OnFreq(self, event, matrix = None):
         self.analyse_matrix(Frequences, analyse_type = 'freq', matrix = matrix, dlgnb = 3)
-        #if matrix is None :
-        #    matrix = self.tree.getmatrix()
-        #try:
-        #    Frequences(self, matrix, parametres = {'type' : 'freq'}, dlg = progressbar(self, 3)) 
-        #except:
-        #    BugReport(self)
 
     def OnChi2(self, event, matrix = None):
 
     def OnChi2(self, event, matrix = None):
-        #try:
         self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3) 
         self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3) 
-        #except:
-        #    BugReport(self)
 
     def OnSimiTab(self, event, matrix = None):
 
     def OnSimiTab(self, event, matrix = None):
-        if matrix is None :
-            matrix = self.tree.getmatrix()
-        try:
-            DoSimi(self, matrix, parametres = {'type' : 'simimatrix'}, dlg = progressbar(self, 3)) 
-        except:
-            BugReport(self)
+        self.analyse_matrix(DoSimi, matrix = matrix, analyse_type = 'simimatrix', dlgnb = 5)
 
     def OnCHDReinert(self, event, matrix = None):
         if matrix is None :
 
     def OnCHDReinert(self, event, matrix = None):
         if matrix is None :
index 0e41fe4..829d6ae 100644 (file)
--- a/layout.py
+++ b/layout.py
@@ -12,7 +12,7 @@ import wx.lib.agw.labelbook as LB
 from wx.lib.agw.fmresources import *
 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
 from ConfigParser import ConfigParser
 from wx.lib.agw.fmresources import *
 from chemins import ConstructPathOut, ChdTxtPathOut, FFF, ffr, PathOut, StatTxtPathOut, simipath
 from ConfigParser import ConfigParser
-from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult, progressbar
+from functions import ReadProfileAsDico, GetTxtProfile, read_list_file, ReadList, exec_rcode, print_liste, BugReport, DoConf, indices_simi, check_Rresult, progressbar, normpath_win32
 from ProfList import ProfListctrlPanel
 from guiparam3d import param3d, simi3d
 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
 from ProfList import ProfListctrlPanel
 from guiparam3d import param3d, simi3d
 from PrintRScript import write_afc_graph, print_simi3d, PrintSimiScript
@@ -1225,9 +1225,8 @@ class DefaultMatLayout :
 class FreqLayout(DefaultMatLayout) :
     def dolayout(self) :
         self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
 class FreqLayout(DefaultMatLayout) :
     def dolayout(self) :
         self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
-        if "gtk2" in wx.PlatformInfo:
-            self.tab.SetStandardFonts()
-        self.tab.LoadPage(self.pathout['resultats.html'].replace('\\\\','/'))
+        res = normpath_win32(self.pathout['resultats.html']).replace('\\','/')
+        self.tab.LoadPage(res)
         self.tab.parametres = self.parametres
         self.ira.nb.AddPage(self.tab, u"Fréquences")
 
         self.tab.parametres = self.parametres
         self.ira.nb.AddPage(self.tab, u"Fréquences")
 
@@ -1237,7 +1236,8 @@ class Chi2Layout(DefaultMatLayout) :
         self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
         if "gtk2" in wx.PlatformInfo:
             self.tab.SetStandardFonts()
         self.tab = wx.html.HtmlWindow(self.ira.nb, -1)
         if "gtk2" in wx.PlatformInfo:
             self.tab.SetStandardFonts()
-        self.tab.LoadPage(self.pathout['resultats-chi2.html'])
+        res = normpath_win32(self.pathout['resultats-chi2.html']).replace('\\','/')
+        self.tab.LoadPage(res)
         self.tab.parametres = self.parametres
         self.ira.nb.AddPage(self.tab, ' - '.join([u"Chi2", "%s" % self.parametres['name']]))
         #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
         self.tab.parametres = self.parametres
         self.ira.nb.AddPage(self.tab, ' - '.join([u"Chi2", "%s" % self.parametres['name']]))
         #self.ira.nb.SetSelection(self.ira.nb.GetPageCount() - 1)
@@ -1327,6 +1327,7 @@ class SimiMatLayout(DefaultMatLayout) :
                     fileout = filename + '.svg'
                 else :
                     fileout = self.script.filename
                     fileout = filename + '.svg'
                 else :
                     fileout = self.script.filename
+                fileout = normpath_win32(fileout)
                 if os.path.exists(self.pathout['liste_graph']):
                     graph_simi = read_list_file(self.pathout['liste_graph'])
                     graph_simi.append([os.path.basename(fileout), self.script.txtgraph])
                 if os.path.exists(self.pathout['liste_graph']):
                     graph_simi = read_list_file(self.pathout['liste_graph'])
                     graph_simi.append([os.path.basename(fileout), self.script.txtgraph])
@@ -1338,7 +1339,7 @@ class SimiMatLayout(DefaultMatLayout) :
                 if self.parametres['svg'] :
                     self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
                 else :
                 if self.parametres['svg'] :
                     self.graphpan.sizer_3.Add(hl.HyperLinkCtrl(self.graphpan.panel_1, -1, fileout, URL = fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
                 else :
-                    self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(self.script.filename, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+                    self.graphpan.sizer_3.Add(wx.StaticBitmap(self.graphpan.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
                 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, self.script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
                 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
                 self.graphpan.Layout()
                 self.graphpan.sizer_3.Add(wx.StaticText(self.graphpan.panel_1,-1, self.script.txtgraph), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
                 self.graphpan.sizer_3.Fit(self.graphpan.panel_1)
                 self.graphpan.Layout()
index 422b447..5b47a28 100755 (executable)
@@ -57,314 +57,6 @@ chioption = { 'valobs' : True,
               'bw' : False,
               }
 
               'bw' : False,
               }
 
-
-class MakeChi2():
-    def __init__(self, parent, select1, select2, chioption, tableau):
-        self.tableau = tableau
-        self.OutFrame=tempfile.mktemp(dir=parent.TEMPDIR)
-        print self.OutFrame
-        self.parent=parent
-        self.encode=self.parent.encode
-        self.TEMPDIR=parent.TEMPDIR
-        self.RPath=parent.PathPath.get('PATHS','rpath')
-        self.TextCroise=[]
-        for i in select1 :
-            for j in select2 :
-                self.TextCroise.append(self.tableau.colnames[i] + ' / ' + self.tableau.colnames[j])
-        rchioption = {}
-        for val in chioption :
-            if chioption[val]:
-                rchioption[val] = 'TRUE'
-            else :
-                rchioption[val] = 'FALSE'
-        txt="""
-        source("%s")
-        """%self.parent.RscriptsPath['Rfunct']
-#        if parent.tableau.: rownames=1
-#        else : rownames='NULL'
-#        if parent.g_header : header = 'TRUE'
-#        else : header = 'FALSE'
-        txt += """
-        source("%s")
-        """ % ffr(self.parent.RscriptsPath['Rgraph'])
-        txt += """
-        doobs <- %s
-        doexp <- %s
-        docontrib <- %s
-        doresi <- %s
-        dopr <- %s
-        doprl <- %s
-        doprc <- %s
-        dograph <- %s
-        bw <- %s
-        """ % (rchioption['valobs'], rchioption['valtheo'], rchioption['contrib'], rchioption['resi'], rchioption['pourcent'], rchioption['pourcentl'], rchioption['pourcentc'], rchioption['graph'], rchioption['bw'])
-        txt+="""
-        datadm <- read.csv2("%s", encoding="%s", header = TRUE, row.names = 1, sep='\\t', quote = '"', na.string = '')
-        listres<-list()
-        listcol<-list()
-        cont<-1
-        """%(ffr(self.tableau.parametres['csvfile']), self.tableau.parametres['syscoding'])
-        if len(select1)==1:
-            strsel1=str(select1).replace(',','')
-        else:
-            strsel1=str(select1)
-        if len(select2)==1:
-            strsel2=str(select2).replace(',','')
-        else:
-            strsel2=str(select2)
-        txt+="""
-        for (i in c%s) {"""%strsel1
-        txt+="""
-            for (j in c%s) {"""%strsel2
-        txt+="""
-                tab<-table(datadm[,i+1],datadm[,j+1])
-                if (min(dim(tab)) != 1) {
-                    chi<-chisq.test(tab)
-                    CS<-colSums(tab)
-                    RS<-rowSums(tab)
-                    GT<-sum(tab)
-                    chi$contrib<-(tab-chi$expected)/sqrt(chi$expected * ((1 - RS/GT) %%*%% t(1 - CS/GT)))
-                    listres[[cont]]<-chi
-                    listcol[[cont]]<-ncol(tab)
-                    cont<-cont+1
-                } else {
-                    chi <- list(observed = tab, residuals = tab, contrib = tab, statistic = 0, p.value = 1, expected = tab, message = 'pas de calcul')
-                    listres[[cont]] <- chi
-                    listcol[[cont]]<-ncol(tab)
-                    cont <- cont + 1
-                }
-            }
-        }
-        maxcol<-max(unlist(listcol))+1
-        if (maxcol<7) {maxcol<-7}
-        frameout<-matrix('*',1,maxcol)
-        count<-0
-        for (chi in listres) {
-            if (min(chi$expected)<5) {
-                att<-"warning"
-            } else {
-                att<-""
-            }
-            if ('message' %%in%% attributes(chi)$names) {
-                att <- "Ce chi2 n\'a pas été calculé"
-                nom_colresi<-colnames(chi$observed)
-                chi$prl <- chi$expected
-                chi$prc <- chi$expected
-                st <- sum(chi$observed)
-            } else {
-                nom_colresi<-colnames(chi$observed)
-                st <- sum(chi$observed)
-                sc <- colSums(chi$observed)
-                sr <- rowSums(chi$observed)
-                chi$prl <- round((chi$observed/sr)*100,2)
-                chi$prc <- t(round((t(chi$observed)/sc)*100,2))
-            }
-            fileout<-paste('histo_',count,sep='')
-            fileout<-paste(fileout,'.png',sep='')
-            count<-count+1
-            fileout<-file.path("%s",fileout)
-            if (max(nchar(colnames(chi$observed)))>15) {
-                leg <- 1:length(colnames(chi$observed))
-            } else {
-                leg <- colnames(chi$observed)
-            }
-            if (dograph) {
-                width<-ncol(chi$observed)*100
-                if (width < 350) {width <- 350}
-                open_file_graph(fileout,width = width, height = 300)
-                par(mar=c(0,0,0,0))
-                layout(matrix(c(1,2),1,2, byrow=TRUE),widths=c(3,1))
-                par(mar=c(2,2,1,0))
-                par(cex=0.8)
-                if (!bw) colors <- rainbow(length(rownames(chi$observed)))
-                else colors <- gray.colors(length(rownames(chi$observed)))
-                barplot(chi$prl,names.arg = leg, beside=TRUE,border=NA, col=colors)
-                par(mar=c(0,0,0,0))
-                par(cex=0.8)
-                plot(0, axes = FALSE, pch = '')
-                legend(x = 'center' , rownames(chi$observed), fill = colors)
-                dev.off()
-            }
-            chi$prl <- cbind(chi$prl, total = rowSums(chi$prl))
-            chi$prc <- rbind(chi$prc, total = colSums(chi$prc))
-            chi$observed<-rbind(chi$observed,total=colSums(chi$observed))
-            chi$observed<-cbind(chi$observed,total=rowSums(chi$observed))
-            chi$pr <- round((chi$observed/st)*100,2)
-            chi$expected<-rbind(chi$expected,total=colSums(chi$expected))
-            chi$expected<-cbind(chi$expected,total=rowSums(chi$expected))
-            chi$expected<-round(chi$expected,digits=2)
-            chi$residuals<-round(chi$residuals,digits=2)
-            chi$contrib<-round(chi$contrib, digits=2)
-            nom_col<-colnames(chi$observed)
-           
-            if (ncol(chi$observed)<maxcol) {
-                for (i in 1:(maxcol-ncol(chi$observed))) {
-                    chi$observed<-cbind(chi$observed,'**')
-                    chi$pr<-cbind(chi$pr,'**')
-                    chi$prl<-cbind(chi$prl,'**')
-                    chi$prc<-cbind(chi$prc,'**')
-                    chi$expected<-cbind(chi$expected,'**')
-                    chi$residuals<-cbind(chi$residuals,'**')
-                    chi$contrib<-cbind(chi$contrib,'**')
-                    nom_col<-append(nom_col,'**')
-                    nom_colresi<-append(nom_colresi,'**')
-                }
-                chi$residuals<-cbind(chi$residuals,'**')
-                chi$contrib<-cbind(chi$contrib,'**')
-                nom_colresi<-append(nom_colresi,'**')
-                chi$prc<-cbind(chi$prc,'**')
-            } else if (ncol(chi$observed)==maxcol) {
-                chi$residuals<-cbind(chi$residuals,'**')
-                chi$contrib<-cbind(chi$contrib,'**')
-                nom_colresi<-append(nom_colresi,'**')
-                chi$prc<-cbind(chi$prc,'**')
-            }
-            if (doobs) {
-                li<-matrix('*obs*',1,maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_col)
-                frameout<-rbind(frameout,chi$observed)
-            }
-            if (doexp) {
-                li<-matrix('*exp*',1,maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_col)
-                frameout<-rbind(frameout,chi$expected)
-            }
-            if (doresi) {
-                li<-matrix('*resi*',1,maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_colresi)
-                frameout<-rbind(frameout,chi$residuals)
-            }
-            if (docontrib) {
-                li<-matrix('*contrib*',1,maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_colresi)
-                frameout<-rbind(frameout,chi$contrib)
-            }
-            if (dopr) {
-                li<-matrix('*pr*', 1, maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_col)
-                frameout<-rbind(frameout,chi$pr)
-            }
-            if (doprl) {
-                li<-matrix('*prl*', 1, maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_col)
-                frameout<-rbind(frameout,chi$prl)
-            }
-            if (doprc) {
-                li<-matrix('*prc*', 1, maxcol)
-                frameout<-rbind(frameout,li)
-                frameout<-rbind(frameout,nom_colresi)
-                frameout<-rbind(frameout,chi$prc)
-            }
-            res<-c('****','chi',chi$statistic,'p',chi$p.value,att,fileout)
-            frameout<-rbind(frameout,res)
-        }
-        li<-matrix('fin_analyse',1,maxcol)
-        frameout<-rbind(frameout,li)
-        write.csv2(frameout,file="%s")
-        """ % (ffr(parent.TEMPDIR),ffr(self.OutFrame))
-        tmpfile=tempfile.mktemp(dir=self.TEMPDIR)
-        print tmpfile
-        tmpscript=open(tmpfile,'w')
-        tmpscript.write(txt)
-        tmpscript.close()
-        pid = exec_rcode(self.RPath, tmpfile, wait = False)
-        while pid.poll() == None :
-            sleep(0.2)
-        check_Rresult(self.parent, pid)
-
-    def dolayout(self, option):
-        ListFile=[False]
-        file=open(self.OutFrame,'rU')
-        content=file.readlines()
-        file.close()
-        lcont = [line.replace('"','').replace('\n','').split(';') for line in content]
-    
-        lcont.pop(0)
-        lcont.pop(0)
-        
-        allcoord = []
-        names = []
-
-        res = [chi for chi in lcont if chi[0]=='res']
-        res = [make_res(line) for line in res]
-        coord_res = [i for i,chi in enumerate(lcont) if chi[0]=='res']
-        if option['valobs']:
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*obs*'])
-            names.append(u'Valeurs observées')
-        if option['valtheo'] :
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*exp*'])
-            names.append(u'Valeurs théoriques')
-        if option['resi'] :
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*resi*'])
-            names.append(u'Residuals')
-        if option['contrib'] :
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*contrib*'])
-            names.append(u'Contributions a posteriori')
-        if option['pourcent'] : 
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*pr*'])
-            names.append(u'Pourcentages')
-        if option['pourcentl'] :
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prl*'])
-            names.append(u'Pourcentages en ligne')
-        if option['pourcentc'] :
-            allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prc*'])
-            names.append(u'Pourcentages en colonne')
-    
-        allcoord.append(coord_res)
-        allhtml = [[clean_line(lcont[allcoord[i][j]+1:allcoord[i+1][j]]) for j, line in enumerate(allcoord[i])] for i, tab in enumerate(allcoord) if i!=len(allcoord)-1]
-    
-        allhtml = [make_table(val,names[i],res) for i,val in enumerate(allhtml)]
-    
-        links = make_link_list(res, self.TextCroise)
-        #colors = [line[-1] for line in res]
-    
-    #    good = [i for i,chi in enumerate(res) if chi[-1] == 'green' or chi[-1] == 'blue']
-        #select_good = [[val[i] for i in good] for val in tout]
-    
-    
-        html_res = make_restab(res)
-        allhtml.insert(0,html_res)
-
-        titles = make_title(res, self.TextCroise)
-        allhtml.insert(0,titles)
-        
-        if option['graph'] :
-            graphs = [line[7] for line in res]
-            ListFile += graphs
-            html_graphs = make_htmlgraphs(graphs)
-            allhtml.append(html_graphs)
-
-        header=u"""
-        <html>\n
-        <meta http-equiv="content-Type" content="text/html; charset=%s" />\n
-        <body>\n
-        <h1>Test du Chi2</h1>\n
-        <br>
-        <table border=1><tr><td>
-        Légende : <br>
-        <font color=green>p &lt;= 0.05</font><br>
-        <font color=blue>p &lt;= 0.05 mais il y a des valeurs théoriques &lt; 5</font><br>
-        <font color=red>p &gt; 0.05</font>
-        </td></tr></table><br><br>
-        """%self.parent.SysEncoding
-
-    
-        pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
-        txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
-        txt = header + pretxt + txt + '\n</body></html>'
-
-        fileout=os.path.join(self.parametres['pathout'],'resultats-chi2.html')
-        with open(fileout, 'w') as f :
-            f.write(txt)
-        ListFile.append(fileout)         
-        return ListFile
-
 class ChiSquare(AnalyseMatrix):
     def doparametres(self, dlg = None):
         if dlg is None :
 class ChiSquare(AnalyseMatrix):
     def doparametres(self, dlg = None):
         if dlg is None :
@@ -374,11 +66,7 @@ class ChiSquare(AnalyseMatrix):
                      )
         dial.CenterOnParent()
         val = dial.ShowModal()
                      )
         dial.CenterOnParent()
         val = dial.ShowModal()
-        if val==wx.ID_OK : 
-            dlg.Center()
-            self.count = 1
-            keepGoing = dlg.Update(self.count)
-            
+        if val==wx.ID_OK :     
             self.colsel1 = dial.list_box_1.GetSelections()
             self.colsel2 = dial.list_box_2.GetSelections()
             if dial.chiopt :
             self.colsel1 = dial.list_box_1.GetSelections()
             self.colsel2 = dial.list_box_2.GetSelections()
             if dial.chiopt :
@@ -435,7 +123,7 @@ class ChiSquare(AnalyseMatrix):
                 rchioption[val] = 'FALSE'
         txt="""
         source("%s")
                 rchioption[val] = 'FALSE'
         txt="""
         source("%s")
-        """%self.parent.RscriptsPath['Rfunct']
+        """%ffr(self.parent.RscriptsPath['Rfunct'])
 #        if parent.tableau.: rownames=1
 #        else : rownames='NULL'
 #        if parent.g_header : header = 'TRUE'
 #        if parent.tableau.: rownames=1
 #        else : rownames='NULL'
 #        if parent.g_header : header = 'TRUE'
@@ -648,8 +336,8 @@ class ChiSquare(AnalyseMatrix):
 #             parent.nb.SetSelection(parent.nb.GetPageCount()-1)
 #             parent.ShowTab(wx.EVT_BUTTON)
 #             parent.DisEnSaveTabAs(True)
 #             parent.nb.SetSelection(parent.nb.GetPageCount()-1)
 #             parent.ShowTab(wx.EVT_BUTTON)
 #             parent.DisEnSaveTabAs(True)
-        self.count += 1
-        keepGoing = self.dlg.Update(self.count,u"Fini")
+#        self.count += 1
+#        keepGoing = self.dlg.Update(self.count,u"Fini")
 
     def dolayout(self, option):
         ListFile=[False]
 
     def dolayout(self, option):
         ListFile=[False]
@@ -691,19 +379,10 @@ class ChiSquare(AnalyseMatrix):
     
         allcoord.append(coord_res)
         allhtml = [[clean_line(lcont[allcoord[i][j]+1:allcoord[i+1][j]]) for j, line in enumerate(allcoord[i])] for i, tab in enumerate(allcoord) if i!=len(allcoord)-1]
     
         allcoord.append(coord_res)
         allhtml = [[clean_line(lcont[allcoord[i][j]+1:allcoord[i+1][j]]) for j, line in enumerate(allcoord[i])] for i, tab in enumerate(allcoord) if i!=len(allcoord)-1]
-    
         allhtml = [make_table(val,names[i],res) for i,val in enumerate(allhtml)]
         allhtml = [make_table(val,names[i],res) for i,val in enumerate(allhtml)]
-    
         links = make_link_list(res, self.TextCroise)
         links = make_link_list(res, self.TextCroise)
-        #colors = [line[-1] for line in res]
-    
-    #    good = [i for i,chi in enumerate(res) if chi[-1] == 'green' or chi[-1] == 'blue']
-        #select_good = [[val[i] for i in good] for val in tout]
-    
-    
         html_res = make_restab(res)
         allhtml.insert(0,html_res)
         html_res = make_restab(res)
         allhtml.insert(0,html_res)
-
         titles = make_title(res, self.TextCroise)
         allhtml.insert(0,titles)
         
         titles = make_title(res, self.TextCroise)
         allhtml.insert(0,titles)
         
@@ -727,7 +406,6 @@ class ChiSquare(AnalyseMatrix):
         </td></tr></table><br><br>
         """%self.parent.SysEncoding
 
         </td></tr></table><br><br>
         """%self.parent.SysEncoding
 
-    
         pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
         txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
         txt = header + pretxt + txt + '\n</body></html>'
         pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
         txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
         txt = header + pretxt + txt + '\n</body></html>'
index 700999d..9de8067 100644 (file)
@@ -5,7 +5,7 @@
 #License: GNU/GPL
 
 from chemins import ConstructPathOut, simipath, ffr, PathOut
 #License: GNU/GPL
 
 from chemins import ConstructPathOut, simipath, ffr, PathOut
-from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod
+from functions import print_liste, exec_rcode, read_list_file, check_Rresult, indices_simi, treat_var_mod, normpath_win32
 from dialog import SelectColDial, FreqDialog
 from guifunct import PrefSimi
 from analysematrix import AnalyseMatrix
 from dialog import SelectColDial, FreqDialog
 from guifunct import PrefSimi
 from analysematrix import AnalyseMatrix
@@ -21,7 +21,7 @@ from uuid import uuid4
 
 
 class DoSimi(AnalyseMatrix):
 
 
 class DoSimi(AnalyseMatrix):
-    def doanalyse(self) :
+    def doparametres(self, dlg = None) :
         self.fromprof = self.parametres.get('fromprof', False)
         self.wordgraph = self.parametres.get('wordgraph', False)
         self.listactives = self.parametres.get('listactives', False)
         self.fromprof = self.parametres.get('fromprof', False)
         self.wordgraph = self.parametres.get('wordgraph', False)
         self.listactives = self.parametres.get('listactives', False)
@@ -29,16 +29,6 @@ class DoSimi(AnalyseMatrix):
         self.openfromprof = self.parametres.get('openfromprof', False)
         self.cmd = self.parametres.get('cmd', False)
         self.dirout = self.parametres.get('pathout', False)
         self.openfromprof = self.parametres.get('openfromprof', False)
         self.cmd = self.parametres.get('cmd', False)
         self.dirout = self.parametres.get('pathout', False)
-     #parent, matrix = None, parametres = 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
-    #    self.listactives = listactives
-    #    self.actives = actives
-    #    self.openfromprof = openfromprof
-    #    self.cmd = cmd
-    #    self.dirout = pathout
-    #    if parametres is not None and fromprof:
         if self.fromprof:
             self.paramsimi = parametres
         else :
         if self.fromprof:
             self.paramsimi = parametres
         else :
@@ -76,20 +66,11 @@ class DoSimi(AnalyseMatrix):
                           'communities' : 0,
                           }
         self.indices = indices_simi
                           'communities' : 0,
                           }
         self.indices = indices_simi
-        #if fromprof :
-        #    self.parent = parent.parent
-        #    self.Source = parent
-        #else :
         self.Source = None
         if self.dirout :
             self.pathout = PathOut(dirout = self.dirout)
 
         self.Source = None
         if self.dirout :
             self.pathout = PathOut(dirout = self.dirout)
 
-        #self.RPath = self.parent.PathPath.get('PATHS', 'rpath')
         if not self.parametres.get('isopen', False) :
         if not self.parametres.get('isopen', False) :
-            #if not fromprof :
-            #    self.tableau = self.parent.tableau
-            #else :
-            #    self.tableau = parent.tableau
             if self.tableau is None :
                 self.tableau = parent.tableau
             self.tableau.parametres['mineff'] = 0
             if self.tableau is None :
                 self.tableau = parent.tableau
             self.tableau.parametres['mineff'] = 0
@@ -133,17 +114,8 @@ class DoSimi(AnalyseMatrix):
                         self.parametres['pathout'] = self.dirout
                     self.pathout.createdir(self.parametres['pathout'])
                     self.pathout.dirout = self.parametres['pathout']
                         self.parametres['pathout'] = self.dirout
                     self.pathout.createdir(self.parametres['pathout'])
                     self.pathout.dirout = self.parametres['pathout']
-                    #self.parametres['filename'] = self.tableau.parametres['filename']
                     self.dial.Destroy()
                     self.dial.Destroy()
-                    self.doanalyse2()  
-                    #dlg = wx.ProgressDialog("Traitements",
-                    #               "Veuillez patienter...",
-                    #               maximum=4,
-                    #               parent=self.parent,
-                    #               style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE | wx.PD_ELAPSED_TIME
-                    #                )
-                    #dlg.Center()
-                    #AnalyseMatrix.__init__(self, parent, self.tableau, self.paramsimi, dlg = dlg)
+                    #self.doanalyse2()  
                 else :
                     self.dial.Destroy()
                     self.parametres = None
                 else :
                     self.dial.Destroy()
                     self.parametres = None
@@ -153,9 +125,9 @@ class DoSimi(AnalyseMatrix):
                 self.parametres = None
                 return False
 
                 self.parametres = None
                 return False
 
-    def doanalyse2(self) :
+    def doanalyse(self) :
         self.pathout.basefiles(simipath)
         self.pathout.basefiles(simipath)
-        with open(self.pathout['selected.csv'], 'w') as f :
+        with open(normpath_win32(self.pathout['selected.csv']), 'w') as f :
             f.write('\n'.join([`val` for val in self.column]))
 
         count = 1
             f.write('\n'.join([`val` for val in self.column]))
 
         count = 1
@@ -191,8 +163,8 @@ class DoSimi(AnalyseMatrix):
         self.addgraph()
         self.tableau.save_tableau(self.pathout['db'])
         #self.make_ira()
         self.addgraph()
         self.tableau.save_tableau(self.pathout['db'])
         #self.make_ira()
-        count += 1
-        self.dlg.Update(count, u"") 
+        #count += 1
+        #self.dlg.Update(count, u"") 
         self.dlg.Destroy()
         #self.dial.Destroy()
         #self.dolayout()
         self.dlg.Destroy()
         #self.dial.Destroy()
         #self.dolayout()
index 807442e..dd5349c 100644 (file)
@@ -38,10 +38,12 @@ class SimiTxt(AnalyseText):
             self.stars = copy(self.listet)
             self.parametres['stars'] = copy(self.listet)
             self.parametres['sfromchi'] = False
             self.stars = copy(self.listet)
             self.parametres['stars'] = copy(self.listet)
             self.parametres['sfromchi'] = False
+            self.dlg.Destroy()
             prep = PrepSimi(self.ira, self, self.parametres, self.pathout['selected.csv'], self.actives, indices_simi, wordlist=dictcol)
             if prep.val == wx.ID_OK :
                 continu = True
                 self.parametres = prep.parametres
             prep = PrepSimi(self.ira, self, self.parametres, self.pathout['selected.csv'], self.actives, indices_simi, wordlist=dictcol)
             if prep.val == wx.ID_OK :
                 continu = True
                 self.parametres = prep.parametres
+                self.dlg = progressbar(self.ira, 4)
         else :
             continu = True
         if continu :
         else :
             continu = True
         if continu :
index fab7c5a..07b65ed 100644 (file)
@@ -25,6 +25,7 @@ class WordCloud(AnalyseText):
         self.parametres['type'] = 'wordcloud'
         #FIXME
         limit = 3
         self.parametres['type'] = 'wordcloud'
         #FIXME
         limit = 3
+        self.dlg.Destroy()
         res = self.make_option()
         if res == wx.ID_OK :
             if self.parametres['mode'] == 2 :
         res = self.make_option()
         if res == wx.ID_OK :
             if self.parametres['mode'] == 2 :
@@ -36,6 +37,7 @@ class WordCloud(AnalyseText):
                 self.actives = self.corpus.make_actives_limit(limit, 2)
             dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) 
             SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], dlg = True)
                 self.actives = self.corpus.make_actives_limit(limit, 2)
             dictcol = dict([[i, [act, self.corpus.getlemeff(act)]] for i, act in enumerate(self.actives)]) 
             SelectColumn(self.ira, dictcol, self.actives, self.pathout['selected.csv'], dlg = True)
+            self.dlg = progressbar(self.ira, 2)
             self.make_wordcloud()
             script = WordCloudRScript(self)
             script.make_script()
             self.make_wordcloud()
             script = WordCloudRScript(self)
             script.make_script()