1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
11 from time import sleep
13 #------------------------------------
14 # import des modules wx
15 #------------------------------------
17 import wx.lib.agw.aui as aui
19 #------------------------------------
20 # import des fichiers du projet
21 #------------------------------------
22 from ProfList import *
23 from functions import exec_rcode, check_Rresult, ReadProfileAsDico, ReadList
25 from dialog import PrefSegProf, PrefProfTypes
26 from chemins import ffr
29 class ProfileSegment() :
31 def __init__(self, parent, pathout, parametres, corpus) :
34 self.dictpathout = pathout
35 self.parametres = parametres
36 dial = PrefSegProf(self.parent)
38 if dial.ShowModal() == wx.ID_OK :
39 if dial.box_lem.GetSelection() == 0 : # @IndentOk
43 self.mini = dial.spin_min.GetValue()
44 self.maxi = dial.spin_max.GetValue()
45 self.eff = dial.spin_eff.GetValue()
47 self.dlg = progressbar(self, maxi=4)
48 self.dlg.Update(1, 'Recherche des segments')
51 self.dlg.Update(3, 'ouverture des profils')
53 self.dlg.Update(4, 'fini')
56 def make_table(self) :
57 self.corpus.make_segments_profile(self.dictpathout['segments_classes'], lenmin=self.mini, lenmax=self.maxi, effmin=self.eff, lem=self.lem)
63 """ % (ffr(self.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct']))
66 dt <- read.csv2("%s", row.names = 1)
67 to <- build.pond.prof(dt)
68 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
69 """ % (ffr(self.corpus.dictpathout['segments_classes']), ffr(self.dictpathout['prof_seg']), ffr(self.dictpathout['antiprof_seg']))
70 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
71 with open(fo, 'w', encoding='utf8') as f :
73 pid = exec_rcode(self.parent.RPath, fo, wait=False)
74 while pid.poll() == None :
75 self.dlg.Pulse('Construction des profils...')
77 check_Rresult(self.parent, pid)
80 SelectTab = self.parent.nb.GetSelection()
81 page = self.parent.nb.GetPage(SelectTab).TabChdSim
82 prof_seg = ReadProfileAsDico(self.dictpathout['prof_seg'], True, 'utf8')
83 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
84 for i in range(0, len(self.corpus.lc)) :
85 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
86 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
87 page.AddPage(prof_seg_nb, 'Profils des segements répétés')
88 page.SetSelection(page.GetPageCount() - 1)
93 def __init__(self, parent, corpus, parametres) :
96 self.parametres = parametres
97 self.outprof = self.corpus.dictpathout['prof_type']
98 dial = PrefProfTypes(self.parent)
99 dial.fbb.SetValue(self.outprof)
100 dial.CenterOnParent()
101 res = dial.ShowModal()
103 if dial.radio_type.GetSelection() == 0 :
107 # if 'outprof' in self.corpus.parametre :
108 # self.corpus.parametre['outprof'][self.outprof] = alceste
110 # self.corpus.parametre['outprof'] = {self.outprof: alceste}
111 self.dlg = progressbar(self, maxi=4)
112 self.dlg.Update(1, 'Recherche des types')
114 self.dlg.Update(1, 'Construction des profils')
115 self.make_prof(alceste=alceste)
116 self.dlg.Update(3, 'Ouverture des profils')
117 self.do_layout(alceste=alceste)
118 self.dlg.Update(4, 'fini')
121 def make_table(self) :
122 self.corpus.make_proftype(self.corpus.dictpathout['type_cl'])
124 def make_prof(self, alceste=True) :
128 """ % (ffr(self.corpus.dictpathout['RData']), ffr(self.parent.RscriptsPath['chdfunct']))
130 dt <- read.csv2("%s", row.names = 1)
131 """ % ffr(self.corpus.dictpathout['type_cl'])
134 to <- build.pond.prof(dt)
135 PrintProfile(n1,to[4],NULL,to[5],NULL,clnb,"%s","%s")
136 """ % (ffr(self.outprof), ffr(self.corpus.dictpathout['antiprof_type']))
140 write.csv2(to[[1]], file = "%s")
141 """ % (ffr(self.outprof))
142 # write.csv2(to[[3]], file = "%s")
144 fo = tempfile.mktemp(dir=self.parent.TEMPDIR)
145 with open(fo, 'w', encoding='utf8') as f :
147 pid = exec_rcode(self.parent.RPath, fo, wait=False)
148 while pid.poll() == None :
149 self.dlg.Pulse('Construction des profils...')
151 check_Rresult(self.parent, pid)
153 def do_layout(self, alceste=True) :
154 SelectTab = self.parent.nb.GetSelection()
155 page = self.parent.nb.GetPage(SelectTab).TabChdSim
156 prof_seg_nb = aui.AuiNotebook(self.parent, -1, wx.DefaultPosition)
158 prof_seg = ReadProfileAsDico(self.outprof, True)
159 for i in range(0, len(self.corpus.lc)) :
160 ntab = ProfListctrlPanel(self.parent, self, prof_seg[str(i + 1)], False, i + 1)
161 prof_seg_nb.AddPage(ntab, 'classe %i' % (i + 1))
163 self.DictSpec, first = ReadList(self.outprof)
164 self.ListPan = ListForSpec(self.parent, self, self.DictSpec, first[1:])
165 prof_seg_nb.AddPage(self.ListPan, 'Spécificités')
167 page.AddPage(prof_seg_nb, 'Profils des types')
168 page.SetSelection(page.GetPageCount() - 1)