2 # -*- coding: utf-8 -*-
3 # Author: Pierre Ratinaud
4 # Copyright (c) 2010, Pierre Ratinaud
10 import wx.lib.agw.aui as aui
11 from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList
13 from dialog import PrefSegProf, PrefProfTypes
14 from time import sleep
16 class ProfileSegment() :
17 def __init__(self, parent, pathout, parametres, corpus) :
20 self.dictpathout = pathout
21 self.parametres = parametres
22 dial = PrefSegProf(self.parent)
24 if dial.ShowModal() == wx.ID_OK :
25 if dial.box_lem.GetSelection() == 0 : # @IndentOk
29 self.mini = dial.spin_min.GetValue()
30 self.maxi = dial.spin_max.GetValue()
31 self.eff = dial.spin_eff.GetValue()
33 self.dlg = progressbar(self, maxi=4)
34 self.dlg.Update(1, u'Recherche des segments')
37 self.dlg.Update(3, u'ouverture des profils')
39 self.dlg.Update(4, 'fini')
42 def make_table(self) :
43 self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin=self.mini, lenmax=self.maxi, effmin=self.eff, lem=self.lem)
49 """ % (self.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
52 dt <- read.csv2("%s", row.names = 1)
53 to <- build.pond.prof(dt)
54 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
55 """ % (self.corpus.dictpathout['segments_classes'], self.dictpathout['prof_seg'], self.dictpathout['antiprof_seg'])
56 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
57 with open(fo, 'w') as f :
59 pid = exec_rcode(self.parent.RPath, fo, wait=False)
60 while pid.poll() == None :
61 self.dlg.Pulse(u'Construction des profils...')
63 check_Rresult(self.parent, pid)
66 SelectTab = self.parent.nb.GetSelection()
67 page = self.parent.nb.GetPage(SelectTab).TabChdSim
68 prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding)
69 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
70 for i in range(0, len(self.corpus.lc)) :
71 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
72 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
73 page.AddPage(prof_seg_nb, u'Profils des segements répétés')
74 page.SetSelection(page.GetPageCount() - 1)
77 def __init__(self, parent, corpus, parametres) :
80 self.parametres = parametres
81 self.outprof = self.corpus.dictpathout['prof_type']
82 dial = PrefProfTypes(self.parent)
83 dial.fbb.SetValue(self.outprof)
85 res = dial.ShowModal()
87 if dial.radio_type.GetSelection() == 0 :
91 # if 'outprof' in self.corpus.parametre :
92 # self.corpus.parametre['outprof'][self.outprof] = alceste
94 # self.corpus.parametre['outprof'] = {self.outprof: alceste}
95 self.dlg = progressbar(self, maxi=4)
96 self.dlg.Update(1, u'Recherche des types')
98 self.dlg.Update(1, u'Construction des profils')
99 self.make_prof(alceste=alceste)
100 self.dlg.Update(3, u'Ouverture des profils')
101 self.do_layout(alceste=alceste)
102 self.dlg.Update(4, 'fini')
105 def make_table(self) :
106 self.corpus.make_proftype(self.corpus.dictpathout['type_cl'])
108 def make_prof(self, alceste=True) :
112 """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
115 dt <- read.csv2("%s", row.names = 1)
116 """ % self.corpus.dictpathout['type_cl']
119 to <- build.pond.prof(dt)
120 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
121 """ % (self.outprof, self.corpus.dictpathout['antiprof_type'])
125 write.csv2(to[[1]], file = "%s")
127 # write.csv2(to[[3]], file = "%s")
129 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
130 with open(fo, 'w') as f :
132 pid = exec_rcode(self.parent.RPath, fo, wait=False)
133 while pid.poll() == None :
134 self.dlg.Pulse(u'Construction des profils...')
136 check_Rresult(self.parent, pid)
138 def do_layout(self, alceste=True) :
139 SelectTab = self.parent.nb.GetSelection()
140 page = self.parent.nb.GetPage(SelectTab).TabChdSim
141 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
143 prof_seg = ReadProfileAsDico(self.outprof, True)
144 for i in range(0, len(self.corpus.lc)) :
145 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
146 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
148 self.DictSpec, first = ReadList(self.outprof)
149 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first[1:])
150 prof_seg_nb.AddPage(self.ListPan, u'Spécificités')
152 page.AddPage(prof_seg_nb, u'Profils des types')
153 page.SetSelection(page.GetPageCount() - 1)