2 # -*- coding: utf-8 -*-
3 #Author: Pierre Ratinaud
4 #Copyright (c) 2010, Pierre Ratinaud
10 from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList
12 from dialog import PrefSegProf, PrefProfTypes
13 from time import sleep
15 class ProfileSegment() :
16 def __init__(self, parent, pathout, parametres, corpus) :
19 self.dictpathout = pathout
20 self.parametres = parametres
21 dial = PrefSegProf(self.parent)
23 if dial.ShowModal() == wx.ID_OK :
24 if dial.box_lem.GetSelection() == 0 :
28 self.mini = dial.spin_min.GetValue()
29 self.maxi = dial.spin_max.GetValue()
30 self.eff = dial.spin_eff.GetValue()
32 self.dlg = progressbar(self, maxi = 4)
33 self.dlg.Update(1, u'Recherche des segments')
36 self.dlg.Update(3, u'ouverture des profils')
38 self.dlg.Update(4, 'fini')
41 def make_table(self) :
42 self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin = self.mini, lenmax = self.maxi, effmin = self.eff, lem = self.lem)
48 """ % (self.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
51 dt <- read.csv2("%s", row.names = 1)
52 to <- build.pond.prof(dt)
53 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
54 """ % (self.corpus.dictpathout['segments_classes'], self.dictpathout['prof_seg'], self.dictpathout['antiprof_seg'])
55 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
56 with open(fo, 'w') as f :
58 pid = exec_rcode(self.parent.RPath, fo, wait = False)
59 while pid.poll() == None :
60 self.dlg.Pulse(u'Construction des profils...')
62 check_Rresult(self.parent, pid)
65 SelectTab = self.parent.nb.GetSelection()
66 page = self.parent.nb.GetPage(SelectTab).TabChdSim
67 prof_seg = ReadProfileAsDico(self, self.dictpathout['prof_seg'], True, self.parent.syscoding)
68 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
69 for i in range(0,len(self.corpus.lc)) :
70 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
71 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
72 page.AddPage(prof_seg_nb, u'Profils des segements répétés')
73 page.SetSelection(page.GetPageCount() - 1)
76 def __init__(self, parent, corpus, parametres) :
79 self.parametres = parametres
80 self.outprof = self.corpus.dictpathout['prof_type']
81 dial = PrefProfTypes(self.parent)
82 dial.fbb.SetValue(self.outprof)
84 res = dial.ShowModal()
86 if dial.radio_type.GetSelection() == 0 :
90 #if 'outprof' in self.corpus.parametre :
91 # self.corpus.parametre['outprof'][self.outprof] = alceste
93 # self.corpus.parametre['outprof'] = {self.outprof: alceste}
94 self.dlg = progressbar(self, maxi = 4)
95 self.dlg.Update(1, u'Recherche des types')
97 self.dlg.Update(1, u'Construction des profils')
98 self.make_prof(alceste = alceste)
99 self.dlg.Update(3, u'Ouverture des profils')
100 self.do_layout(alceste = alceste)
101 self.dlg.Update(4, 'fini')
104 def make_table(self) :
105 self.corpus.make_proftype(self.corpus.dictpathout['type_cl'])
107 def make_prof(self, alceste = True) :
111 """ % (self.corpus.dictpathout['RData'], self.parent.RscriptsPath['chdfunct'])
114 dt <- read.csv2("%s", row.names = 1)
115 """ % self.corpus.dictpathout['type_cl']
118 to <- build.pond.prof(dt)
119 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
120 """ % (self.outprof, self.corpus.dictpathout['antiprof_type'])
124 write.csv2(to[[1]], file = "%s")
126 #write.csv2(to[[3]], file = "%s")
128 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
129 with open(fo, 'w') as f :
131 pid = exec_rcode(self.parent.RPath, fo, wait = False)
132 while pid.poll() == None :
133 self.dlg.Pulse(u'Construction des profils...')
135 check_Rresult(self.parent, pid)
137 def do_layout(self, alceste = True) :
138 SelectTab = self.parent.nb.GetSelection()
139 page = self.parent.nb.GetPage(SelectTab).TabChdSim
140 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
142 prof_seg = ReadProfileAsDico(self, self.outprof, True)
143 for i in range(0,len(self.corpus.lc)) :
144 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
145 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
147 self.DictSpec, first = ReadList(self.outprof)
148 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first)
149 prof_seg_nb.AddPage(self.ListPan, u'Spécificités')
151 page.AddPage(prof_seg_nb, u'Profils des types')
152 page.SetSelection(page.GetPageCount() - 1)