pKaTool/pKa_system_file_menu.py
def load_pH_activity_profile(self, filename=None,parent=None):
        """Read pH activity profile from a text file"""
        if not parent:
            parent=self.win
        import tkFileDialog, os
        if not filename:
            savedir=os.getcwd()
            filename=tkFileDialog.askopenfilename(defaultextension="*.txt",
                                                  initialdir=savedir,
                                                  filetypes=[("Text file","*.txt"),
                                                             ("Comma separated","*.csv"),
                                                             ("All files","*.*")],
                                                  parent=parent)

        if filename:
            if os.path.isfile(filename):
                if filename[-4:]=='.csv':
                    splitter=','
                else:
                    splitter=None
                #
                # Read the file
                #
                fd=open(filename)
                self.activity_data={}
                header=fd.readline()
                header=header.split()

                line = fd.readline()
                while len(line)>2 and not line =='END':
                    words = line.split(splitter)
                    print words
                    self.activity_data[float(words[0])] = float(words[1])
                    print 'loaded',words[0],':  ',words[1]
                    line = fd.readline()
                fd.close()
                #
                # normalise profile
                #
                max = 0
                for key in self.activity_data.keys():
                    if self.activity_data[key] > max:
                        max = self.activity_data[key]
                #print 'max',max
                for key in self.activity_data.keys():
                    self.activity_data[key] = self.activity_data[key]/max

                #print self.activity_data

                self.micro_var.set(1.0)
                self.update_pkasystem_curves()


            else:
                import tkMessageBox
                tkMessageBox.showwarning('File does not exist',
                                         'Could not find %s.' %filename,
                                         parent=parent)

        return
Read pH activity profile from a text file
Read pH activity profile from a text file
Read pH activity profile from a text file
def load_pH_activity_profile(self, filename=None,parent=None):
        if not parent:
            parent=self.win
        import tkFileDialog, os
        if not filename:
            savedir=os.getcwd()
            filename=tkFileDialog.askopenfilename(defaultextension="*.txt",
                                                  initialdir=savedir,
                                                  filetypes=[("Text file","*.txt"),
                                                             ("Comma separated","*.csv"),
                                                             ("All files","*.*")],
                                                  parent=parent)
        if filename:
            if os.path.isfile(filename):
                if filename[-4:]=='.csv':
                    splitter=','
                else:
                    splitter=None
                 Read the file
                fd=open(filename)
                self.activity_data={}
                header=fd.readline()
                header=header.split()
                line = fd.readline()
                while len(line)>2 and not line =='END':
                    words = line.split(splitter)
                    print words
                    self.activity_data[float(words[0])] = float(words[1])
                    print 'loaded',words[0],':  ',words[1]
                    line = fd.readline()
                fd.close()
                 normalise profile
                max = 0
                for key in self.activity_data.keys():
                    if self.activity_data[key] > max:
                        max = self.activity_data[key]
                print 'max',max
                for key in self.activity_data.keys():
                    self.activity_data[key] = self.activity_data[key]/max
                print self.activity_data
                self.micro_var.set(1.0)
                self.update_pkasystem_curves()
            else:
                import tkMessageBox
                tkMessageBox.showwarning('File does not exist',
                                         'Could not find %s.' %filename,
                                         parent=parent)
        return
def load_pH_activity_profile ( self , filename = None , parent = None ) : if not parent : parent = self . win import tkFileDialog , os if not filename : savedir = os . getcwd ( ) filename = tkFileDialog . askopenfilename ( defaultextension = "*.txt" , initialdir = savedir , filetypes = [ ( "Text file" , "*.txt" ) , ( "Comma separated" , "*.csv" ) , ( "All files" , "*.*" ) ] , parent = parent ) if filename : if os . path . isfile ( filename ) : if filename [ - 4 : ] == '.csv' : splitter = ',' else : splitter = None fd = open ( filename ) self . activity_data = { } header = fd . readline ( ) header = header . split ( ) line = fd . readline ( ) while len ( line ) > 2 and not line == 'END' : words = line . split ( splitter ) print words self . activity_data [ float ( words [ 0 ] ) ] = float ( words [ 1 ] ) print 'loaded' , words [ 0 ] , ':  ' , words [ 1 ] line = fd . readline ( ) fd . close ( ) max = 0 for key in self . activity_data . keys ( ) : if self . activity_data [ key ] > max : max = self . activity_data [ key ] for key in self . activity_data . keys ( ) : self . activity_data [ key ] = self . activity_data [ key ] / max self . micro_var . set ( 1.0 ) self . update_pkasystem_curves ( ) else : import tkMessageBox tkMessageBox . showwarning ( 'File does not exist' , 'Could not find %s.' % filename , parent = parent ) return
Read pH activity profile from a text file
Read pH activity profile from a text file
"""Read pH activity profile from a text file""" # # Read the file # # # normalise profile # #print 'max',max #print self.activity_data
self
filename
parent