2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2010 Pierre Ratinaud
14 from chemins import ffr,FFF
15 import wx.lib.sized_controls as sc
16 from time import sleep
17 from functions import exec_rcode, check_Rresult
18 from dialog import ChiDialog, PrefChi
19 from analysematrix import AnalyseMatrix
22 if float(line[5]) <= 0.05 and line[6] != 'warning':
24 elif float(line[5]) <= 0.05 and line[6] == 'warning':
30 def clean_line(result) :
31 return [[val for val in line if val != '**'] for line in result]
33 def make_table(tabs, tab_title, res) :
34 return ['<br>'.join(['<font color=%s>%s</font>' % (res[i][-1], tab_title), HTML.table(tab)]) for i,tab in enumerate(tabs)]
36 def make_restab(res) :
37 return ['<br>'.join(['<font color=%s>%s</font>'% (line[-1], u'Résultats'),HTML.table([['chi', line[3]],['p', line[5]]])]) for i,line in enumerate(res)]
39 def make_htmlgraphs(graphs) :
40 return ['<img src=%s>' % os.path.basename(val) for val in graphs]
42 def make_link_list(res, text) :
43 return ['<a name=back_%i></a><a href=#%i><font color=%s>%s</font></a>' % (i, i, chi[-1], text[i]) for i, chi in enumerate(res)]
45 def make_title(res, text) :
46 return ['<a name=%i></a><br><font color=%s>%s</font><br><a href=#back_%i>retour</a><br>' % (i, val[-1], text[i], i) for i, val in enumerate(res)]
49 chioption = { 'valobs' : True,
62 def __init__(self, parent, select1, select2, chioption, tableau):
63 self.tableau = tableau
64 self.OutFrame=tempfile.mktemp(dir=parent.TEMPDIR)
67 self.encode=self.parent.encode
68 self.TEMPDIR=parent.TEMPDIR
69 self.RPath=parent.PathPath.get('PATHS','rpath')
73 self.TextCroise.append(self.tableau.colnames[i] + ' / ' + self.tableau.colnames[j])
75 for val in chioption :
77 rchioption[val] = 'TRUE'
79 rchioption[val] = 'FALSE'
82 """%self.parent.RscriptsPath['Rfunct']
83 # if parent.tableau.: rownames=1
84 # else : rownames='NULL'
85 # if parent.g_header : header = 'TRUE'
86 # else : header = 'FALSE'
89 """ % ffr(self.parent.RscriptsPath['Rgraph'])
100 """ % (rchioption['valobs'], rchioption['valtheo'], rchioption['contrib'], rchioption['resi'], rchioption['pourcent'], rchioption['pourcentl'], rchioption['pourcentc'], rchioption['graph'], rchioption['bw'])
102 datadm <- read.csv2("%s", encoding="%s", header = TRUE, row.names = 1, sep='\\t', quote = '"', na.string = '')
106 """%(ffr(self.tableau.parametres['csvfile']), self.tableau.parametres['syscoding'])
108 strsel1=str(select1).replace(',','')
112 strsel2=str(select2).replace(',','')
116 for (i in c%s) {"""%strsel1
118 for (j in c%s) {"""%strsel2
120 tab<-table(datadm[,i+1],datadm[,j+1])
121 if (min(dim(tab)) != 1) {
126 chi$contrib<-(tab-chi$expected)/sqrt(chi$expected * ((1 - RS/GT) %%*%% t(1 - CS/GT)))
128 listcol[[cont]]<-ncol(tab)
131 chi <- list(observed = tab, residuals = tab, contrib = tab, statistic = 0, p.value = 1, expected = tab, message = 'pas de calcul')
132 listres[[cont]] <- chi
133 listcol[[cont]]<-ncol(tab)
138 maxcol<-max(unlist(listcol))+1
139 if (maxcol<7) {maxcol<-7}
140 frameout<-matrix('*',1,maxcol)
142 for (chi in listres) {
143 if (min(chi$expected)<5) {
148 if ('message' %%in%% attributes(chi)$names) {
149 att <- "Ce chi2 n\'a pas été calculé"
150 nom_colresi<-colnames(chi$observed)
151 chi$prl <- chi$expected
152 chi$prc <- chi$expected
153 st <- sum(chi$observed)
155 nom_colresi<-colnames(chi$observed)
156 st <- sum(chi$observed)
157 sc <- colSums(chi$observed)
158 sr <- rowSums(chi$observed)
159 chi$prl <- round((chi$observed/sr)*100,2)
160 chi$prc <- t(round((t(chi$observed)/sc)*100,2))
162 fileout<-paste('histo_',count,sep='')
163 fileout<-paste(fileout,'.png',sep='')
165 fileout<-file.path("%s",fileout)
166 if (max(nchar(colnames(chi$observed)))>15) {
167 leg <- 1:length(colnames(chi$observed))
169 leg <- colnames(chi$observed)
172 width<-ncol(chi$observed)*100
173 if (width < 350) {width <- 350}
174 open_file_graph(fileout,width = width, height = 300)
176 layout(matrix(c(1,2),1,2, byrow=TRUE),widths=c(3,1))
179 if (!bw) colors <- rainbow(length(rownames(chi$observed)))
180 else colors <- gray.colors(length(rownames(chi$observed)))
181 barplot(chi$prl,names.arg = leg, beside=TRUE,border=NA, col=colors)
184 plot(0, axes = FALSE, pch = '')
185 legend(x = 'center' , rownames(chi$observed), fill = colors)
188 chi$prl <- cbind(chi$prl, total = rowSums(chi$prl))
189 chi$prc <- rbind(chi$prc, total = colSums(chi$prc))
190 chi$observed<-rbind(chi$observed,total=colSums(chi$observed))
191 chi$observed<-cbind(chi$observed,total=rowSums(chi$observed))
192 chi$pr <- round((chi$observed/st)*100,2)
193 chi$expected<-rbind(chi$expected,total=colSums(chi$expected))
194 chi$expected<-cbind(chi$expected,total=rowSums(chi$expected))
195 chi$expected<-round(chi$expected,digits=2)
196 chi$residuals<-round(chi$residuals,digits=2)
197 chi$contrib<-round(chi$contrib, digits=2)
198 nom_col<-colnames(chi$observed)
200 if (ncol(chi$observed)<maxcol) {
201 for (i in 1:(maxcol-ncol(chi$observed))) {
202 chi$observed<-cbind(chi$observed,'**')
203 chi$pr<-cbind(chi$pr,'**')
204 chi$prl<-cbind(chi$prl,'**')
205 chi$prc<-cbind(chi$prc,'**')
206 chi$expected<-cbind(chi$expected,'**')
207 chi$residuals<-cbind(chi$residuals,'**')
208 chi$contrib<-cbind(chi$contrib,'**')
209 nom_col<-append(nom_col,'**')
210 nom_colresi<-append(nom_colresi,'**')
212 chi$residuals<-cbind(chi$residuals,'**')
213 chi$contrib<-cbind(chi$contrib,'**')
214 nom_colresi<-append(nom_colresi,'**')
215 chi$prc<-cbind(chi$prc,'**')
216 } else if (ncol(chi$observed)==maxcol) {
217 chi$residuals<-cbind(chi$residuals,'**')
218 chi$contrib<-cbind(chi$contrib,'**')
219 nom_colresi<-append(nom_colresi,'**')
220 chi$prc<-cbind(chi$prc,'**')
223 li<-matrix('*obs*',1,maxcol)
224 frameout<-rbind(frameout,li)
225 frameout<-rbind(frameout,nom_col)
226 frameout<-rbind(frameout,chi$observed)
229 li<-matrix('*exp*',1,maxcol)
230 frameout<-rbind(frameout,li)
231 frameout<-rbind(frameout,nom_col)
232 frameout<-rbind(frameout,chi$expected)
235 li<-matrix('*resi*',1,maxcol)
236 frameout<-rbind(frameout,li)
237 frameout<-rbind(frameout,nom_colresi)
238 frameout<-rbind(frameout,chi$residuals)
241 li<-matrix('*contrib*',1,maxcol)
242 frameout<-rbind(frameout,li)
243 frameout<-rbind(frameout,nom_colresi)
244 frameout<-rbind(frameout,chi$contrib)
247 li<-matrix('*pr*', 1, maxcol)
248 frameout<-rbind(frameout,li)
249 frameout<-rbind(frameout,nom_col)
250 frameout<-rbind(frameout,chi$pr)
253 li<-matrix('*prl*', 1, maxcol)
254 frameout<-rbind(frameout,li)
255 frameout<-rbind(frameout,nom_col)
256 frameout<-rbind(frameout,chi$prl)
259 li<-matrix('*prc*', 1, maxcol)
260 frameout<-rbind(frameout,li)
261 frameout<-rbind(frameout,nom_colresi)
262 frameout<-rbind(frameout,chi$prc)
264 res<-c('****','chi',chi$statistic,'p',chi$p.value,att,fileout)
265 frameout<-rbind(frameout,res)
267 li<-matrix('fin_analyse',1,maxcol)
268 frameout<-rbind(frameout,li)
269 write.csv2(frameout,file="%s")
270 """ % (ffr(parent.TEMPDIR),ffr(self.OutFrame))
271 tmpfile=tempfile.mktemp(dir=self.TEMPDIR)
273 tmpscript=open(tmpfile,'w')
276 pid = exec_rcode(self.RPath, tmpfile, wait = False)
277 while pid.poll() == None :
279 check_Rresult(self.parent, pid)
281 def dolayout(self, option):
283 file=open(self.OutFrame,'rU')
284 content=file.readlines()
286 lcont = [line.replace('"','').replace('\n','').split(';') for line in content]
294 res = [chi for chi in lcont if chi[0]=='res']
295 res = [make_res(line) for line in res]
296 coord_res = [i for i,chi in enumerate(lcont) if chi[0]=='res']
298 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*obs*'])
299 names.append(u'Valeurs observées')
300 if option['valtheo'] :
301 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*exp*'])
302 names.append(u'Valeurs théoriques')
304 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*resi*'])
305 names.append(u'Residuals')
306 if option['contrib'] :
307 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*contrib*'])
308 names.append(u'Contributions a posteriori')
309 if option['pourcent'] :
310 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*pr*'])
311 names.append(u'Pourcentages')
312 if option['pourcentl'] :
313 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prl*'])
314 names.append(u'Pourcentages en ligne')
315 if option['pourcentc'] :
316 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prc*'])
317 names.append(u'Pourcentages en colonne')
319 allcoord.append(coord_res)
320 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]
322 allhtml = [make_table(val,names[i],res) for i,val in enumerate(allhtml)]
324 links = make_link_list(res, self.TextCroise)
325 #colors = [line[-1] for line in res]
327 # good = [i for i,chi in enumerate(res) if chi[-1] == 'green' or chi[-1] == 'blue']
328 #select_good = [[val[i] for i in good] for val in tout]
331 html_res = make_restab(res)
332 allhtml.insert(0,html_res)
334 titles = make_title(res, self.TextCroise)
335 allhtml.insert(0,titles)
338 graphs = [line[7] for line in res]
340 html_graphs = make_htmlgraphs(graphs)
341 allhtml.append(html_graphs)
345 <meta http-equiv="content-Type" content="text/html; charset=%s" />\n
347 <h1>Test du Chi2</h1>\n
349 <table border=1><tr><td>
351 <font color=green>p <= 0.05</font><br>
352 <font color=blue>p <= 0.05 mais il y a des valeurs théoriques < 5</font><br>
353 <font color=red>p > 0.05</font>
354 </td></tr></table><br><br>
355 """%self.parent.SysEncoding
358 pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
359 txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
360 txt = header + pretxt + txt + '\n</body></html>'
362 fileout=os.path.join(self.parametres['pathout'],'resultats-chi2.html')
363 with open(fileout, 'w') as f :
365 ListFile.append(fileout)
368 class ChiSquare(AnalyseMatrix):
369 def doparametres(self, dlg = None):
372 dial = ChiDialog(self.parent, -1, u"Chi2", chioption, self.tableau, size=(400, 350),
373 style = wx.DEFAULT_DIALOG_STYLE
375 dial.CenterOnParent()
376 val = dial.ShowModal()
380 keepGoing = dlg.Update(self.count)
382 self.colsel1 = dial.list_box_1.GetSelections()
383 self.colsel2 = dial.list_box_2.GetSelections()
385 chioption['valobs'] = dial.dial.check1.GetValue()
386 chioption['valtheo'] = dial.dial.check2.GetValue()
387 chioption['resi'] = dial.dial.check3.GetValue()
388 chioption['contrib'] = dial.dial.check4.GetValue()
389 chioption['pourcent'] = dial.dial.check5.GetValue()
390 chioption['pourcentl'] = dial.dial.check6.GetValue()
391 chioption['pourcentc'] = dial.dial.check7.GetValue()
392 chioption['graph'] = dial.dial.check8.GetValue()
393 chioption['bw'] = dial.dial.checkbw.GetValue()
396 self.parametres.update(chioption)
397 self.chioption = chioption
402 self.parametres = None
407 #self.dlg=wx.ProgressDialog("Traitements",
408 # "Veuillez patienter...",
411 # style = wx.PD_APP_MODAL|wx.PD_AUTO_HIDE|wx.PD_ELAPSED_TIME
417 keepGoing = self.dlg.Update(self.count,u"Analyse dans R...")
418 #analyse=MakeChi2(self.parent, self.colsel1, self.colsel2, self.chioption, self.tableau)
419 #self.tableau = tableau
420 self.OutFrame=tempfile.mktemp(dir=self.parent.TEMPDIR)
423 self.encode=self.parent.encode
424 self.TEMPDIR=self.parent.TEMPDIR
425 self.RPath=self.parent.PathPath.get('PATHS','rpath')
427 for i in self.colsel1 :
428 for j in self.colsel2 :
429 self.TextCroise.append(self.tableau.colnames[i] + ' / ' + self.tableau.colnames[j])
431 for val in self.chioption :
432 if self.chioption[val]:
433 rchioption[val] = 'TRUE'
435 rchioption[val] = 'FALSE'
438 """%self.parent.RscriptsPath['Rfunct']
439 # if parent.tableau.: rownames=1
440 # else : rownames='NULL'
441 # if parent.g_header : header = 'TRUE'
442 # else : header = 'FALSE'
445 """ % ffr(self.parent.RscriptsPath['Rgraph'])
456 """ % (rchioption['valobs'], rchioption['valtheo'], rchioption['contrib'], rchioption['resi'], rchioption['pourcent'], rchioption['pourcentl'], rchioption['pourcentc'], rchioption['graph'], rchioption['bw'])
458 datadm <- read.csv2("%s", encoding="%s", header = TRUE, row.names = 1, sep='\\t', quote = '"', na.string = '')
462 """%(ffr(self.tableau.parametres['csvfile']), self.tableau.parametres['syscoding'])
463 if len(self.colsel1)==1:
464 strsel1=str(self.colsel1).replace(',','')
466 strsel1=str(self.colsel1)
467 if len(self.colsel2)==1:
468 strsel2=str(self.colsel2).replace(',','')
470 strsel2=str(self.colsel2)
472 for (i in c%s) {""" % strsel1
474 for (j in c%s) {""" % strsel2
476 tab<-table(datadm[,i+1],datadm[,j+1])
477 if (min(dim(tab)) != 1) {
482 chi$contrib<-(tab-chi$expected)/sqrt(chi$expected * ((1 - RS/GT) %%*%% t(1 - CS/GT)))
484 listcol[[cont]]<-ncol(tab)
487 chi <- list(observed = tab, residuals = tab, contrib = tab, statistic = 0, p.value = 1, expected = tab, message = 'pas de calcul')
488 listres[[cont]] <- chi
489 listcol[[cont]]<-ncol(tab)
494 maxcol<-max(unlist(listcol))+1
495 if (maxcol<7) {maxcol<-7}
496 frameout<-matrix('*',1,maxcol)
498 for (chi in listres) {
499 if (min(chi$expected)<5) {
504 if ('message' %%in%% attributes(chi)$names) {
505 att <- "Ce chi2 n\'a pas été calculé"
506 nom_colresi<-colnames(chi$observed)
507 chi$prl <- chi$expected
508 chi$prc <- chi$expected
509 st <- sum(chi$observed)
511 nom_colresi<-colnames(chi$observed)
512 st <- sum(chi$observed)
513 sc <- colSums(chi$observed)
514 sr <- rowSums(chi$observed)
515 chi$prl <- round((chi$observed/sr)*100,2)
516 chi$prc <- t(round((t(chi$observed)/sc)*100,2))
518 fileout<-paste('histo_',count,sep='')
519 fileout<-paste(fileout,'.png',sep='')
521 fileout<-file.path("%s",fileout)
522 if (max(nchar(colnames(chi$observed)))>15) {
523 leg <- 1:length(colnames(chi$observed))
525 leg <- colnames(chi$observed)
528 width<-ncol(chi$observed)*100
529 if (width < 350) {width <- 350}
530 open_file_graph(fileout,width = width, height = 300)
532 layout(matrix(c(1,2),1,2, byrow=TRUE),widths=c(3,1))
535 if (!bw) colors <- rainbow(length(rownames(chi$observed)))
536 else colors <- gray.colors(length(rownames(chi$observed)))
537 barplot(chi$prl,names.arg = leg, beside=TRUE,border=NA, col=colors)
540 plot(0, axes = FALSE, pch = '')
541 legend(x = 'center' , rownames(chi$observed), fill = colors)
544 chi$prl <- cbind(chi$prl, total = rowSums(chi$prl))
545 chi$prc <- rbind(chi$prc, total = colSums(chi$prc))
546 chi$observed<-rbind(chi$observed,total=colSums(chi$observed))
547 chi$observed<-cbind(chi$observed,total=rowSums(chi$observed))
548 chi$pr <- round((chi$observed/st)*100,2)
549 chi$expected<-rbind(chi$expected,total=colSums(chi$expected))
550 chi$expected<-cbind(chi$expected,total=rowSums(chi$expected))
551 chi$expected<-round(chi$expected,digits=2)
552 chi$residuals<-round(chi$residuals,digits=2)
553 chi$contrib<-round(chi$contrib, digits=2)
554 nom_col<-colnames(chi$observed)
556 if (ncol(chi$observed)<maxcol) {
557 for (i in 1:(maxcol-ncol(chi$observed))) {
558 chi$observed<-cbind(chi$observed,'**')
559 chi$pr<-cbind(chi$pr,'**')
560 chi$prl<-cbind(chi$prl,'**')
561 chi$prc<-cbind(chi$prc,'**')
562 chi$expected<-cbind(chi$expected,'**')
563 chi$residuals<-cbind(chi$residuals,'**')
564 chi$contrib<-cbind(chi$contrib,'**')
565 nom_col<-append(nom_col,'**')
566 nom_colresi<-append(nom_colresi,'**')
568 chi$residuals<-cbind(chi$residuals,'**')
569 chi$contrib<-cbind(chi$contrib,'**')
570 nom_colresi<-append(nom_colresi,'**')
571 chi$prc<-cbind(chi$prc,'**')
572 } else if (ncol(chi$observed)==maxcol) {
573 chi$residuals<-cbind(chi$residuals,'**')
574 chi$contrib<-cbind(chi$contrib,'**')
575 nom_colresi<-append(nom_colresi,'**')
576 chi$prc<-cbind(chi$prc,'**')
579 li<-matrix('*obs*',1,maxcol)
580 frameout<-rbind(frameout,li)
581 frameout<-rbind(frameout,nom_col)
582 frameout<-rbind(frameout,chi$observed)
585 li<-matrix('*exp*',1,maxcol)
586 frameout<-rbind(frameout,li)
587 frameout<-rbind(frameout,nom_col)
588 frameout<-rbind(frameout,chi$expected)
591 li<-matrix('*resi*',1,maxcol)
592 frameout<-rbind(frameout,li)
593 frameout<-rbind(frameout,nom_colresi)
594 frameout<-rbind(frameout,chi$residuals)
597 li<-matrix('*contrib*',1,maxcol)
598 frameout<-rbind(frameout,li)
599 frameout<-rbind(frameout,nom_colresi)
600 frameout<-rbind(frameout,chi$contrib)
603 li<-matrix('*pr*', 1, maxcol)
604 frameout<-rbind(frameout,li)
605 frameout<-rbind(frameout,nom_col)
606 frameout<-rbind(frameout,chi$pr)
609 li<-matrix('*prl*', 1, maxcol)
610 frameout<-rbind(frameout,li)
611 frameout<-rbind(frameout,nom_col)
612 frameout<-rbind(frameout,chi$prl)
615 li<-matrix('*prc*', 1, maxcol)
616 frameout<-rbind(frameout,li)
617 frameout<-rbind(frameout,nom_colresi)
618 frameout<-rbind(frameout,chi$prc)
620 res<-c('****','chi',chi$statistic,'p',chi$p.value,att,fileout)
621 frameout<-rbind(frameout,res)
623 li<-matrix('fin_analyse',1,maxcol)
624 frameout<-rbind(frameout,li)
625 write.csv2(frameout,file="%s")
626 """ % (ffr(self.parametres['pathout']),ffr(self.OutFrame))
627 tmpfile=tempfile.mktemp(dir=self.TEMPDIR)
629 tmpscript=open(tmpfile,'w')
632 pid = exec_rcode(self.RPath, tmpfile, wait = False)
633 while pid.poll() == None :
635 check_Rresult(self.parent, pid)
637 keepGoing = self.dlg.Update(self.count,u"Ecriture des résultats")
639 listfileout = self.dolayout(self.chioption)
640 #listfileout=dlg.ShowChi2(ColSel1,ColSel2)
642 #parent.DictTab[u"Chi2_%s*"%parent.FreqNum]=listfileout
643 # parent.newtab = wx.html.HtmlWindow(parent.nb, -1)
644 # if "gtk2" in wx.PlatformInfo:
645 # parent.newtab.SetStandardFonts()
646 # parent.newtab.LoadPage(listfileout[len(listfileout)-1])
647 # parent.nb.AddPage(parent.newtab,u"Chi2_%s*"%parent.FreqNum)
648 # parent.nb.SetSelection(parent.nb.GetPageCount()-1)
649 # parent.ShowTab(wx.EVT_BUTTON)
650 # parent.DisEnSaveTabAs(True)
652 keepGoing = self.dlg.Update(self.count,u"Fini")
654 def dolayout(self, option):
656 file=open(self.OutFrame,'rU')
657 content=file.readlines()
659 lcont = [line.replace('"','').replace('\n','').split(';') for line in content]
667 res = [chi for chi in lcont if chi[0]=='res']
668 res = [make_res(line) for line in res]
669 coord_res = [i for i,chi in enumerate(lcont) if chi[0]=='res']
671 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*obs*'])
672 names.append(u'Valeurs observées')
673 if option['valtheo'] :
674 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*exp*'])
675 names.append(u'Valeurs théoriques')
677 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*resi*'])
678 names.append(u'Residuals')
679 if option['contrib'] :
680 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*contrib*'])
681 names.append(u'Contributions a posteriori')
682 if option['pourcent'] :
683 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*pr*'])
684 names.append(u'Pourcentages')
685 if option['pourcentl'] :
686 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prl*'])
687 names.append(u'Pourcentages en ligne')
688 if option['pourcentc'] :
689 allcoord.append([i for i,chi in enumerate(lcont) if chi[1]=='*prc*'])
690 names.append(u'Pourcentages en colonne')
692 allcoord.append(coord_res)
693 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]
695 allhtml = [make_table(val,names[i],res) for i,val in enumerate(allhtml)]
697 links = make_link_list(res, self.TextCroise)
698 #colors = [line[-1] for line in res]
700 # good = [i for i,chi in enumerate(res) if chi[-1] == 'green' or chi[-1] == 'blue']
701 #select_good = [[val[i] for i in good] for val in tout]
704 html_res = make_restab(res)
705 allhtml.insert(0,html_res)
707 titles = make_title(res, self.TextCroise)
708 allhtml.insert(0,titles)
711 graphs = [line[7] for line in res]
713 html_graphs = make_htmlgraphs(graphs)
714 allhtml.append(html_graphs)
718 <meta http-equiv="content-Type" content="text/html; charset=%s" />\n
720 <h1>Test du Chi2</h1>\n
722 <table border=1><tr><td>
724 <font color=green>p <= 0.05</font><br>
725 <font color=blue>p <= 0.05 mais il y a des valeurs théoriques < 5</font><br>
726 <font color=red>p > 0.05</font>
727 </td></tr></table><br><br>
728 """%self.parent.SysEncoding
731 pretxt = '<br>\n'.join(links)+'<br><hr><br>\n'
732 txt = '<br><hr><br>\n'.join(['<br><br>'.join([tab[i] for tab in allhtml]) for i,val in enumerate(res)])
733 txt = header + pretxt + txt + '\n</body></html>'
735 fileout=os.path.join(self.parametres['pathout'],'resultats-chi2.html')
736 with open(fileout, 'w') as f :
738 ListFile.append(fileout)