Esempio n. 1
0
def cleanOptions(options):
    options['dialogs'] = 'dialogs' in options
    options['p'] = F.absfile(options.get('p', ''))

    if options['dialogs']:

        if not 'i' in options:
            options['i'] = D.askForFile(defaultextension='*.xls',
                                        filetypes=(('Excel classic', '*.xls'),
                                                   ('Excel', '*.xlsx'),
                                                   ('All files', '*.*')),
                                        initialdir=options['p'],
                                        multiple=False,
                                        title="Definition of Target Reactions")

        if not 'src' in options:
            options['src'] = D.askForFile(
                defaultextension='*.xls',
                filetypes=(('Excel classic', '*.xls'), ('Excel', '*.xlsx'),
                           ('All files', '*.*')),
                initialdir=options['p'],
                multiple=True,
                title="Source fragments and their locations")

        if not 'o' in options:
            options['o'] = D.askForFile(defaultextension='*.gwl',
                                        filetypes=(('Evo Worklist', '*.gwl'),
                                                   ('Text file', '*.txt'),
                                                   ('All files', '*.*')),
                                        initialdir=options['p'],
                                        multiple=False,
                                        newfile=True,
                                        title="Save Worklist output file as")

    options['i'] = F.absfile(options['i'])
    options['src'] = [F.absfile(f) for f in U.tolist(options['src'])]
    options['o'] = F.absfile(options['o'])

    options['useLabel'] = 'useLabel' in options
    ##    options['srcplate'] = [s.strip() for s in U.tolist(options.get('srcplate',[]))]
    return options
Esempio n. 2
0
 def __init__(self, fname, reportErrors=True):
     """
     Worklist constructor.
         >>> wl = Worklist('outputfile.gwl')
         
     Args:
         fname (str): file name for output worklist (will be created)
         reportErrors (bool): report exceptions via dialog box to user [True]
     """
     self.fname = F.absfile(fname)
     self._f = None  ## file handle
     self.reportErrors = reportErrors
Esempio n. 3
0
def cleanOptions(options):
    options['dialogs'] = 'dialogs' in options
    cwd = options.get('p', None)

    if options['dialogs']:

        if not 'i' in options:
            options['i'] = D.askForFile(defaultextension='*.xls',
                                        filetypes=(('Excel classic', '*.xls'),
                                                   ('Excel', '*.xlsx'),
                                                   ('All files', '*.*')),
                                        initialdir=cwd,
                                        multiple=False,
                                        title="Cherrypicking Table")

        if not 'src' in options:
            options['src'] = D.askForFile(
                defaultextension='*.xls',
                filetypes=(('Excel classic', '*.xls'), ('Excel', '*.xlsx'),
                           ('All files', '*.*')),
                initialdir=cwd,
                multiple=True,
                title="Source samples and their locations")

        if not 'o' in options:
            options['o'] = D.askForFile(defaultextension='*.gwl',
                                        filetypes=(('Evo Worklist', '*.gwl'),
                                                   ('Text file', '*.txt'),
                                                   ('All files', '*.*')),
                                        initialdir=cwd,
                                        multiple=False,
                                        newfile=True,
                                        title="Save Worklist output file as")

    options['i'] = F.existingFile(
        options['i'],
        cwd=cwd,
        errmsg='Cannot find cherrypicking input (-i) file.')

    options['src'] = U.tolist(options['src'])
    msg = 'Cannot find source (-src) file '
    options['src'] = [
        F.existingFile(f, cwd=cwd, errmsg=msg) for f in options['src']
    ]

    options['o'] = F.absfile(options['o'], cwd=cwd)

    options['columns'] = U.tolist(options.get('columns', []))

    options['useLabel'] = 'barcode' not in options
    return options
Esempio n. 4
0
    def generictest(self, options):
        import evoware.fileutil as F
        import os.path as O

        self.f_out = F.absfile(self.f_project + '/' + options['o'])

        run(options)

        self.assertTrue(O.exists(self.f_out))

        with open(self.f_out,'r') as f1, \
             open(F.testRoot('results/distribute.gwl'),'r') as f2:

            self.assertEqual(f1.readlines(), f2.readlines())
Esempio n. 5
0
def cleanOptions( options ):
    options['dialogs'] = 'dialogs' in options
    options['p'] = F.absfile( options.get('p', ''))
    
    if options['dialogs']:
        
        if not 'i' in options:
            options['i'] = D.askForFile(defaultextension='*.xls', 
                            filetypes=(('Excel classic','*.xls'),('Excel','*.xlsx'),('All files','*.*')), 
                            initialdir=options['p'], 
                            multiple=False, 
                            title="Definition of Target Reactions")
        
        if not 'src' in options:
            options['src'] = D.askForFile(defaultextension='*.xls', 
                            filetypes=(('Excel classic','*.xls'),('Excel','*.xlsx'),('All files','*.*')), 
                            initialdir=options['p'], 
                            multiple=True, 
                            title="Source templates and primers and their locations")
        
        if not 'o' in options:
            options['o'] = D.askForFile(defaultextension='*.gwl', 
                            filetypes=(('Evo Worklist','*.gwl'),('Text file','*.txt'),('All files','*.*')), 
                            initialdir=options['p'], 
                            multiple=False,
                            newfile=True,
                            title="Save Worklist output file as")
    
    
    options['i'] = F.absfile(options['i'])
    options['src'] = [ F.absfile(f) for f in U.tolist(options['src']) ]
    options['o'] = F.absfile(options['o'])
    
    options['useLabel'] = 'useLabel' in options
##    options['srcplate'] = [s.strip() for s in U.tolist(options.get('srcplate',[]))]
    return options
Esempio n. 6
0
    def read(self, fname):
        """
        Append data from given Excel file to internal list of rows and
        dictionary of parameters.
        
        Args:
            fname (str) excel file name including path
        
        Raises:
            IOError: if file cannot be found (presumably)
            `ExcelFormatError`: if header row cannot be found or interpreted
        """
        book = X.open_workbook(F.absfile(fname))
        sheet = book.sheets()[0]

        try:
            row = 0
            values = []
            ## iterate until there is a row starting with HEADER_FIRST_VALUE
            ## capture any "param, <key>, <value>" entries until then
            while not self.detectHeader(values):
                values = [v for v in sheet.row_values(row) if v]
                self.parsePreHeader(values)
                row += 1

            ## parse table "header"
            keys = self.parseHeader(values)

            i = 0
            for row in range(row, sheet.nrows):
                values = sheet.row_values(row)

                ## ignore rows with empty first column
                if values[0]:
                    d = dict(zip(keys, values))
                    self.cleanEntry(d)
                    self.addEntry(d)
                    i += 1

            return i

        except ExcelFormatError as why:
            raise ExcelFormatError(
                'Invalid Excel file (could not find header).')