Esempio n. 1
0
    dataset = DataSet(**metadata)
    logger.info('dataset to save %s' % dataset)
    dataset.save()

    logger.debug('read data columns...')
    col_to_definitions = read_datacolumns(book)

    small_molecule_col = None
    col_to_dc_map = {}
    for i, dc_definition in enumerate(col_to_definitions):
        dc_definition['dataset'] = dataset
        if (not 'display_order' in dc_definition
                or dc_definition['display_order'] == None):
            dc_definition['display_order'] = i
        datacolumn = DataColumn(**dc_definition)
        datacolumn.save()
        if not small_molecule_col and datacolumn.data_type == 'small_molecule':
            small_molecule_col = datacolumn
        logger.debug('datacolumn created: %r' % datacolumn)
        if datacolumn.worksheet_column:
            col_to_dc_map[int_for_col(
                datacolumn.worksheet_column)] = datacolumn
    logger.debug('final data columns: %s' % col_to_dc_map)

    logger.debug('read the Data sheet')
    data_sheet = book.sheet_by_name('Data')

    for i, label in enumerate(data_sheet.row_values(0)):
        logger.debug('find datasheet label %r:%r' % (colname(i), label))
        if label in meta_columns:
            meta_columns[label] = i
Esempio n. 2
0
        raise e
    
    # Read in the data columns sheet to an array of dict's, 
    # each dict defines a DataColumn.    
    logger.debug('read data columns...')
    dataColumnDefinitions = readDataColumns(path)
    
    # Now that the array of DataColumn dicts is created, 
    # use them to create the DataColumn instances.
    dataColumns = {}
    for i,dc in enumerate(dataColumnDefinitions):
        dc['dataset'] = dataset
        if(not 'display_order' in dc or dc['display_order']==None): 
            dc['display_order']=i
        dataColumn = DataColumn(**dc)
        dataColumn.save()
        logger.debug(str(('====datacolumn created:', dataColumn)))
        dataColumns[dataColumn.name] = dataColumn    

    logger.debug('read the Data sheet')
    sheetname = 'Data'
    dataSheet = iu.readtable([path, sheetname])
    
    # First, map the sheet column indices to the DataColumns that were created.
    dataColumnList = {}
    # Follows are optional columns
    # Meta columns contain forensic information, all are optional
    metaColumnDict = {'Control Type':-1, 'batch_id':-1} 
    # What is being studied - at least one is required
    mappingColumnDict = {
        'Small Molecule Batch':-1, 'Plate':-1, 'Well':-1, 
Esempio n. 3
0
    if not small_mol_col:
        dc_definitions_found.append(default_reagent_columns['Small Molecule Batch'])
        
    logger.info('data column definitions found: %s' 
        % [x['display_name'] for x in dc_definitions_found])

    
    col_to_dc_map = {}
    first_small_molecule_column = None
    for i,dc_definition in enumerate(dc_definitions_found):
        dc_definition['dataset'] = dataset
        if (not 'display_order' in dc_definition 
                or dc_definition['display_order']==None): 
            dc_definition['display_order']=i
        datacolumn = DataColumn(**dc_definition)
        datacolumn.save()
        if not first_small_molecule_column and datacolumn.data_type == 'small_molecule':
            first_small_molecule_column = datacolumn
        logger.debug('datacolumn created: %r' % datacolumn)
        if datacolumn.worksheet_column:
            col_to_dc_map[int_for_col(datacolumn.worksheet_column)] = datacolumn    
    logger.debug('final data columns: %s' % col_to_dc_map)

    read_data(book, col_to_dc_map, first_small_molecule_column, dataset)

def read_explicit_reagents(book, dataset):
    
    try:
        reagents_sheet = book.sheet_by_name('Reagents')
        for row in range(1,reagents_sheet.nrows):
            facility_batch_id = read_string(reagents_sheet.cell(row,0))