pKaTool/pKa_system_file_menu.py
def load_curves(self, filename = '', acid_bases = None):
        """Read titration curves from a text file"""
        import tkFileDialog, os
        savedir=os.getcwd()
        if filename == '':
            filename=tkFileDialog.askopenfilename(defaultextension="*.tcrv",
                                                  initialdir=savedir,
                                                  filetypes=[("pKaTool titration curve file","*.tcrv"),
                                                             ("Text file","*.txt"),
                                                             ("CSV file",".csv"),
                                                             ("All files","*.*")])
        if filename:
            if os.path.isfile(filename):
                #
                # Get the type
                #
                if filename[-4:]=='.csv':
                    filetype='csv'
                    split_char=','
                else:
                    filetype='spacesep'
                    split_char=None
                #
                # Read the file
                #
                fd=open(filename)
                local_titration_data={}
                header=fd.readline()
                header=header.split(split_char)
                exp_groups=header[1:]
                #
                # store experimental data in local_titration_data
                #
                keys = exp_groups
                for key in keys:
                    local_titration_data[key]={}

                line=fd.readline()
                while line.find('END')==-1 and len(line)>2:
                    sp=line.split(split_char)
                    pH=float(sp[0])

                    count=1
                    for key in keys:
                        try:
                            local_titration_data[key][pH]=float(sp[count])
                        except:
                            print 'Could not load data point for',key,'at pH',pH
                        count=count+1
                    #
                    # Read the next line
                    #
                    line=fd.readline()
                fd.close()

                self.convert_titration_data(local_titration_data, acid_bases=acid_bases)

            else:
                import tkMessageBox
                tkMessageBox.showwarning('File does not exist',
                                         'Could not find %s.' %filename)
        return
Read titration curves from a text file
Read titration curves from a text file
Read titration curves from a text file
def load_curves(self, filename = '', acid_bases = None):
        import tkFileDialog, os
        savedir=os.getcwd()
        if filename == '':
            filename=tkFileDialog.askopenfilename(defaultextension="*.tcrv",
                                                  initialdir=savedir,
                                                  filetypes=[("pKaTool titration curve file","*.tcrv"),
                                                             ("Text file","*.txt"),
                                                             ("CSV file",".csv"),
                                                             ("All files","*.*")])
        if filename:
            if os.path.isfile(filename):
                 Get the type
                if filename[-4:]=='.csv':
                    filetype='csv'
                    split_char=','
                else:
                    filetype='spacesep'
                    split_char=None
                 Read the file
                fd=open(filename)
                local_titration_data={}
                header=fd.readline()
                header=header.split(split_char)
                exp_groups=header[1:]
                 store experimental data in local_titration_data
                keys = exp_groups
                for key in keys:
                    local_titration_data[key]={}
                line=fd.readline()
                while line.find('END')==-1 and len(line)>2:
                    sp=line.split(split_char)
                    pH=float(sp[0])
                    count=1
                    for key in keys:
                        try:
                            local_titration_data[key][pH]=float(sp[count])
                        except:
                            print 'Could not load data point for',key,'at pH',pH
                        count=count+1
                     Read the next line
                    line=fd.readline()
                fd.close()
                self.convert_titration_data(local_titration_data, acid_bases=acid_bases)
            else:
                import tkMessageBox
                tkMessageBox.showwarning('File does not exist',
                                         'Could not find %s.' %filename)
        return
def load_curves ( self , filename = '' , acid_bases = None ) : import tkFileDialog , os savedir = os . getcwd ( ) if filename == '' : filename = tkFileDialog . askopenfilename ( defaultextension = "*.tcrv" , initialdir = savedir , filetypes = [ ( "pKaTool titration curve file" , "*.tcrv" ) , ( "Text file" , "*.txt" ) , ( "CSV file" , ".csv" ) , ( "All files" , "*.*" ) ] ) if filename : if os . path . isfile ( filename ) : if filename [ - 4 : ] == '.csv' : filetype = 'csv' split_char = ',' else : filetype = 'spacesep' split_char = None fd = open ( filename ) local_titration_data = { } header = fd . readline ( ) header = header . split ( split_char ) exp_groups = header [ 1 : ] keys = exp_groups for key in keys : local_titration_data [ key ] = { } line = fd . readline ( ) while line . find ( 'END' ) == - 1 and len ( line ) > 2 : sp = line . split ( split_char ) pH = float ( sp [ 0 ] ) count = 1 for key in keys : try : local_titration_data [ key ] [ pH ] = float ( sp [ count ] ) except : print 'Could not load data point for' , key , 'at pH' , pH count = count + 1 line = fd . readline ( ) fd . close ( ) self . convert_titration_data ( local_titration_data , acid_bases = acid_bases ) else : import tkMessageBox tkMessageBox . showwarning ( 'File does not exist' , 'Could not find %s.' % filename ) return
Read titration curves from a text file
Read titration curves from a text file
"""Read titration curves from a text file""" # # Get the type # # # Read the file # # # store experimental data in local_titration_data # # # Read the next line #
self
filename
acid_bases