Example #1
0
    def Run(self):

        self.transit_message("Starting TnseqStats")
        start_time = time.time()

        datasets = self.wigs
        if self.combined_wig == None:
            (data, sites) = tnseq_tools.get_data(self.wigs)
        else:
            (sites, data,
             datasets) = tnseq_tools.read_combined_wig(self.combined_wig)

        # write table of stats (saturation,NZmean)
        file = sys.stdout
        if self.outfile != None: file = open(self.outfile, "w")
        PTI = True
        if PTI == True:
            file.write(
                "dataset\tdensity\tmean_ct\tNZmean\tNZmedian\tmax_ct\ttotal_cts\tskewness\tkurtosis\tpickands_tail_index\n"
            )
        else:
            file.write(
                "dataset\tdensity\tmean_ct\tNZmean\tNZmedian\tmax_ct\ttotal_cts\tskewness\tkurtosis\n"
            )
        for i in range(data.shape[0]):
            density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis = tnseq_tools.get_data_stats(
                data[i, :])
            nzmedianrd = int(nzmedianrd) if numpy.isnan(
                nzmedianrd) == False else 0
            pti = self.pickands_tail_index(data[i, :])
            vals = [
                datasets[i],
                "%0.3f" % density,
                "%0.1f" % meanrd,
                "%0.1f" % nzmeanrd,
                "%d" % nzmedianrd, maxrd,
                int(totalrd),
                "%0.1f" % skew,
                "%0.1f" % kurtosis
            ]
            if PTI == True: vals.append("%0.3f" % pti)
            file.write('\t'.join([str(x) for x in vals]) + '\n')
        if self.outfile != None: file.close()

        self.finish()
        self.transit_message("Finished TnseqStats")
Example #2
0
    def updateFiles(self):
        self.index_stats = 0

        try:
            for j,row in enumerate(self.normdata):
                name = transit_tools.basename(self.wigList[j])
                (density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_data_stats(row)
                self.statsListCtrl.InsertStringItem(self.index_stats, name)
                self.statsListCtrl.SetStringItem(self.index_stats, 1, "%1.1f" % (density*100.0))
                self.statsListCtrl.SetStringItem(self.index_stats, 2, "%1.1f" % (meanrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 3, "%1.1f" % (nzmeanrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 4, "%1.1f" % (nzmedianrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 5, "%d" % (maxrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 6, "%d" % (totalrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 7, "%1.1f" % (skew))
                self.statsListCtrl.SetStringItem(self.index_stats, 8, "%1.1f" % (kurtosis))
                print(self.qc_prefix, "Adding dataset (%d): %s" % (self.index_stats, name))
                self.index_stats+=1
        except Exception as e:
            print(self.qc_prefix, "Error:", e)
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)
Example #3
0
    def updateFiles(self):
        self.index_stats = 0

        try:
            for j,row in enumerate(self.normdata):
                name = transit_tools.basename(self.wigList[j])
                (density, meanrd, nzmeanrd, nzmedianrd, maxrd, totalrd, skew, kurtosis) = tnseq_tools.get_data_stats(row)
                self.statsListCtrl.InsertStringItem(self.index_stats, name)
                self.statsListCtrl.SetStringItem(self.index_stats, 1, "%1.1f" % (density*100.0))
                self.statsListCtrl.SetStringItem(self.index_stats, 2, "%1.1f" % (meanrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 3, "%1.1f" % (nzmeanrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 4, "%1.1f" % (nzmedianrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 5, "%d" % (maxrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 6, "%d" % (totalrd))
                self.statsListCtrl.SetStringItem(self.index_stats, 7, "%1.1f" % (skew))
                self.statsListCtrl.SetStringItem(self.index_stats, 8, "%1.1f" % (kurtosis))
                print self.qc_prefix, "Adding dataset (%d): %s" % (self.index_stats, name)
                self.index_stats+=1
        except Exception as e:
            print self.qc_prefix, "Error:", e
            exc_type, exc_obj, exc_tb = sys.exc_info()
            fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
            print(exc_type, fname, exc_tb.tb_lineno)