示例#1
0
    def _compute_pools(self, plate_info):
        super()._compute_pools(plate_info)

        self.params['total_each'] = False
        self.params['vol_constant'] = 10 ** 9
        pool_vals = self.function(self.raw_concs, **self.params)

        # if adjust blank volume, do that
        if self.params['blank_vol'] != '':
            bv = self.params['blank_vol']
            pool_vals = PoolingProcess.adjust_blank_vols(pool_vals,
                                                         self.comp_blanks,
                                                         bv)

        # if only pool some blanks, do that
        if self.params['blank_num'] != '':
            bn = int(self.params['blank_num'])
            pool_vals = PoolingProcess.select_blanks(pool_vals,
                                                     self.raw_concs,
                                                     self.comp_blanks,
                                                     bn)

        # estimate pool volume and concentration
        cs = self.comp_concs
        total_c, total_v = PoolingProcess.estimate_pool_conc_vol(pool_vals, cs)

        # store output values
        output = {}
        output['func_data'] = {'function': self.func_name,
                               'parameters': self.params}
        output['raw_vals'] = self.raw_concs
        output['comp_vals'] = self.comp_concs
        output['pool_vals'] = pool_vals
        output['pool_blanks'] = self.comp_blanks.tolist()
        output['plate_names'] = self.plate_names.tolist()
        output['plate_id'] = self.plate_id
        output['destination'] = self.params['destination']
        output['robot'] = self.params['robot']
        output['blank_vol'] = self.params['blank_vol']
        output['blank_num'] = self.params['blank_num']
        output['total_conc'] = total_c
        output['total_vol'] = total_v
        output['quant-process-id'] = self.quant_process_id

        return output
示例#2
0
    def _compute_pools(self, plate_info):
        super()._compute_pools(plate_info)

        # pool_vals looks like its needed in the output
        pool_vals = self.function(self.raw_concs, **self.params)

        # if adjust blank volume, do that
        if self.params['blank_vol'] != '':
            pool_vals = PoolingProcess.adjust_blank_vols(
                pool_vals, self.comp_blanks, self.params['blank_vol'])

        # if only pool some blanks, do that
        if self.params['blank_num'] != '':
            pool_vals = PoolingProcess.select_blanks(
                pool_vals, self.raw_concs, self.comp_blanks,
                int(self.params['blank_num']))

        # estimate pool volume and concentration
        total_c, total_v = PoolingProcess.estimate_pool_conc_vol(
            pool_vals, self.comp_concs)

        # store output values
        output = {}
        output['pool_vals'] = pool_vals
        output['pool_blanks'] = self.comp_blanks.tolist()
        output['plate_names'] = self.plate_names.tolist()
        output['plate_id'] = self.plate_id
        output['destination'] = self.params['destination']
        output['robot'] = self.params['robot']
        output['blank_vol'] = self.params['blank_vol']
        output['blank_num'] = self.params['blank_num']
        output['total_conc'] = total_c
        output['total_vol'] = total_v
        output['quant-process-id'] = self.quant_process_id

        return output
    def _compute_pools(self, plate_info):
        plate_id = plate_info['plate-id']
        func_name = plate_info['pool-func']
        plate_type = plate_info['plate-type']
        quant_process_id = plate_info['quant-process-id']
        func_info = POOL_FUNCS[func_name]
        function = func_info['function']

        plate = Plate(plate_id)
        quant_process = QuantificationProcess(quant_process_id)

        # make params dictionary for function
        params = {}
        for arg, pfx in func_info['parameters']:
            param_key = '%s%s' % (pfx, plate_id)
            if param_key not in plate_info:
                raise HTTPError(
                    400, reason='Missing parameter %s' % param_key)
            # empty strings are sent when we have disabled inputs.
            # we are testing for them explicitly where expected.
            if plate_info[param_key] != '':
                params[arg] = float(plate_info[param_key])
            else:
                params[arg] = plate_info[param_key]

        # compute molar concentrations
        quant_process.compute_concentrations(size=params['size'])

        # calculate pooled values
        raw_concs, comp_concs, comp_blanks, \
        plate_names = make_2D_arrays(plate, quant_process)

        # for 16S, we calculate each sample independently
        pool_type = PLATE_TYPE_TO_POOL_TYPE[plate_type]
        params['total_each'] = POOL_TYPE_PARAMS[pool_type]['total_each']
        params['vol_constant'] = POOL_TYPE_PARAMS[pool_type]['vol_constant']
        pool_vals = function(raw_concs, **params)

        # if adjust blank volume, do that
        if params['blank_vol'] != '':
            pool_vals = PoolingProcess.adjust_blank_vols(pool_vals,
                                                         comp_blanks,
                                                         params['blank_vol'])

        # if only pool some blanks, do that
        if params['blank_num'] != '':
            pool_vals = PoolingProcess.select_blanks(pool_vals,
                                                     raw_concs,
                                                     comp_blanks,
                                                     int(params['blank_num']))

        # estimate pool volume and concentration
        total_c, total_v = PoolingProcess.estimate_pool_conc_vol(pool_vals,
                                                                 comp_concs)

        # store output values
        output = {}
        output['func_data'] = {'function': func_name,
                               'parameters': params}
        output['raw_vals'] = raw_concs
        output['comp_vals'] = comp_concs
        output['pool_vals'] = pool_vals
        output['pool_blanks'] = comp_blanks.tolist()
        output['plate_names'] = plate_names.tolist()
        output['plate_id'] = plate_id
        output['destination'] = params['destination']
        output['robot'] = params['robot']
        output['blank_vol'] = params['blank_vol']
        output['blank_num'] = params['blank_num']
        output['total_conc'] = total_c
        output['total_vol'] = total_v
        output['quant-process-id'] = quant_process_id

        return output