def __call__(self, context): brains = find(IProvider.__identifer__) values = [b.getObject() for b in brains] names = [" ".join([str(v.site_ID), v.first_name, v.last_name]) for v in values] items = [(n, normalize(n)) for n in names] return SimpleVocabulary.fromItems(items)
def __call__(self, context): wells = ["-A", "-B", "-C", "-D", "-E", "-F", "-H"] values = find(portal_type='iChip') ichips = [v.Title for v in values] unique_ichip_wells = [] for o in ichips: for w in wells: well_location = o + w unique_ichip_wells.append(well_location) items = [(i, normalize(i)) for i in unique_ichip_wells] return SimpleVocabulary.fromItems(items)
def __call__(self, context): values = get_registry_record('immunarray.category_primary') items = [(i, normalize(i)) for i in values] return SimpleVocabulary.fromItems(items)
def __call__(self): wb = self.load_workbook() ws = wb.get_sheet_by_name('Form') # A6 - add run number to 'FILE NAME' ws['A6'].value += ' (Veracis Test Run %s)' % self.context.run_number # A7 - PURPOSE ws['A7'].value += ' %s' % self.context.assay_name # A8 - DATE ws['A8'].value += ' %s' % self.context.run_date # D8 - PLANNED BY ws['D8'].value += ' %s' % self.context.run_planner # H8 - PERFORMED BY ws['H8'].value += ' %s' % self.context.run_operator # PLATE HEADERS are at 10, 27, 44, 61, 78 for plate_nr, plate_cell in enumerate([10, 27, 44, 61, 78]): plate_nr += 1 # verify plate header exists in spreadsheet plate_title = 'plate %s' % plate_nr plate_header_cell = ws['A%s' % plate_cell] assert plate_header_cell.value.lower() == plate_title # verify the plate exists in run.plates if len(self.context.plates) < plate_nr: break plate = self.context.plates[plate_nr - 1] # ALIQUOT WELL ROWS are PLATE HEADER+[2..9] in COLS B,D,F,H for chip_nr, chip_col in enumerate('BDFH'): for well_nr in range(8): uid = plate['chip-%s_well-%s' % (chip_nr + 1, well_nr + 1)] if uid: brain = find(UID=uid)[0] row = plate_cell + (well_nr + 2) cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # +1 for ICHIP in rows C,E,G,I - and "COMMENTS" in J row = plate_cell + 10 for chip_nr, chip_col in enumerate('CEGI'): uid = plate['chip-id-%s' % (chip_nr + 1)] if not uid: raise MissingIChipForSlide( "plate %s, slide %s" % (plate_nr, chip_nr + 1)) brain = find(UID=uid)[0] cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # comments in J cell = ws['J%s' % row] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] # +1 for ICHIP in rows C,E,G,I - and "COMMENTS" in J row = plate_cell + 10 for chip_nr, chip_col in enumerate('CEGI'): uid = plate['chip-id-%s' % (chip_nr + 1)] if not uid: raise MissingIChipForSlide( "plate %s, slide %s" % (plate_nr, chip_nr + 1)) brain = find(UID=uid)[0] cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # comments in J cell = ws['J%s' % row] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] # +1 for SCAN SLOT C,E,G,I row = plate_cell + 11 for chip_nr, slot_col in enumerate('CEGI'): cell = ws['%s%s' % (slot_col, row)] cell.value = plate['scan-slot-%s' % (chip_nr + 1)] # +2 for COMMENTS in B,D,F,H row = plate_cell + 13 for chip_nr, comment_col in enumerate('CEGI'): cell = ws['%s%s' % (comment_col, row)] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] fn = "{}-{}".format(self.context.assay_name, self.context.run_number) fn = normalize(fn) + ".xlsx" setheader = self.request.RESPONSE.setHeader setheader('Content-Type', 'application/vnd.ms-excel') setheader("Content-Disposition", 'attachment;filename="%s"' % fn) fn = tempfile.mktemp() wb.save(fn) data = open(fn).read() self.request.RESPONSE.write(data)
def __call__(self): wb = self.load_workbook() ws = wb.get_sheet_by_name('Form') # A6 - add run number to 'FILE NAME' ws['A6'].value += ' (Veracis Test Run %s)' % self.context.run_number # A7 - PURPOSE ws['A7'].value += ' %s' % self.context.assay_name # A8 - DATE ws['A8'].value += ' %s' % self.context.run_date # D8 - PLANNED BY ws['D8'].value += ' %s' % self.context.run_planner # H8 - PERFORMED BY ws['H8'].value += ' %s' % self.context.run_operator # PLATE HEADERS are at 10, 27, 44, 61, 78 for plate_nr, plate_cell in enumerate([10, 27, 44, 61, 78]): plate_nr += 1 # verify plate header exists in spreadsheet plate_title = 'plate %s' % plate_nr plate_header_cell = ws['A%s' % plate_cell] assert plate_header_cell.value.lower() == plate_title # verify the plate exists in run.plates if len(self.context.plates) < plate_nr: break plate = self.context.plates[plate_nr - 1] # ALIQUOT WELL ROWS are PLATE HEADER+[2..9] in COLS B,D,F,H for chip_nr, chip_col in enumerate('BDFH'): for well_nr in range(8): uid = plate['chip-%s_well-%s' % (chip_nr + 1, well_nr + 1)] if uid: brain = find(UID=uid)[0] row = plate_cell + (well_nr + 2) cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # +1 for ICHIP in rows C,E,G,I - and "COMMENTS" in J row = plate_cell + 10 for chip_nr, chip_col in enumerate('CEGI'): uid = plate['chip-id-%s' % (chip_nr + 1)] if not uid: raise MissingIChipForSlide("plate %s, slide %s" % (plate_nr, chip_nr + 1)) brain = find(UID=uid)[0] cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # comments in J cell = ws['J%s' % row] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] # +1 for ICHIP in rows C,E,G,I - and "COMMENTS" in J row = plate_cell + 10 for chip_nr, chip_col in enumerate('CEGI'): uid = plate['chip-id-%s' % (chip_nr + 1)] if not uid: raise MissingIChipForSlide("plate %s, slide %s" % (plate_nr, chip_nr + 1)) brain = find(UID=uid)[0] cell = ws['%s%s' % (chip_col, row)] cell.value = brain.Title # comments in J cell = ws['J%s' % row] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] # +1 for SCAN SLOT C,E,G,I row = plate_cell + 11 for chip_nr, slot_col in enumerate('CEGI'): cell = ws['%s%s' % (slot_col, row)] cell.value = plate['scan-slot-%s' % (chip_nr + 1)] # +2 for COMMENTS in B,D,F,H row = plate_cell + 13 for chip_nr, comment_col in enumerate('CEGI'): cell = ws['%s%s' % (comment_col, row)] cell.value = plate['comments-ichip-%s' % (chip_nr + 1)] fn = "{}-{}".format(self.context.assay_name, self.context.run_number) fn = normalize(fn) + ".xlsx" setheader = self.request.RESPONSE.setHeader setheader('Content-Type', 'application/vnd.ms-excel') setheader("Content-Disposition", 'attachment;filename="%s"' % fn) fn = tempfile.mktemp() wb.save(fn) data = open(fn).read() self.request.RESPONSE.write(data)
def __call__(self, context): catalog = getToolByName(context, 'portal_catalog') values = catalog(portal_type='iChip') names = [([v.id]) for v in values] items = [(n, normalize(n)) for n in names] return SimpleVocabulary.fromItems(items)
def __call__(self): fieldnames = [ 'iChipLot', 'Slide_ID', 'Well_ID', 'Plate', 'TestSession', 'SampleID', 'Analyze', 'Run_Number', 'SampleClass', 'Aliqout_ID'] io = StringIO() writer = csv.DictWriter(io, fieldnames=fieldnames) writer.writerow(dict(zip(fieldnames, fieldnames))) for plate_nr, plate in enumerate(self.context.plates): plate_nr += 1 for chip_nr in range(1, 5): # get chip for this slide uid = plate['chip-id-%s' % chip_nr] if not uid: raise MissingIChipForSlide( "plate %s, slide %s" % (plate_nr, chip_nr)) chip = find(UID=uid)[0].getObject() for well_nr in range(1, 9): uid = plate['chip-%s_well-%s' % (chip_nr, well_nr)] if uid: aliquot = find(UID=uid)[0].getObject() sample = self.get_parent_sample_from_aliquot(aliquot) if IClinicalAliquot.providedBy(aliquot): SampleClass = '1' Aliquot_ID = aliquot.title SampleID = '-'.join( aliquot.title.split('-')[:2]) Analyze = '1' elif self.is_hqc(sample): SampleClass = '3' Aliquot_ID = aliquot.title SampleID = sample.source_id_one Analyze = '1' elif self.is_lqc(sample): SampleClass = '5' Aliquot_ID = aliquot.title SampleID = sample.source_id_one Analyze = '1' else: raise InvalidSample("Aliquot %s" % aliquot.title) else: SampleClass = '1' Aliquot_ID = 'Blank' SampleID = 'Blank' Analyze = '0' # noinspection PyUnboundLocalVariable writer.writerow({ 'iChipLot': chip.title.split("_")[0], 'Slide_ID': chip.title.split("_")[1], 'Well_ID': str(well_nr), 'Plate': str(plate_nr), 'TestSession': '1', 'SampleID': SampleID, 'Analyze': Analyze, 'Run_Number': self.context.run_number, 'SampleClass': SampleClass, 'Aliqout_ID': Aliquot_ID, }) fn = "{}-{}".format(self.context.assay_name, self.context.run_number) fn = normalize(fn) + ".csv" setheader = self.request.RESPONSE.setHeader setheader('Content-Type', 'text/csv') setheader("Content-Disposition", 'attachment;filename="%s"' % fn) self.request.RESPONSE.write(io.getvalue())