def post(self): # We will receive as many files as plates the user has selected # The key of the self.request.files dictionary is of the form # plate-file-<PLATE_ID> so use the keys to know the plates # that we need to quantify plates = [] for key in self.request.files: plate_id = key.rsplit('-', 1)[1] # The 0 is because for each key we have a single file file_content = self.request.files[key][0]['body'].decode('utf-8') plate = Plate(plate_id) pc = plate.plate_configuration concentrations = QuantificationProcess.parse(file_content, rows=pc.num_rows, cols=pc.num_columns) names = np.empty_like(plate.layout, dtype='object') blanks = np.zeros_like(plate.layout, dtype=bool) # fetch the sample names and whether or not the samples are blanks # by default these are set to be None and False. for i, full_row in enumerate(plate.layout): for j, well in enumerate(full_row): # some wells have no compositions at all so skip those if well is None: continue comp = well.composition # cache the sample compositions to avoid extra intermediate # queries if isinstance(comp, GDNAComposition): smp = comp.sample_composition elif isinstance(comp, (CompressedGDNAComposition, LibraryPrep16SComposition)): smp = comp.gdna_composition.sample_composition elif isinstance(comp, LibraryPrepShotgunComposition): smp = comp.normalized_gdna_composition\ .compressed_gdna_composition.gdna_composition\ .sample_composition else: raise ValueError('This composition type is not ' 'supported') blanks[i][j] = smp.sample_composition_type == 'blank' names[i][j] = smp.sample_id plates.append({ 'plate_name': plate.external_id, 'plate_id': plate_id, 'concentrations': concentrations.tolist(), 'names': names.tolist(), 'blanks': blanks.tolist(), 'type': plate.process._process_type }) self.render('quantification.html', plates=plates)
def post(self): plate_id = self.get_argument('plate-select') # Magic number 0 -> there is only 1 file attached file_content = self.request.files['plate-reader-fp'][0]['body'].decode( 'utf-8') concentrations = QuantificationProcess.parse(file_content) plate = Plate(plate_id) self.render('quantification.html', concentrations=concentrations.tolist(), plate_name=plate.external_id, plate_id=plate.id, plate_conf=plate.plate_configuration.description)
def post(self): # We will receive as many files as plates the user has selected # The key of the self.request.files dictionary is of the form # plate-file-<PLATE_ID> so use the keys to know the plates # that we need to quantify plates = [] for key in self.request.files: plate_id = key.rsplit('-', 1)[1] # The 0 is because for each key we have a single file file_content = self.request.files[key][0]['body'].decode('utf-8') plate = Plate(plate_id) pc = plate.plate_configuration concentrations = QuantificationProcess.parse( file_content, rows=pc.num_rows, cols=pc.num_columns) plates.append({'plate_name': plate.external_id, 'plate_id': plate_id, 'concentrations': concentrations.tolist()}) self.render('quantification.html', plates=plates)