Take the parsed summary stats from Slamdunk and add it to the
        basic stats table at the top of the report
967897
def slamdunkGeneralStatsTable(self):
        


        headers = OrderedDict()
        headers['counted'] = {
            'title': '{} Counted'.format(config.read_count_prefix),
            'description': '# reads counted within 3\'UTRs ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'scale': 'YlGn',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['retained'] = {
            'title': '{} Retained'.format(config.read_count_prefix),
            'description': '# retained reads after filtering ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'scale': 'YlGn',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['mapped'] = {
            'title': '{} Mapped'.format(config.read_count_prefix),
            'description': '# mapped reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'scale': 'YlGn',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['sequenced'] = {
            'title': '{} Sequenced'.format(config.read_count_prefix),
            'description': '# sequenced reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'scale': 'YlGn',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }

        self.general_stats_addcols(self.slamdunk_data, headers)
171106
def pick_summary_data(key, summary_df, selected_summaries):
    """"""

    selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
    value = selected_summaries_dict[key]
    return summary_df.iloc[:, summary_df.columns.get_level_values(1) == value]
1283703
def conpair_general_stats_table(self):
        

        headers = {}
        headers['concordance_concordance'] = {
            'title': 'Concordance',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.2f}',
            'scale': 'RdYlGn'
        }
        headers['contamination_normal'] = {
            'title': 'N Contamination',
            'description': 'Normal sample contamination level',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.3f}',
            'scale': 'RdYlBu-rev'
        }
        headers['contamination_tumor'] = {
            'title': 'T Contamination',
            'description': 'Tumor sample contamination level',
            'max': 100,
            'min': 0,
            'suffix': '%',
            'format': '{:,.3f}',
            'scale': 'RdYlBu-rev'
        }
        self.general_stats_addcols(self.conpair_data, headers)
