PEATDB/DNAtool/primer_database.py
def save_to_text(self,filename=None,separator=',',nodesc=None):
        """Save the primers to a csv text file. Same format as dump file"""
        import tkFileDialog, os
        savedir=os.getcwd()
        if filename==None:
            filename=tkFileDialog.asksaveasfilename(defaultextension='.pdb.csv',
                                                    initialdir=savedir,
                                                    filetypes=[("Text files","*.csv"),("All files","*.*")])

        if not filename:
            return

        # Write the file
        primers=self.parent.data['primer_dict'].copy()
        fd=open(filename,'wb')

        #this code reused from the dumper class, some duplication
        if nodesc==None:
            HeaderList = ['description', 'sequence']
        else:
            HeaderList = ['sequence']
        #ActualHeaderList = ['name','description', 'sequence']
        DumpPDB = []
        #DumpPDB.append(ActualHeaderList)
        for entry in primers:
            tmp = []
            tmp.append(entry)
            for head in HeaderList:
                tmp.append(primers[entry][head])
            DumpPDB.append(tmp)
        result = DumpPDB

        DFILE = filename
        try:
            fd=open(DFILE,'w')
            for line in result:
                str = ''
                for S in line:
                    str = str+S+separator
                fd.write(str+'\n')
            fd.close()
            print "File written ",DFILE
        except:
            print "error: could not write file ",DFILE

        fd.close()
        return
Save the primers to a csv text file. Same format as dump file
Save the primers to a csv text file. Same format as dump file
Save the primers to a csv text file . Same format as dump file
def save_to_text(self,filename=None,separator=',',nodesc=None):
        import tkFileDialog, os
        savedir=os.getcwd()
        if filename==None:
            filename=tkFileDialog.asksaveasfilename(defaultextension='.pdb.csv',
                                                    initialdir=savedir,
                                                    filetypes=[("Text files","*.csv"),("All files","*.*")])
        if not filename:
            return
        primers=self.parent.data['primer_dict'].copy()
        fd=open(filename,'wb')
        if nodesc==None:
            HeaderList = ['description', 'sequence']
        else:
            HeaderList = ['sequence']
        DumpPDB = []
        for entry in primers:
            tmp = []
            tmp.append(entry)
            for head in HeaderList:
                tmp.append(primers[entry][head])
            DumpPDB.append(tmp)
        result = DumpPDB
        DFILE = filename
        try:
            fd=open(DFILE,'w')
            for line in result:
                str = ''
                for S in line:
                    str = str+S+separator
                fd.write(str+'\n')
            fd.close()
            print "File written ",DFILE
        except:
            print "error: could not write file ",DFILE
        fd.close()
        return
def save_to_text ( self , filename = None , separator = ',' , nodesc = None ) : import tkFileDialog , os savedir = os . getcwd ( ) if filename == None : filename = tkFileDialog . asksaveasfilename ( defaultextension = '.pdb.csv' , initialdir = savedir , filetypes = [ ( "Text files" , "*.csv" ) , ( "All files" , "*.*" ) ] ) if not filename : return primers = self . parent . data [ 'primer_dict' ] . copy ( ) fd = open ( filename , 'wb' ) if nodesc == None : HeaderList = [ 'description' , 'sequence' ] else : HeaderList = [ 'sequence' ] DumpPDB = [ ] for entry in primers : tmp = [ ] tmp . append ( entry ) for head in HeaderList : tmp . append ( primers [ entry ] [ head ] ) DumpPDB . append ( tmp ) result = DumpPDB DFILE = filename try : fd = open ( DFILE , 'w' ) for line in result : str = '' for S in line : str = str + S + separator fd . write ( str + '\n' ) fd . close ( ) print "File written " , DFILE except : print "error: could not write file " , DFILE fd . close ( ) return
Save the primers to a csv text file.
Save the primers to a csv text file .
"""Save the primers to a csv text file. Same format as dump file""" # Write the file #this code reused from the dumper class, some duplication #ActualHeaderList = ['name','description', 'sequence'] #DumpPDB.append(ActualHeaderList)
self
filename
separator
nodesc