def cluster_csv(self, id=None, show_only_gated=True, *args, **kwargs): from pyqlb.nstats.well import accepted_peaks qlwell = self.__qlwell_from_threshold_form(id) if show_only_gated != 'False': peaks = accepted_peaks(qlwell) else: peaks = qlwell.peaks from pyqlb.nstats.peaks import fam_amplitudes, fam_widths, vic_amplitudes, vic_widths, peak_times from pyqlb.nstats.well import well_observed_cluster_assignments response.headers['Content-Type'] = 'text/csv' h.set_download_response_header(request, response, "%s_%s%s.csv" % \ (str(c.well.plate.plate.name), str(c.well.well_name), '' if show_only_gated != 'False' else '_all')) out = StringIO.StringIO() csvwriter = csv_pkg.writer(out) csvwriter.writerow(['Plate',c.well.plate.plate.name]) csvwriter.writerow(['Well',c.well.well_name]) csvwriter.writerow([]) csvwriter.writerow(['Time','FAMAmplitude','FAMWidth','VICAmplitude','VICWidth','Cluster']) csvwriter.writerow([]) pts = peak_times(peaks) fas = fam_amplitudes(peaks) fws = fam_widths(peaks) vas = vic_amplitudes(peaks) vws = vic_widths(peaks) cls = well_observed_cluster_assignments(qlwell, peaks) for row in zip(pts, fas, fws, vas, vws, cls): csvwriter.writerow(row) csv = out.getvalue() out.close() return csv
def peak_csv(self, id=None, show_only_gated=True, *args, **kwargs): from qtools.lib.nstats.peaks import accepted_peaks qlwell = self.__qlwell_from_threshold_form(id) if show_only_gated != 'False': peaks = accepted_peaks(qlwell) else: peaks = qlwell.peaks from pyqlb.nstats.peaks import fam_amplitudes, fam_widths, fam_quality, vic_amplitudes, vic_widths, vic_quality, peak_times response.headers['Content-Type'] = 'text/csv' h.set_download_response_header(request, response, "%s_%s%s.csv" % \ (str(c.well.plate.plate.name), str(c.well.well_name), '' if show_only_gated != 'False' else '_all')) out = StringIO.StringIO() csvwriter = csv_pkg.writer(out) csvwriter.writerow(['Plate',c.well.plate.plate.name]) csvwriter.writerow(['Well',c.well.well_name]) csvwriter.writerow([]) csvwriter.writerow(['FAMThreshold',qlwell.channels[0].statistics.threshold]) csvwriter.writerow(['VICThreshold',qlwell.channels[1].statistics.threshold]) csvwriter.writerow(['WidthGate',qlwell.channels[0].statistics.min_width_gate,qlwell.channels[0].statistics.max_width_gate]) csvwriter.writerow(['MinQualityGate',qlwell.channels[0].statistics.min_quality_gate]) csvwriter.writerow([]) csvwriter.writerow(['Time','FAMAmplitude','FAMWidth','FAMQuality','VICAmplitude','VICWidth','VICQuality']) csvwriter.writerow([]) pts = peak_times(peaks) fas = fam_amplitudes(peaks) fws = fam_widths(peaks) fqs = fam_quality(peaks) vas = vic_amplitudes(peaks) vws = vic_widths(peaks) vqs = vic_quality(peaks) for row in zip(pts, fas, fws, fqs, vas, vws, vqs): csvwriter.writerow(row) csv = out.getvalue() out.close() return csv