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 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 :
txt += """
chd2<-CHD(data2, x = nbt, mode.patate = mode.patate, svd.method = svd.method, libsvdc.path = libsvdc.path)
"""
- else:
- txt += """
- chd2<-chd1
- """
txt += """
#lecture des uce
}
n1 <- chd.result$n1
classeuce1 <- chd.result$cuce1
- classeuce2 <- chd.result$cuce2
- """ % (classif_mode, mincl, DicoPath['uce'])
+ classes<-n1[,ncol(n1)]
+ write.csv2(n1, file="%s")
+ rm(n1)
+ """ % (classif_mode, mincl, DicoPath['uce'], DicoPath['n1.csv'])
txt += """
tree.tot1 <- make_tree_tot(chd1)
if classif_mode == 0:
txt += """
+ classeuce2 <- chd.result$cuce2
tree.tot2 <- make_tree_tot(chd2)
# open_file_graph("%s", width = 600, height=400)
# plot(tree.tot2$tree.cl)
txt += """
tree.cut1 <- make_dendro_cut_tuple(tree.tot1$dendro_tuple, chd.result$coord_ok, classeuce1, 1, nbt)
save(tree.cut1, file="%s")
- classes<-n1[,ncol(n1)]
+
open_file_graph("%s", width = 600, height=400)
plot.dendropr(tree.cut1$tree.cl,classes, histo=TRUE)
open_file_graph("%s", width = 600, height=400)
""" % (DicoPath['dendro2'], DicoPath['arbre2'])
txt += """
- save.image(file="%s")
- """ % DicoPath['RData']
+
+ #save.image(file="%s")
+ """ % (DicoPath['RData'])
+
fileout = open(DicoPath['Rchdtxt'], 'w')
fileout.write(txt)
fileout.close()
txt = "clnb<-%i\n" % clnb
txt += """
source("%s")
-load("%s")
-""" % (RscriptsPath['chdfunct'], DictChdTxtOut['RData'])
+#load("%s")
+n1 <- read.csv2("%s")
+""" % (RscriptsPath['chdfunct'], DictChdTxtOut['RData'], DictChdTxtOut['n1.csv'])
txt += """
dataact<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA')
datasup<-read.csv2("%s", header = FALSE, sep = ';',quote = '\"', row.names = 1, na.strings = 'NA')
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
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
else :
txt += """
load("%s")
- """ % self.pathout['RData.RData']
+ """ % ffr(self.pathout['RData.RData'])
if self.parametres['coeff'] == 0 :
method = 'cooc'
"""
txt += """
seuil <- %s
- if (method!='cooc') {
- seuil <- seuil/100
- }
+ if (!is.null(seuil)) {
+ if (method!='cooc') {
+ seuil <- seuil/100
+ }
+ }
""" % seuil
txt += """
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'
}
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()
tochange <- apply(rgbs, 2, is.yellow)
tochange <- which(tochange)
if (length(tochange)) {
- gr.col <- grey.colors(length(tochange), start = 0.5)
+ gr.col <- grey.colors(length(tochange), start = 0.5, end = 0.8)
}
compt <- 1
for (val in tochange) {
rain <- rainbow(clnb)
compt <- 1
tochange <- NULL
- for (my.color in rain) {
- my.color <- col2rgb(my.color)
- if ((my.color[1] > 200) & (my.color[2] > 200) & (my.color[3] < 20)) {
- tochange <- append(tochange, compt)
- }
- compt <- compt + 1
- }
- if (!is.null(tochange)) {
- gr.col <- grey.colors(length(tochange))
- compt <- 1
- for (val in tochange) {
- rain[val] <- gr.col[compt]
- compt <- compt + 1
- }
- }
- cl.color <- rain[classes]
+ #for (my.color in rain) {
+ # my.color <- col2rgb(my.color)
+ # if ((my.color[1] > 200) & (my.color[2] > 200) & (my.color[3] < 20)) {
+ # tochange <- append(tochange, compt)
+ # }
+ # compt <- compt + 1
+ #}
+ #if (!is.null(tochange)) {
+ # gr.col <- grey.colors(length(tochange))
+ # compt <- 1
+ # for (val in tochange) {
+ # rain[val] <- gr.col[compt]
+ # compt <- compt + 1
+ # }
+ #}
+ rain <- del.yellow(rain)
+ cl.color <- rain[classes]
if (black) {
cl.color <- 'black'
}
vec.mat[3,] <- 3:(length(sum.cl)+2)
layout(matrix(vec.mat, nrow=3, ncol=length(sum.cl)),heights=c(2,1,6))
if (! bw) {
- col <- rainbow(length(sum.cl))[as.numeric(tree$tip.label)]
+ col <- rainbow(length(sum.cl))
col <- del.yellow(col)
+ col <- col[as.numeric(tree$tip.label)]
colcloud <- rainbow(length(sum.cl))
colcloud <- del.yellow(colcloud)
}
#wordcloud(names(lclasses[[i]]), lclasses[[i]], scale = c(1.5, 0.2), random.order=FALSE, colors = colcloud[i])
yval <- 1.1
plot(0,0,pch='', axes = FALSE)
- vcex <- norm.vec(lclasses[[i]], 1.5, 2.5)
+ vcex <- norm.vec(lclasses[[i]], 1.5, 1.5)
for (j in 1:length(lclasses[[i]])) {
yval <- yval-(strheight( names(lclasses[[i]])[j],cex=vcex[j])+0.02)
text(-0.9, yval, names(lclasses[[i]])[j], cex = vcex[j], col = colcloud[i], adj=0)
par(mar=c(0,0,0,0))
if (!is.null(classes)) {
matlay <- matrix(c(1,2,3,4),1,byrow=TRUE)
- lay.width <- c(3,1,3,2)
+ lay.width <- c(3,2,3,2)
} else {
matlay <- matrix(c(1,2,3),1,byrow=TRUE)
}
layout(matlay, widths=lay.width,TRUE)
- par(mar=c(3,0,2,0),cex=1)
+ par(mar=c(3,0,2,4),cex=1)
label.ori<-tree[[2]]
if (!is.null(lab)) {
- tree$tip.label <- lab
+ tree$tip.label <- lab[tree.order]
} else {
tree[[2]]<-paste('classe ',tree[[2]])
}
col.bars <- grey.colors(nrow(to.plot),0,0.8)
}
col <- col[tree.order]
- plot.phylo(tree,label.offset=0.1,tip.col=col)
+ plot.phylo(tree,label.offset=0.2,tip.col=col)
if (!is.null(classes)) {
par(cex=0.7)
par(mar=c(3,0,2,1))
classeuce1<-AssignClasseToUce(listuce1,chd1$n1)
if (classif_mode==0) {
classeuce2<-AssignClasseToUce(listuce2,chd2$n1)
- } else {
- classeuce2<-classeuce1
- }
+ }
+ #} else {
+ # classeuce2<-classeuce1
+ #}
#calcul des poids (effectifs)
if (classif_mode==0) {
poids2<-vector(mode='integer',length = tcl)
poids2<-makepoids(classeuce2,poids2)
- } else {
- poids2<-poids1
- }
+ }# else {
+ # poids2<-poids1
+ #}
print('croisement classif')
# }
# croise
# }
- croise <- croiseeff( matrix(ncol=tcl,nrow=tcl), classeuce1, classeuce2)
+ if (classif_mode==0) {
+ croise <- croiseeff( matrix(ncol=tcl,nrow=tcl), classeuce1, classeuce2)
+ } else {
+ croise <- croiseeff( matrix(ncol=tcl,nrow=tcl), classeuce1, classeuce1)
+ }
print(croise)
if (classif_mode == 0) {ind <- (nbcl * 2)} else {ind <- nbcl}
if (mincl==0){
}
chicroise
}
- chicroise <- dochicroise(croise, mincl)
+
+ dochicroisesimple <- function(croise, mincl) {
+ chicroise <- croise
+ for (i in 1:nrow(croise)) {
+ for (j in 1:ncol(croise)) {
+ if (croise[i,j]==0) {
+ chicroise[i,j]<-0
+ } else if (croise[i,j]<mincl) {
+ chicroise[i,j]<-0
+ } else {
+ chitable<-matrix(ncol=2,nrow=2)
+ chitable[1,1]<-croise[i,j]
+ chitable[1,2]<-poids1[i]-chitable[1,1]
+ chitable[2,1]<-poids1[j]-chitable[1,1]
+ chitable[2,2]<-nrow(classeuce1)-poids1[j]-chitable[1,2]
+ chitest<-chisq.test(chitable,correct=FALSE)
+ if ((chitable[1,1]-chitest$expected[1,1])<0) {
+ chicroise[i,j]<--round(chitest$statistic,digits=7)
+ } else {
+ chicroise[i,j]<-round(chitest$statistic,digits=7)
+ #print(chitest)
+ }
+ }
+ }
+ }
+ chicroise
+ }
+ if (classif_mode == 0) {
+ chicroise <- dochicroise(croise, mincl)
+ } else {
+ chicroise <- dochicroisesimple(croise, mincl)
+ }
+
print('fin croise')
#print(chicroise)
#determination des chi2 les plus fort
}
print('listfille')
listfille1<-lfilletot(classeuce1,1)
- listfille2<-lfilletot(classeuce2,2)
+ if (classif_mode == 0) {
+ listfille2<-lfilletot(classeuce2,2)
+ }
#utiliser rownames comme coordonnees dans un tableau de 0
Assignclasse<-function(classeuce,x) {
nchd1<-Assignclasse(classeuce1,1)
if (classif_mode==0) {
nchd2<-Assignclasse(classeuce2,2)
- } else {
- nchd2<-nchd1
- }
+ }
print('fini assign new classe')
#croisep<-matrix(ncol=nrow(coordok),nrow=nrow(coordok))
- nchd2[which(nchd1[,ncol(nchd1)]==0),] <- 0
- nchd2[which(nchd1[,ncol(nchd1)]!=nchd2[,ncol(nchd2)]),] <- 0
- nchd1[which(nchd2[,ncol(nchd2)]==0),] <- 0
+ if (classif_mode==0) {
+ nchd2[which(nchd1[,ncol(nchd1)]==0),] <- 0
+ nchd2[which(nchd1[,ncol(nchd1)]!=nchd2[,ncol(nchd2)]),] <- 0
+ nchd1[which(nchd2[,ncol(nchd2)]==0),] <- 0
+ }
print('fini croise')
elim<-which(nchd1[,ncol(nchd1)]==0)
keep<-which(nchd1[,ncol(nchd1)]!=0)
n1<-nchd1[nchd1[,ncol(nchd1)]!=0,]
- n2<-nchd2[nchd2[,ncol(nchd2)]!=0,]
+ if (classif_mode==0) {
+ n2<-nchd2[nchd2[,ncol(nchd2)]!=0,]
+ } else {
+ classeuce2 <- NULL
+ }
#clnb<-nrow(coordok)
print('fini')
write.csv2(nchd1[,ncol(nchd1)],uceout)
import logging
import os
from uuid import uuid4
-
-
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 :
- 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.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']) :
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
- if dlg :
- dlg.Destroy()
+ if self.dlg is not None :
+ self.dlg.Destroy()
def doanalyse(self) :
pass
DoConf().makeoptions([self.parametres['type']], [self.parametres], self.pathout['Analyse.ira'])
self.ira.history.add(self.parametres)
if dlg :
+ if not isinstance(dlg, int) :
+ dlg.Destroy()
self.dlg.Destroy()
OpenAnalyse(self.parent, self.parametres['ira'])
self.ira.tree.AddAnalyse(self.parametres)
if dlg :
self.dlg.Destroy()
else :
- #if dlg :
+ #if isinstance(dlg, wx.ProgressDialog) :
# self.dlg.Destroy()
self.val = False
#License: GNU/GPL
import os
+import sys
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 :
self.analyse = analyse_type
#self.dirout = self.mkdirout(dirout)
if dirout is not None:
- self.dirout = dirout
+ self.dirout = os.path.abspath(dirout)
elif filename is not None and dirout is None:
- self.dirout = self.directory
+ self.dirout = os.path.abspath(self.directory)
self.d = {}
def mkdirout(self) :
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 :
- 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('\\', '/')
self.m_staticline4 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
fgSizer1.Add( self.m_staticline4, 0, wx.EXPAND |wx.ALL, 5 )
+
+ self.text_format_image = wx.StaticText( self, wx.ID_ANY, _(u"Image format").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
+ self.text_format_image.Wrap( -1 )
+ fgSizer1.Add( self.text_format_image, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
+
+ self.choice_format = wx.Choice( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, ['png', 'svg'], 0 )
+ self.choice_format.SetSelection( 0 )
+ fgSizer1.Add( self.choice_format, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5 )
+
+ self.m_staticline31 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+ fgSizer1.Add( self.m_staticline31, 0, wx.EXPAND |wx.ALL, 5 )
+
+ self.m_staticline41 = wx.StaticLine( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.LI_HORIZONTAL )
+ fgSizer1.Add( self.m_staticline41, 0, wx.EXPAND |wx.ALL, 5 )
+
self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, _(u"Color or black and white").decode('utf8'), wx.DefaultPosition, wx.DefaultSize, 0 )
self.m_staticText5.Wrap( -1 )
self.m_radioBox1.SetSelection(self.param['color_nb'])
self.m_checkBox1.SetValue(self.param['taille_classe'])
self.m_radioBox2.SetSelection(self.param['type_tclasse'])
+ self.choice_format.SetSelection(self.param['svg'])
def __del__( self ):
pass
self.uceids = uceids
self.ira = wx.GetApp().GetTopWindow()
self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
-
+ self.items = items
self.html = ""
#self.HtmlPage=wx.html.HtmlWindow(self, -1)
self.HtmlPage = ConcordList(self, items)
)
dlg.SetFilterIndex(2)
dlg.CenterOnParent()
+ self.html = '<br>'.join([self.items[i] for i in range(0,len(self.items))])
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
with open(path, 'w') as f :
bSizer1 = wx.BoxSizer( wx.VERTICAL )
m_listBox1Choices = self.header
- self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL|wx.LB_MULTIPLE )
+ self.m_listBox1 = wx.ListBox( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, m_listBox1Choices, wx.LB_EXTENDED|wx.LB_HSCROLL )
self.m_listBox1.SetMinSize( wx.Size( 500,-1 ) )
bSizer1.Add( self.m_listBox1, 0, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5 )
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
def __init__(self, configfile=None, diff = None, parametres = None) :
self.configfile = configfile
self.conf = ConfigParser()
+
if configfile is not None :
+ configfile = normpath_win32(configfile)
self.conf.readfp(codecs.open(configfile, 'r', 'utf8'))
self.parametres = {}
if parametres is not None :
txt += '%s = %s\n' % (option, `parametres[i][option]`)
if outfile is None :
outfile = self.configfile
- with codecs.open(outfile, 'w', 'utf8') as f :
- f.write(txt)
+ outfile = normpath_win32(outfile)
+ with open(outfile, 'w') as f :
+ f.write(txt.encode('utf8'))
#self.conf.write(f)
def totext(self, parametres) :
if wordlist is not None :
self.listcol = ListForSpec(self, self, wordlist, ['eff'])
self.listcol.SetMinSize( wx.Size( 270,-1 ) )
- bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+ listsizer = wx.BoxSizer( wx.VERTICAL )
+ countsizer = wx.BoxSizer( wx.HORIZONTAL )
+ self.butcount = wx.Button(self, -1, "count")
+ self.textcount = wx.TextCtrl(self, -1, "", wx.DefaultPosition, wx.Size( 100,-1 ), wx.TE_READONLY )
+ countsizer.Add(self.butcount, 0, wx.ALL, 5)
+ countsizer.Add(self.textcount, 0, wx.ALL, 5 )
+ listsizer.Add(countsizer, 0, wx.ALL, 5)
+ listsizer.Add(self.listcol, 2, wx.ALL|wx.EXPAND, 5 )
+ #bSizer16.Add( self.listcol, 0, wx.ALL|wx.EXPAND, 5 )
+ bSizer16.Add( listsizer, 0, wx.ALL|wx.EXPAND, 5)
if selected is None :
for row in xrange(self.listcol.GetItemCount()):
self.listcol.Select(row)
self.checki.Bind( wx.EVT_CHECKBOX, self.OnChecki )
self.check_vcex.Bind( wx.EVT_CHECKBOX, self.OnCheck_vcex )
self.check_s_size.Bind( wx.EVT_CHECKBOX, self.OnCheck_s_size )
+ self.listcol.Bind( wx.EVT_LIST_ITEM_SELECTED, self.ChangeCount)
+ self.listcol.Bind( wx.EVT_LIST_ITEM_DESELECTED, self.ChangeCount)
+ self.butcount.Bind( wx.EVT_BUTTON, self.ChangeCount)
+ self.ChangeCount(wx.EVT_BUTTON)
+
def __set_properties(self):
self.choice1.SetSelection(self.paramsimi['coeff'])
self.comcheck.SetValue(self.paramsimi['com'])
self.choix_com.SetSelection(self.paramsimi['communities'])
self.halo.SetValue(self.paramsimi['halo'])
+
+ def ChangeCount(self, evt) :
+ self.textcount.SetValue('%i' % self.listcol.GetSelectedItemCount())
def OnCheck_s_size(self, evt):
if self.check_s_size.GetValue() :
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)
- #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):
- #try:
self.analyse_matrix(ChiSquare, matrix = matrix, analyse_type = 'chi2', dlgnb = 3)
- #except:
- # BugReport(self)
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 :
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
else :
svg = 1
typegraph = dial.choicetype.GetSelection()
- typefile = '.png'
+ if svg :
+ typefile = '.svg'
+ else :
+ typefile = '.png'
if self.clnb <= 3 and typegraph == 1 :
typegraph = 2
if typegraph == 2:
ira = wx.GetApp().GetTopWindow()
self.page.tgens, etoiles = ReadList(parametres['tgenspec'], ira.syscoding, sep="\t")
tgentab = False
+ gparent = None
for i in range(page.GetPageCount()) :
tab = page.GetPage(i)
+ if 'gparent' in dir(tab) :
+ if tab.gparent is not None :
+ gparent = tab.gparent
if 'tgen' in dir(tab) :
if tab.tgen :
tgentab = tab
self.page.tgentab.RefreshData(self.page.tgens)
self.page.SetSelection(i)
else :
- self.page.tgentab = ListForSpec(ira, None, self.page.tgens, etoiles[1:])
+ self.page.tgentab = ListForSpec(ira, gparent, self.page.tgens, etoiles[1:])
self.page.tgentab.tgen = True
self.page.AddPage(self.page.tgentab, u'Tgens Specificities')
self.page.SetSelection(self.page.GetPageCount() - 1)
self.ListPanEff = ListForSpec(ira, self, self.DictEff, self.etoiles)
self.ListPanEffType = ListForSpec(ira, self, self.DictEffType, self.etoiles)
self.ListPanEffRelForme = ListForSpec(ira, self, self.DictEffRelForme, self.etoiles)
- self.ListPanEffRelType = ListForSpec(ira, self.parent, self.DictEffRelType, self.etoiles)
+ self.ListPanEffRelType = ListForSpec(ira, self, self.DictEffRelType, self.etoiles)
self.TabStat.AddPage(self.ListPan, u'formes')
if os.path.exists(self.pathout['banalites.csv']) :
for i in range(0,len(list_graph)):
if os.path.exists(os.path.join(self.dirout,list_graph[i][0])) :
- self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
+ filename, ext = os.path.splitext(list_graph[i][0])
+ if ext == '.svg' :
+ self.listimg.append(hl.HyperLinkCtrl(self.panel_1, -1, os.path.join(self.dirout,list_graph[i][0]), URL=os.path.join(self.dirout,list_graph[i][0])))
+ else :
+ self.listimg.append(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(os.path.join(self.dirout,list_graph[i][0]), wx.BITMAP_TYPE_ANY)))
self.labels.append(wx.StaticText(self.panel_1, -1, list_graph[i][1]))
self.__set_properties()
'type_dendro': 0,
'color_nb': 0,
'taille_classe' : True,
- 'type_tclasse' : 0
+ 'type_tclasse' : 0,
+ 'svg' : 0
}
self.type_dendro = [ u"phylogram", u"cladogram", u"fan", u"unrooted", u"radial" ]
self.param['color_nb'] = dial.m_radioBox1.GetSelection()
self.param['taille_classe'] = dial.m_checkBox1.GetValue()
self.param['type_tclasse'] = dial.m_radioBox2.GetSelection()
+ self.param['svg'] = dial.choice_format.GetSelection()
def make_dendro(self, dendro = 'simple') :
- while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+'.png')) :
+ if self.param['svg'] :
+ typefile = '.svg'
+ else :
+ typefile = '.png'
+ while os.path.exists(os.path.join(self.dirout, 'dendrogramme_' + str(self.graphnb)+typefile)) :
self.graphnb += 1
- fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+'.png'))
+ fileout = ffr(os.path.join(self.dirout,'dendrogramme_' + str(self.graphnb)+typefile))
width = self.param['width']
height = self.param['height']
type_dendro = self.type_dendro[self.param['type_dendro']]
histo='FALSE'
else :
histo = 'TRUE'
+ if self.param['svg'] :
+ svg = 'TRUE'
+ else :
+ svg = 'FALSE'
dendro_path = self.dictpathout['Rdendro']
classe_path = self.dictpathout['uce']
txt = """
load("%s")
source("%s")
chistable <- chistabletot[1:(debsup-1),]
- open_file_graph("%s", width=%i, height=%i)
+ open_file_graph("%s", width=%i, height=%i, svg = %s)
plot.dendro.prof(tree.cut1$tree.cl, classes, chistable, nbbycl = 60, type.dendro="%s", bw=%s, lab=NULL)
- """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw)
+ """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
elif dendro == 'cloud' :
txt += """
load("%s")
source("%s")
chistable <- chistabletot[1:(debsup-1),]
- open_file_graph("%s", width=%i, height=%i)
+ open_file_graph("%s", width=%i, height=%i, svg=%s)
plot.dendro.cloud(tree.cut1$tree.cl, classes, chistable, nbbycl = 300, type.dendro="%s", bw=%s, lab=NULL)
- """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, type_dendro, bw)
+ """ % (ffr(self.dictpathout['RData.RData']), ffr(self.ira.RscriptsPath['Rgraph']), ffr(fileout), width, height, svg, type_dendro, bw)
tmpfile = tempfile.mktemp()
check_Rresult(self.ira, error)
self.list_graph.append([fileout, 'Dendrogramme CHD1 - %s' % type_dendro])
print_liste(self.dictpathout['liste_graph_chd'], self.list_graph)
- self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+ if self.param['svg'] :
+ self.sizer_3.Add(hl.HyperLinkCtrl(self.panel_1, -1, fileout, URL=fileout), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
+ else :
+ self.sizer_3.Add(wx.StaticBitmap(self.panel_1, -1, wx.Bitmap(fileout, wx.BITMAP_TYPE_ANY)), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
self.sizer_3.Add(wx.StaticText(self.panel_1,-1, 'Dendrogramme CHD1 - %s' % type_dendro), 0, wx.ALIGN_CENTER_HORIZONTAL, 0)
self.sizer_3.Fit(self.panel_1)
self.Layout()
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 = 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)
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 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.Bind(wx.EVT_MENU, self.onstcaract, id = nid)
menu.AppendMenu(-1, u"Segments de texte caractéristiques", menu_stcaract)
#menu.Append(self.popup_Tgen_glob, "Tgen global")
- menu.Append(self.onmaketgen, "Make Tgen")
+ if not self.tgen :
+ menu.Append(self.onmaketgen, "Make Tgen")
self.PopupMenu(menu)
menu.Destroy()
else :
pass
if keepline and line.strip() not in ['LP', 'TD', ''] :
- ucis[-1][1] = '\n'.join([ucis[-1][1],line])
+ ucis[-1][1] = '\n'.join([ucis[-1][1],line.replace(u'*', ' ')])
return ucis
class ParseFactivaPaste :
def __init__(self, txtdir, fileout, encodage_in, encodage_out) :
- files = os.listdir(txtdir)
- files = [f for f in files if f.split('.')[-1] == 'txt']
+ files = []
+ for root, subfolders, subfiles in os.walk(txtdir) :
+ nf = [os.path.join(root, f) for f in subfiles if f.split('.')[-1] == 'txt']
+ nf.sort()
+ files += nf
tot = 0
with open(fileout,'w') as outf :
for f in files :
print f
- f = os.path.join(txtdir, f)
- print f
with codecs.open(f, 'rU', encodage_in) as infile :
content = infile.read()
ucis = parsetxtpaste(content)
'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 <= 0.05</font><br>
- <font color=blue>p <= 0.05 mais il y a des valeurs théoriques < 5</font><br>
- <font color=red>p > 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 :
)
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.parametres = None
def doanalyse(self):
-
-
- #self.dlg=wx.ProgressDialog("Traitements",
- # "Veuillez patienter...",
- # maximum = 4,
- # parent=parent,
- # style = wx.PD_APP_MODAL|wx.PD_AUTO_HIDE|wx.PD_ELAPSED_TIME
- # )
-
-
-
- self.count += 1
+ self.count = 1
keepGoing = self.dlg.Update(self.count,u"Analyse dans R...")
- #analyse=MakeChi2(self.parent, self.colsel1, self.colsel2, self.chioption, self.tableau)
- #self.tableau = tableau
self.OutFrame=tempfile.mktemp(dir=self.parent.TEMPDIR)
- print self.OutFrame
- #self.parent=parent
self.encode=self.parent.encode
self.TEMPDIR=self.parent.TEMPDIR
self.RPath=self.parent.PathPath.get('PATHS','rpath')
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'
+ """%ffr(self.parent.RscriptsPath['Rfunct'])
txt += """
source("%s")
""" % ffr(self.parent.RscriptsPath['Rgraph'])
# 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]
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)
</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>'
#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
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.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 :
'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.RPath = self.parent.PathPath.get('PATHS', 'rpath')
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
res = wx.ID_OK
if res == wx.ID_OK :
if not self.actives :
- self.tableau.selected_col = dialcol.list_box_1.GetSelections()
+ self.tableau.selected_col = dialcol.m_listBox1.GetSelections()
actives = self.tableau.getactlistfromselection(self.tableau.selected_col)
else :
actives = self.actives
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.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
self.parametres = None
return False
- def doanalyse2(self) :
+ def doanalyse(self) :
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
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()
dial.CenterOnParent()
val = dial.ShowModal()
if val == wx.ID_OK :
- self.parametres['colsel'] = dial.list_box_1.GetSelections()
+ self.parametres['colsel'] = dial.m_listBox1.GetSelections()
self.parametres['header'] = dial.header
else :
self.parametres = None
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
+ self.dlg = progressbar(self.ira, 4)
else :
continu = True
if continu :
self.parametres['type'] = 'wordcloud'
#FIXME
limit = 3
+ self.dlg.Destroy()
res = self.make_option()
if res == wx.ID_OK :
if self.parametres['mode'] == 2 :
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.ild['chi2'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'chi2.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['reinertmatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'reinertmatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.ild['simimatrix'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'simimatrix.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
+ self.ild['proto'] = self.il.Add(wx.Image(os.path.join(self.parent.images_path,'proto.png'), wx.BITMAP_TYPE_PNG).Scale(16,16).ConvertToBitmap())
self.SetImageList(self.il)
self.count = 0