Get the mapping between metrics and sections in Manuscripts report
        :return: a dict with the mapping between metrics and sections in Manuscripts report
185485
def get_section_metrics(cls):
        

        return {
            "overview": {
                "activity_metrics": [Closed, Submitted],
                "author_metrics": None,
                "bmi_metrics": [BMI],
                "time_to_close_metrics": [DaysToMergeMedian],
                "projects_metrics": [Projects],
            },
            "com_channels": {
                "activity_metrics": [],
                "author_metrics": []
            },
            "project_activity": {
                "metrics": [Submitted, Closed]
            },
            "project_community": {
                "author_metrics": [],
                "people_top_metrics": [],
                "orgs_top_metrics": [],
            },
            "project_process": {
                "bmi_metrics": [BMI],
                "time_to_close_metrics": [],
                "time_to_close_title": "",
                "time_to_close_review_metrics": [DaysToMergeAverage, DaysToMergeMedian],
                "time_to_close_review_title": "Days to close review (median and average)",
                "patchsets_metrics": [PatchsetsMedian, PatchsetsAverage],
                "patchsets_title": "Number of patchsets per review (median and average)"
            }
        }
690128
def interop_parse(self):
        
        # Parse the files and load the data
        try:
            run_metrics = py_interop_run_metrics.run_metrics()
            valid_to_load = py_interop_run.uchar_vector(py_interop_run.MetricCount, 0)
            py_interop_run_metrics.list_summary_metrics_to_load(valid_to_load)
            run_metrics.read(self.path, valid_to_load)
            summary = py_interop_summary.run_summary()
            py_interop_summary.summarize_run_metrics(run_metrics, summary)
            # PhiX error rate for run over all "usable cycles"
            errorrate = summary.total_summary().error_rate()
            # Percent aligned PhiX
            pctaligned = summary.total_summary().percent_aligned()
            # Add the error rate and the percent of reads that align to PhiX to the metadata object
            for sample in self.metadata:
                sample.run.error_rate = '{:.2f}'.format(errorrate)
                sample.run.phix_aligned = '{:.2f}'.format(pctaligned)
        except:
            for sample in self.metadata:
                sample.run.error_rate = 'ND'
                sample.run.phix_aligned = 'ND'
887517
def _get_wmi_properties(self, instance_key, metrics, tag_queries):
        
        if instance_key not in self.wmi_props:
            metric_name_by_property = dict(
                (wmi_property.lower(), (metric_name, metric_type)) for wmi_property, metric_name, metric_type in metrics
            )
            properties = map(lambda x: x[0], metrics + tag_queries)
            self.wmi_props[instance_key] = (metric_name_by_property, properties)

        return self.wmi_props[instance_key]
52364
def snapshot(self):
        
        return dict((category, dict((name, metric.value())
                                    for name, metric in list(metrics.items())))
                    for category, metrics in
                    list(self._store.items()))
111333
def _collect_dict(self, metric_type, field_metric_map, query, db, tags):
        
        try:
            with closing(db.cursor()) as cursor:
                cursor.execute(query)
                result = cursor.fetchone()
                if result is not None:
                    for field, metric in list(iteritems(field_metric_map)):
                        # Find the column name in the cursor description to identify the column index
                        # http://www.python.org/dev/peps/pep-0249/
                        # cursor.description is a tuple of (column_name, ..., ...)
                        try:
                            col_idx = [d[0].lower() for d in cursor.description].index(field.lower())
                            self.log.debug("Collecting metric: %s" % metric)
                            if result[col_idx] is not None:
                                self.log.debug("Collecting done, value %s" % result[col_idx])
                                if metric_type == GAUGE:
                                    self.gauge(metric, float(result[col_idx]), tags=tags)
                                elif metric_type == RATE:
                                    self.rate(metric, float(result[col_idx]), tags=tags)
                                else:
                                    self.gauge(metric, float(result[col_idx]), tags=tags)
                            else:
                                self.log.debug("Received value is None for index %d" % col_idx)
                        except ValueError:
                            self.log.exception("Cannot find %s in the columns %s" % (field, cursor.description))
        except Exception:
            self.warning("Error while running %s\n%s" % (query, traceback.format_exc()))
            self.log.exception("Error while running %s" % query)
241680
def dict(self):
        
        metadata = super(ImpactLayerMetadata, self).dict

        metadata['provenance'] = self.provenance
        metadata['summary_data'] = self.summary_data

        return metadata
1299803
def get_metrics(tag):
    
    if tag is None:
        return metrics.metrics_by_name_list(metrics.metrics())
    else:
        return metrics.metrics_by_tag(tag)
111777
def get_report(self):
        

        lines = [super(LabelCoverageValidationResult, self).get_report()]

        if len(self.uncovered_segments) > 0:
            lines.append('\nUncovered segments:')

            for utt_idx, utt_segments in self.uncovered_segments.items():
                if len(utt_segments) > 0:
                    lines.append('\n{}'.format(utt_idx))
                    sorted_items = sorted(utt_segments, key=lambda x: x[0])
                    lines.extend(['    * {:10.2f}  -  {:10.2f}'.format(x[0], x[1]) for x in sorted_items])

        return '\n'.join(lines)
146717
def get_summary_data(self, sec2d_nt):
        """"""
        grouped = set()
        ungrouped = set()
        sections = set()
        secdflt = self.grprobj.hdrobj.secdflt
        for section_name, nts in sec2d_nt:
            if section_name != secdflt:
                if nts:
                    grouped.update(set(nt.GO for nt in nts))
                    sections.add(section_name)
                else:
                    ungrouped.update(set(nt.GO for nt in nts))
        return {'grouped':grouped, 'ungrouped':ungrouped, 'sections':sections}
