Beispiel #1
0
 def cliquerFile(self):
     global filename
     self.charge_network.configure(state=DISABLED)
     self.charge_simulation.configure(state=DISABLED)
     self.reduce.configure(state=DISABLED)
     self.charge_reduced_simulation.configure(state=DISABLED)
     self.charge_network_reduced.configure(state=DISABLED)
     self.button_vectors.configure(state=DISABLED)
     filename = filedialog.askopenfilename(initialdir="/HOME",
                                           title="Select file",
                                           filetypes=(("csv files",
                                                       "*.csv"),
                                                      ("all files", "*.*")))
     try:
         lnetreduce.load_graph(filename)
         self.labelFile.configure(text=basename(filename))
         self.charge_network.configure(state=NORMAL)
         self.charge_simulation.configure(state=NORMAL)
         self.reduce.configure(state=NORMAL)
         self.charge_reduced_simulation.configure(state=DISABLED)
         self.charge_network_reduced.configure(state=DISABLED)
         self.button_vectors.configure(state=DISABLED)
     except:
         showwarning(
             message=
             'An error occured loading the model, \n please check format', )
Beispiel #2
0
    def cliquerChangeLayout_reduced(self):
        #os.system("python3 simulate.py "+filename+"_reduced.tsv "+self.result.Entry_number.get())
        u_G = lnetreduce.load_graph(
            '%s/%s_reduced.tsv' %
            (work_folder, basename(filename).split('.')[0]))

        if self.networkReducedWindow.Layout_CB.get() in [
                "neato", "dot", "twopi", "circo", "fdp"
        ]:
            layout = self.networkReducedWindow.Layout_CB.get()

            imageo = draw_graph(u_G, layout)

            resultNetwork = ImageTk.PhotoImage(imageo)
            #self.networkReducedWindow.canva=Canvas(self.networkReducedWindow.frameImage,width=resultNetwork.width(),height=resultNetwork.height())

            self.networkReducedWindow.canva.delete("all")
            self.networkReducedWindow.canva.config(
                width=resultNetwork.width(), height=resultNetwork.height())
            self.networkReducedWindow.canva.create_image(0,
                                                         0,
                                                         anchor=NW,
                                                         image=resultNetwork)
            self.networkReducedWindow.canva.image = resultNetwork
            self.networkReducedWindow.canva.pack(fill=BOTH)
        else:
            showwarning(message='Please select an existing layout', )
Beispiel #3
0
def generateVectors(savename, vector_folder):
    u_G = lnetreduce.load_graph(savename)
    R = lnetreduce.reduction.right_vector(u_G)
    L = lnetreduce.reduction.left_vector(u_G)
    with open(
            vector_folder + "/" + basename(filename).split('.')[0] +
            "right_vector_reduced.txt", "w") as f:
        f.write(str(R))
    with open(
            vector_folder + "/" + basename(filename).split('.')[0] +
            "left_vector_reduced.txt", "w") as g:
        g.write(str(L))
    u_G = lnetreduce.load_graph(filename)
    R = lnetreduce.reduction.right_vector(u_G)
    L = lnetreduce.reduction.left_vector(u_G)
    with open(
            vector_folder + "/" + basename(filename).split('.')[0] +
            "right_vector_initial.txt", "w") as f:
        f.write(str(R))
    with open(
            vector_folder + "/" + basename(filename).split('.')[0] +
            "left_vector_initial.txt", "w") as g:
        g.write(str(L))
Beispiel #4
0
def reductionpy(filename):
    input_G = lnetreduce.load_graph(filename)
    try:
        u_G = lnetreduce.reduce_graph(input_G)
    except:
        try:
            u_G = lnetreduce.reduce_graph(input_G, partial=True)
            showwarning(
                message=
                'Failed to completely reduce the model, a partially reduced model have been generated'
            )

        except:
            showwarning(
                message=
                'Sorry, this instance is not reducible because its reduced form has non separated reaction speeds'
            )
            sys.exit()

    #lnetreduce.save_graph( u_G, '%s_reduced.tsv' % filename)
    return input_G, u_G
Beispiel #5
0
    def cliquerFolder(self):
        if self.networkInitWindow.Format_CB.get() in [
                "dot", "pdf", "png", "svg"
        ]:

            if self.networkInitWindow.Layout_CB.get() in [
                    "neato", "dot", "twopi", "circo", "fdp"
            ]:
                format = self.networkInitWindow.Format_CB.get()
                self.work_folder = filedialog.askdirectory(
                    initialdir="/HOME", title="Select folder")
                savename = self.work_folder + "/" + basename(
                    filename) + "_input_graph" + "." + format
                input_G = lnetreduce.load_graph(filename)

                layout = self.networkInitWindow.Layout_CB.get()
                fp = save_draw_graph(input_G, savename, format, layout)
            else:
                showwarning(message='Please select an existing layout', )

        else:
            showwarning(message='Please select a correct format', )