841664
def slamdunkFilterStatsTable(self):
        

        headers = OrderedDict()
        headers['mapped'] = {
            'namespace': 'Slamdunk',
            'title': '{} Mapped'.format(config.read_count_prefix),
            'description': '# mapped reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'suffix': config.read_count_prefix,
            'scale': 'YlGn',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['multimapper'] = {
            'namespace': 'Slamdunk',
            'title': '{} Multimap-Filtered'.format(config.read_count_prefix),
            'description': '# multimap-filtered reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'suffix': config.read_count_prefix,
            'scale': 'OrRd',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['nmfiltered'] = {
            'namespace': 'Slamdunk',
            'title': '{} NM-Filtered'.format(config.read_count_prefix),
            'description': '# NM-filtered reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'suffix': config.read_count_prefix,
            'scale': 'OrRd',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['idfiltered'] = {
            'namespace': 'Slamdunk',
            'title': '{} Identity-Filtered'.format(config.read_count_prefix),
            'description': '# identity-filtered reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'suffix': config.read_count_prefix,
            'scale': 'OrRd',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        headers['mqfiltered'] = {
            'namespace': 'Slamdunk',
            'title': '{} MQ-Filtered'.format(config.read_count_prefix),
            'description': '# MQ-filtered reads ({})'.format(config.read_count_desc),
            'shared_key': 'read_count',
            'min': 0,
            'format': '{:,.2f}',
            'suffix': config.read_count_prefix,
            'scale': 'OrRd',
            'modify': lambda x: float(x) * config.read_count_multiplier,
        }
        pconfig = {
            'id': 'slamdunk_filtering_table',
            'min': 0,
        }

        self.add_section (
            name = 'Filter statistics',
            anchor = 'slamdunk_filtering',
            description = 'This table shows the number of reads filtered with each filter criterion during filtering phase of slamdunk.',
            plot = table.plot(self.slamdunk_data, headers, pconfig)
        )
523789
public void setupSummaryKey(BaseField[][] mxKeyFields)
    {
        for (int i = 0; i < mxKeyFields.length; i++)
        {
            mxKeyFields[i][SUMMARY].moveFieldToThis(mxKeyFields[i][BASIS]);
        }
    }
168045
def verifybamid_general_stats_table(self):
		

		# create a dictionary to hold the columns to add to the general stats table
		headers = OrderedDict()
		# available columns are:
		#SEQ_ID RG  CHIP_ID #SNPS   #READS  AVG_DP  FREEMIX FREELK1 FREELK0 FREE_RH FREE_RA CHIPMIX CHIPLK1 CHIPLK0 CHIP_RH CHIP_RA DPREF   RDPHET  RDPALT
		#see https://genome.sph.umich.edu/wiki/VerifyBamID#Interpreting_output_files

		# add the CHIPMIX column if we have data
		if not self.hide_chip_columns:
			headers['CHIPMIX'] = dict(self.col_config_defaults, **{
				'title': 'Contamination (S+A)',
				'description': 'VerifyBamID: CHIPMIX -   Sequence+array estimate of contamination (NA if the external genotype is unavailable)'
			})

		# add the FREEMIX column. set the title and description
		headers['FREEMIX'] = dict(self.col_config_defaults, **{
			'title': 'Contamination (S)',
			'description': 'VerifyBamID: FREEMIX -   Sequence-only estimate of contamination.',
		})

		# pass the data dictionary and header dictionary to function to add to table.
		self.general_stats_addcols(self.verifybamid_data, headers)
743589
def __display_stats(self):
        """"""

        self.display('unify.tmpl', processed=self.total,
                     matched=self.matched,
                     unified=self.total - self.matched)
898762
def _GenerateStaticsTable(self, title='Current Statistics'):
        """"""
        if len(self.__categories.keys()) < 1:
            return ''
        d = self.__categories
        keys = sorted(d.keys())
        cats = ', '.join(['"%s"' % k for k in keys])
        vals = ', '.join(['%d' % d[k] for k in keys])

        return r'''

%s
%s

.. csv-table::
   :header: %s

   %s

''' % (title, '-'*len(title), cats, vals)
1143618
def summary(app):
    """"""
    r = requests.get('https://{}.herokuapp.com/summary'.format(app))
    summary = r.json()['summary']
    click.echo("\nstatus \t| count")
    click.echo("----------------")
    for s in summary:
        click.echo("{}\t| {}".format(s[0], s[1]))
    num_101s = sum([s[1] for s in summary if s[0] == 101])
    num_10xs = sum([s[1] for s in summary if s[0] >= 100])
    if num_10xs > 0:
        click.echo("\nYield: {:.2%}".format(1.0 * num_101s / num_10xs))
844636
def slamdunkPCAPlot (self):
        

        pconfig = {
            'id': 'slamdunk_pca',
            'title': 'Slamdunk: PCA',
            'xlab': 'PC1',
            'ylab': 'PC2',
            'tt_label': 'PC1 {point.x:.2f}: PC2 {point.y:.2f}'
        }

        self.add_section (
            name = 'PCA (T&gt;C based)',
            anchor = 'slamdunk_PCA',
            description = """This plot shows the principal components of samples based
                        on the distribution of reads with T&gt;C conversions within UTRs
                        (see the <a href="http://t-neumann.github.io/slamdunk/docs.html#summary" target="_blank">slamdunk docs</a>).""",
            plot = scatter.plot(self.PCA_data, pconfig)
        )
687018
public void addSummary(Record recSummary, BaseField[][] mxKeyFields, BaseField[][] mxDataFields)
    {
        try {
            recSummary.addNew();
            // First move the key to see if a record exists
            this.setupSummaryKey(mxKeyFields);
            boolean bSuccess = recSummary.seek("=");
            if (bSuccess)
                recSummary.edit();
            else
            {
                recSummary.addNew();
                this.setupSummaryKey(mxKeyFields);
            }
            this.addSummaryData(mxDataFields);
            if (bSuccess)
                recSummary.set();
            else
                recSummary.add();
        } catch (DBException ex)    {
            ex.printStackTrace();
        }
    }
802411
def _dump_stats(self):
        '''
        
        '''
        extras = {}
        if 'total' in self.stats_dict:
            self.logger.debug("Compiling total/fail dump stats")
            for key in self.stats_dict['total']:
                final = 'total_{t}'.format(t=key)
                extras[final] = self.stats_dict['total'][key].value()
            for key in self.stats_dict['fail']:
                final = 'fail_{t}'.format(t=key)
                extras[final] = self.stats_dict['fail'][key].value()

        if 'plugins' in self.stats_dict:
            self.logger.debug("Compiling plugin dump stats")
            for name in self.stats_dict['plugins']:
                for key in self.stats_dict['plugins'][name]:
                    final = 'plugin_{n}_{t}'.format(n=name, t=key)
                    extras[final] = self.stats_dict['plugins'][name][key].value()

        if not self.logger.json:
            self.logger.info('Kafka Monitor Stats Dump:\n{0}'.format(
                    json.dumps(extras, indent=4, sort_keys=True)))
        else:
            self.logger.info('Kafka Monitor Stats Dump', extra=extras)
1075600
def write_summaries(self, tagged_data, experiment_name, run_name):
    
    logger.debug('Writing summaries for %s tags', len(tagged_data))
    # Connection used as context manager for auto commit/rollback on exit.
    # We still need an explicit BEGIN, because it doesn't do one on enter,
    # it waits until the first DML command - which is totally broken.
    # See: https://stackoverflow.com/a/44448465/1179226
    with self._db:
      self._db.execute('BEGIN TRANSACTION')
      run_id = self._maybe_init_run(experiment_name, run_name)
      tag_to_metadata = {
          tag: tagdata.metadata for tag, tagdata in six.iteritems(tagged_data)
      }
      tag_to_id = self._maybe_init_tags(run_id, tag_to_metadata)
      tensor_values = []
      for tag, tagdata in six.iteritems(tagged_data):
        tag_id = tag_to_id[tag]
        for step, wall_time, tensor_proto in tagdata.values:
          dtype = tensor_proto.dtype
          shape = ','.join(str(d.size) for d in tensor_proto.tensor_shape.dim)
          # Use tensor_proto.tensor_content if it's set, to skip relatively
          # expensive extraction into intermediate ndarray.
          data = self._make_blob(
              tensor_proto.tensor_content or
              tensor_util.make_ndarray(tensor_proto).tobytes())
          tensor_values.append((tag_id, step, wall_time, dtype, shape, data))
      self._db.executemany(
          """
          INSERT OR REPLACE INTO Tensors (
            series, step, computed_time, dtype, shape, data
          ) VALUES (?, ?, ?, ?, ?, ?)
          """,
          tensor_values)
1227615
def dedup_general_stats_table(self):
        

        headers = OrderedDict()
        headers['duplication_rate'] = {
            'title': 'Duplication Rate',
            'description': 'Percentage of reads categorised as a technical duplicate',
            'min': 0,
            'max': 100,
            'suffix': '%',
            'scale': 'OrRd',
            'format': '{:,.0f}',
            'modify': lambda x: x * 100.0
        }
        self.general_stats_addcols(self.dedup_data, headers)
8796
def installStatsLoop(statsFile, statsDelay):
  """"""

  def dumpStats():
    """Actual stats dump function."""
    scales.dumpStatsTo(statsFile)
    reactor.callLater(statsDelay, dumpStats)

  def startStats():
    """Starts the stats dump in "statsDelay" seconds."""
    reactor.callLater(statsDelay, dumpStats)

  reactor.callWhenRunning(startStats)
22430
def update(self, stats):
        """"""
        # Get the stats
        all_stats = stats.getAllExportsAsDict(plugin_list=self.plugins_to_export())

        # Init data with timestamp (issue#708)
        if self.first_line:
            csv_header = ['timestamp']
        csv_data = [time.strftime('%Y-%m-%d %H:%M:%S')]

        # Loop over plugins to export
        for plugin in self.plugins_to_export():
            if isinstance(all_stats[plugin], list):
                for stat in all_stats[plugin]:
                    # First line: header
                    if self.first_line:
                        csv_header += ('{}_{}_{}'.format(
                            plugin, self.get_item_key(stat), item) for item in stat)
                    # Others lines: stats
                    csv_data += itervalues(stat)
            elif isinstance(all_stats[plugin], dict):
                # First line: header
                if self.first_line:
                    fieldnames = iterkeys(all_stats[plugin])
                    csv_header += ('{}_{}'.format(plugin, fieldname)
                                   for fieldname in fieldnames)
                # Others lines: stats
                csv_data += itervalues(all_stats[plugin])

        # Export to CSV
        if self.first_line:
            self.writer.writerow(csv_header)
            self.first_line = False
        self.writer.writerow(csv_data)
        self.csv_file.flush()
545338
def clipandmerge_general_stats_table(self):
        

        headers = OrderedDict()
        headers['percentage'] = {
            'title': '% Merged',
            'description': 'Percentage of reads merged',
            'min': 0,
            'max': 100,
            'suffix': '%',
            'scale': 'Greens',
            'format': '{:,.2f}',
        }
        self.general_stats_addcols(self.clipandmerge_data, headers)