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
15 from chemins import ffr
17 class ProfileSegment() :
18 def __init__(self, parent, pathout, parametres, corpus) :
21 self.dictpathout = pathout
22 self.parametres = parametres
23 dial = PrefSegProf(self.parent)
25 if dial.ShowModal() == wx.ID_OK :
26 if dial.box_lem.GetSelection() == 0 : # @IndentOk
30 self.mini = dial.spin_min.GetValue()
31 self.maxi = dial.spin_max.GetValue()
32 self.eff = dial.spin_eff.GetValue()
34 self.dlg = progressbar(self, maxi=4)
35 self.dlg.Update(1, u'Recherche des segments')
38 self.dlg.Update(3, u'ouverture des profils')
40 self.dlg.Update(4, 'fini')
43 def make_table(self) :
44 self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin=self.mini, lenmax=self.maxi, effmin=self.eff, lem=self.lem)
50 """ % (ffr(self.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct']))
53 dt <- read.csv2("%s", row.names = 1)
54 to <- build.pond.prof(dt)
55 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
56 """ % (ffr(self.corpus.dictpathout['segments_classes']), ffr(self.dictpathout['prof_seg']), ffr(self.dictpathout['antiprof_seg']))
57 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
58 with open(fo, 'w') as f :
60 pid = exec_rcode(self.parent.RPath, fo, wait=False)
61 while pid.poll() == None :
62 self.dlg.Pulse(u'Construction des profils...')
64 check_Rresult(self.parent, pid)
67 SelectTab = self.parent.nb.GetSelection()
68 page = self.parent.nb.GetPage(SelectTab).TabChdSim
69 prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, self.parent.syscoding)
70 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
71 for i in range(0, len(self.corpus.lc)) :
72 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
73 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
74 page.AddPage(prof_seg_nb, u'Profils des segements répétés')
75 page.SetSelection(page.GetPageCount() - 1)
78 def __init__(self, parent, corpus, parametres) :
81 self.parametres = parametres
82 self.outprof = self.corpus.dictpathout['prof_type']
83 dial = PrefProfTypes(self.parent)
84 dial.fbb.SetValue(self.outprof)
86 res = dial.ShowModal()
88 if dial.radio_type.GetSelection() == 0 :
92 # if 'outprof' in self.corpus.parametre :
93 # self.corpus.parametre['outprof'][self.outprof] = alceste
95 # self.corpus.parametre['outprof'] = {self.outprof: alceste}
96 self.dlg = progressbar(self, maxi=4)
97 self.dlg.Update(1, u'Recherche des types')
99 self.dlg.Update(1, u'Construction des profils')
100 self.make_prof(alceste=alceste)
101 self.dlg.Update(3, u'Ouverture des profils')
102 self.do_layout(alceste=alceste)
103 self.dlg.Update(4, 'fini')
106 def make_table(self) :
107 self.corpus.make_proftype(self.corpus.dictpathout['type_cl'])
109 def make_prof(self, alceste=True) :
113 """ % (ffr(self.corpus.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct']))
116 dt <- read.csv2("%s", row.names = 1)
117 """ % ffr(self.corpus.dictpathout['type_cl'])
120 to <- build.pond.prof(dt)
121 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
122 """ % (ffr(self.outprof), ffr(self.corpus.dictpathout['antiprof_type']))
126 write.csv2(to[[1]], file = "%s")
127 """ % (ffr(self.outprof))
128 # write.csv2(to[[3]], file = "%s")
130 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
131 with open(fo, 'w') as f :
133 pid = exec_rcode(self.parent.RPath, fo, wait=False)
134 while pid.poll() == None :
135 self.dlg.Pulse(u'Construction des profils...')
137 check_Rresult(self.parent, pid)
139 def do_layout(self, alceste=True) :
140 SelectTab = self.parent.nb.GetSelection()
141 page = self.parent.nb.GetPage(SelectTab).TabChdSim
142 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
144 prof_seg = ReadProfileAsDico(self.outprof, True)
145 for i in range(0, len(self.corpus.lc)) :
146 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
147 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
149 self.DictSpec, first = ReadList(self.outprof)
150 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first[1:])
151 prof_seg_nb.AddPage(self.ListPan, u'Spécificités')
153 page.AddPage(prof_seg_nb, u'Profils des types')
154 page.SetSelection(page.GetPageCount() - 1)