Beispiel #6
0
    def cliquerChangeLayout(self):
        input_G = lnetreduce.load_graph(filename)
        format = 'png'
        #if self.networkInitWindow.Format_CB.get()!="":
        #    format = self.networkInitWindow.Format_CB.get()
        layout = 'dot'
        if self.networkInitWindow.Layout_CB.get() != "":
            layout = self.networkInitWindow.Layout_CB.get()
        #savename = filename + "_input_graph" + "." + format

        imageo = draw_graph(input_G, layout)
        resultNetwork = ImageTk.PhotoImage(imageo)
        #self.networkInitWindow.canva=Canvas(self.networkInitWindow.frameImage,width=resultNetwork.width(),height=resultNetwork.height())

        self.networkInitWindow.canva.delete("all")
        self.networkInitWindow.canva.config(width=resultNetwork.width(),
                                            height=resultNetwork.height())
        self.networkInitWindow.canva.create_image(0,
                                                  0,
                                                  anchor=NW,
                                                  image=resultNetwork)
        self.networkInitWindow.canva.image = resultNetwork
        self.networkInitWindow.canva.pack(fill=BOTH)
Beispiel #7
0
    def cliquerNetwork_reduced(self):
        LayoutValue = 'dot'
        u_G = lnetreduce.load_graph(
            '%s/%s_reduced.tsv' %
            (work_folder, basename(filename).split('.')[0]))
        #rsavename = filename + "reduced_graph" + ".png"
        imageo = draw_graph(u_G, LayoutValue)

        self.networkReducedWindow = Toplevel(master=fenetre, bg="white")
        self.networkReducedWindow.title("Reduced network")

        self.networkReducedWindow.frameOption = Frame(
            master=self.networkReducedWindow, bg=self.color)
        self.networkReducedWindow.frameOption.pack(fill=BOTH)

        self.networkReducedWindow.layoutOption = Label(
            master=self.networkReducedWindow.frameOption,
            text="Layout :",
            bg=self.color)
        self.networkReducedWindow.layoutOption.grid(
            row=1,
            column=1,
            pady=(10, 20),
            padx=40,
        )

        self.networkReducedWindow.Layout_CB = ttk.Combobox(
            master=self.networkReducedWindow.frameOption,
            textvariable="LayoutValue",
            values=["neato", "dot", "twopi", "circo", "fdp"])
        self.networkReducedWindow.Layout_CB.grid(
            row=1,
            column=2,
            pady=(10, 20),
            padx=40,
        )

        self.networkReducedWindow.GoButton = Button(
            master=self.networkReducedWindow.frameOption,
            text="Vizualise",
            command=self.cliquerChangeLayout_reduced,
            bg=self.color_button)
        self.networkReducedWindow.GoButton.grid(row=3,
                                                column=2,
                                                pady=(10, 20),
                                                padx=40,
                                                sticky=W)

        self.networkReducedWindow.frameImage = Frame(
            master=self.networkReducedWindow)
        self.networkReducedWindow.frameImage.pack()

        resultNetwork = ImageTk.PhotoImage(imageo, width=1000, height=1200)
        self.networkReducedWindow.canva = Canvas(
            self.networkReducedWindow.frameImage,
            width=resultNetwork.width(),
            height=resultNetwork.height())
        self.networkReducedWindow.canva.create_image(0,
                                                     0,
                                                     anchor=NW,
                                                     image=resultNetwork)
        self.networkReducedWindow.canva.image = resultNetwork
        self.networkReducedWindow.canva.pack(fill=BOTH)

        self.networkReducedWindow.frameSave = Frame(
            master=self.networkReducedWindow, bg=self.color)
        self.networkReducedWindow.frameSave.pack(fill=BOTH)

        self.networkReducedWindow.SaveButton = Button(
            master=self.networkReducedWindow.frameSave,
            text="Save",
            command=self.cliquerFolderReduced,
            bg=self.color_button)
        self.networkReducedWindow.SaveButton.grid(row=3,
                                                  column=2,
                                                  pady=(10, 20),
                                                  padx=40,
                                                  sticky=W)

        self.networkReducedWindow.Format_CB = ttk.Combobox(
            master=self.networkReducedWindow.frameSave,
            textvariable="FormatValue",
            values=["dot", "pdf", "png", "svg"])
        self.networkReducedWindow.Format_CB.grid(
            row=2,
            column=2,
            pady=(10, 20),
            padx=40,
        )

        self.networkReducedWindow.formatOption = Label(
            master=self.networkReducedWindow.frameSave,
            text="Format :",
            bg=self.color)
        self.networkReducedWindow.formatOption.grid(
            row=2,
            column=1,
            pady=(10, 20),
            padx=40,
        )