694534
def _merge_metrics(samples, out_dir):
    
    logger.info("summarize metrics")
    out_dir = utils.safe_makedir(os.path.join(out_dir, "report", "metrics"))
    sample_metrics = collections.defaultdict(dict)
    for s in samples:
        s = _add_disambiguate(s)
        m = tz.get_in(['summary', 'metrics'], s)
        if isinstance(m, six.string_types):
            m = json.loads(m)
        if m:
            for me in m.keys():
                if isinstance(m[me], list) or isinstance(m[me], dict) or isinstance(m[me], tuple):
                    m.pop(me, None)
            sample_metrics[dd.get_sample_name(s)].update(m)
    out = []
    for sample_name, m in sample_metrics.items():
        sample_file = os.path.join(out_dir, "%s_bcbio.txt" % sample_name)
        with file_transaction(samples[0], sample_file) as tx_out_file:
            dt = pd.DataFrame(m, index=['1'])
            dt.columns = [k.replace(" ", "_").replace("(", "").replace(")", "") for k in dt.columns]
            dt['sample'] = sample_name
            dt['rRNA_rate'] = m.get('rRNA_rate', "NA")
            dt['RiP_pct'] = "%.3f" % (int(m.get("RiP", 0)) / float(m.get("Total_reads", 1)) * 100)
            dt = _fix_duplicated_rate(dt)
            dt.transpose().to_csv(tx_out_file, sep="\t", header=False)
        out.append(sample_file)
    return out
314869
def get_metrics(self):
        

        search_file_nodes_count = search_occurence_nodesCount = 0

        for node in foundations.walkers.nodes_walker(self.root_node):
            if node.family == "SearchFile":
                search_file_nodes_count += 1
            elif node.family == "SearchOccurence":
                search_occurence_nodesCount += 1

        return {"SearchFile": search_file_nodes_count, "SearchOccurence": search_occurence_nodesCount}
1154909
def get_es_mappings(self):
        

        es_mappings = json.loads(requests.get(self.mapping_url).text)
        es_mappings = {"_".join(key.split("_")[:-1]): value['mappings'] \
                       for key, value in es_mappings.items()}
        return es_mappings
1309326
def _create_extractors(cls, metrics):
        
        metrics_dict = {}
        # group entries by `category` attribute (default is "standard")
        for metric, config in six.iteritems(metrics):
            category = config.get('category', StdBenchmark.DEFAULT_CATEGORY)
            metrics_dict.setdefault(category, {})[metric] = config
        # create one StdExtractor instance per category,
        # passing associated metrics
        return dict(
            (category, StdExtractor(metrics))
            for category, metrics in six.iteritems(metrics_dict)
        )
735446
def get_document_models():
    """"""
    mappings = {}
    for i in get_index_names():
        for m in get_index_models(i):
            key = "%s.%s" % (i, m._meta.model_name)
            mappings[key] = m
    return mappings
172875
def __get_metrics(self):
        
        esfilters_merge = None
        esfilters_abandon = None
        esfilters_submit = None
        if self.esfilters:
            esfilters_merge = self.esfilters.copy()
            esfilters_abandon = self.esfilters.copy()
            esfilters_submit = self.esfilters.copy()

        merged = Merged(self.es_url, self.es_index,
                        start=self.start, end=self.end,
                        esfilters=esfilters_merge, interval=self.interval)
        # For BMI we need when the ticket was closed
        merged.FIELD_DATE = 'closed'

        abandoned = Abandoned(self.es_url, self.es_index,
                              start=self.start, end=self.end,
                              esfilters=esfilters_abandon, interval=self.interval)
        # For BMI we need when the ticket was closed
        abandoned.FIELD_DATE = 'closed'

        submitted = Submitted(self.es_url, self.es_index,
                              start=self.start, end=self.end,
                              esfilters=esfilters_submit,
                              interval=self.interval)

        return (merged, abandoned, submitted)
579013
def load_kbs(kbs_files):
    

    return {
        'journals_re': build_journals_re_kb(kbs_files['journals-re']),
        'journals': load_kb(kbs_files['journals'], build_journals_kb),
        'report-numbers': build_reportnum_kb(kbs_files['report-numbers']),
        'authors': build_authors_kb(kbs_files['authors']),
        'books': build_books_kb(kbs_files['books']),
        'publishers': load_kb(kbs_files['publishers'], build_publishers_kb),
        'special_journals': build_special_journals_kb(kbs_files['special-journals']),
        'collaborations': load_kb(kbs_files['collaborations'], build_collaborations_kb),
    }
568118
def _compute_document_meta(self):
        
        meta = OrderedDict()

        bounds_iter = xml_utils.bounds(self.filename,
                            start_re=r'<text id="(\d+)"[^>]*name="([^"]*)"',
                            end_re=r'</text>')

        for match, bounds in bounds_iter:
            doc_id, title = str(match.group(1)), match.group(2)
            title = xml_utils.unescape_attribute(title)

            # cache categories
            xml_data = xml_utils.load_chunk(self.filename, bounds)
            doc = Document(compat.ElementTree.XML(xml_data.encode('utf8')))

            meta[doc_id] = _DocumentMeta(title, bounds, doc.categories())
        return meta