2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2010, Pierre Ratinaud
10 if wx.__version__ >= '2.11' :
11 #import agw.aui as aui
12 import wx.lib.agw.aui as aui
15 from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList
17 from dialog import PrefSegProf, PrefProfTypes
18 from time import sleep
20 class ProfileSegment() :
21 def __init__(self, parent, pathout, parametres, corpus) :
24 self.dictpathout = pathout
25 self.parametres = parametres
26 dial = PrefSegProf(self.parent)
28 if dial.ShowModal() == wx.ID_OK :
29 if dial.box_lem.GetSelection() == 0 :
33 self.mini = dial.spin_min.GetValue()
34 self.maxi = dial.spin_max.GetValue()
35 self.eff = dial.spin_eff.GetValue()
37 self.dlg = progressbar(self, maxi = 4)
38 self.dlg.Update(1, u'Recherche des segments')
41 self.dlg.Update(3, u'ouverture des profils')
43 self.dlg.Update(4, 'fini')
46 def make_table(self) :
47 self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin = self.mini, lenmax = self.maxi, effmin = self.eff, lem = self.lem)
53 """ % (self.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
56 dt <- read.csv2("%s", row.names = 1)
57 to <- build.pond.prof(dt)
58 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
59 """ % (self.corpus.dictpathout['segments_classes'], self.dictpathout['prof_seg'], self.dictpathout['antiprof_seg'])
60 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
61 with open(fo, 'w') as f :
63 pid = exec_rcode(self.parent.RPath, fo, wait = False)
64 while pid.poll() == None :
65 self.dlg.Pulse(u'Construction des profils...')
67 check_Rresult(self.parent, pid)
70 SelectTab = self.parent.nb.GetSelection()
71 page = self.parent.nb.GetPage(SelectTab).TabChdSim
72 prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding)
73 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
74 for i in range(0,len(self.corpus.lc)) :
75 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
76 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
77 page.AddPage(prof_seg_nb, u'Profils des segements répétés')
78 page.SetSelection(page.GetPageCount() - 1)
81 def __init__(self, parent, corpus, parametres) :
84 self.parametres = parametres
85 self.outprof = self.corpus.dictpathout['prof_type']
86 dial = PrefProfTypes(self.parent)
87 dial.fbb.SetValue(self.outprof)
89 res = dial.ShowModal()
91 if dial.radio_type.GetSelection() == 0 :
95 #if 'outprof' in self.corpus.parametre :
96 # self.corpus.parametre['outprof'][self.outprof] = alceste
98 # self.corpus.parametre['outprof'] = {self.outprof: alceste}
99 self.dlg = progressbar(self, maxi = 4)
100 self.dlg.Update(1, u'Recherche des types')
102 self.dlg.Update(1, u'Construction des profils')
103 self.make_prof(alceste = alceste)
104 self.dlg.Update(3, u'Ouverture des profils')
105 self.do_layout(alceste = alceste)
106 self.dlg.Update(4, 'fini')
109 def make_table(self) :
110 self.corpus.make_proftype(self.corpus.dictpathout['type_cl'])
112 def make_prof(self, alceste = True) :
116 """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
119 dt <- read.csv2("%s", row.names = 1)
120 """ % self.corpus.dictpathout['type_cl']
123 to <- build.pond.prof(dt)
124 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
125 """ % (self.outprof, self.corpus.dictpathout['antiprof_type'])
129 write.csv2(to[[1]], file = "%s")
131 #write.csv2(to[[3]], file = "%s")
133 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
134 with open(fo, 'w') as f :
136 pid = exec_rcode(self.parent.RPath, fo, wait = False)
137 while pid.poll() == None :
138 self.dlg.Pulse(u'Construction des profils...')
140 check_Rresult(self.parent, pid)
142 def do_layout(self, alceste = True) :
143 SelectTab = self.parent.nb.GetSelection()
144 page = self.parent.nb.GetPage(SelectTab).TabChdSim
145 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
147 prof_seg = ReadProfileAsDico(self.outprof, True)
148 for i in range(0,len(self.corpus.lc)) :
149 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
150 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
152 self.DictSpec, first = ReadList(self.outprof)
153 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first)
154 prof_seg_nb.AddPage(self.ListPan, u'Spécificités')
156 page.AddPage(prof_seg_nb, u'Profils des types')
157 page.SetSelection(page.GetPageCount() - 1)