Take the parsed stats from the ClipAndMerge report and add it to the
        basic stats table at the top of the report
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)
334509
def report(args):
    
    from jcvi.utils.table import tabulate

    p = OptionParser(report.__doc__)

    types = {"read":      ["padded_start", "padded_end", "orient"],
             "consensus": ["padded_consensus_start", "padded_consensus_end"],
             "quality"  : ["qual_clipping_start", "qual_clipping_end", "align_clipping_start", "align_clipping_end"]
            }
    valid_types = tuple(types.keys())
    p.add_option("--type", default="read", choices=valid_types,
            help="choose report type [default: %default]")

    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    acefile, = args
    ace = Ace.read(must_open(acefile))
    logging.debug('Loaded ace file {0}'.format(acefile))

    for c in ace.contigs:
        print(c.name)
        table = dict()
        if opts.type == "read":
            ps, pe = [], []
            ps = [read.padded_start for read in c.af]
            for i in xrange(1, len(ps)):
                pe.append(ps[i] - ps[i-1])
            pe.append(c.nbases)
            map = dict(zip(ps, pe))
            for i, read in enumerate(c.af):
                values = [str(x) for x in (read.padded_start, map[read.padded_start], read.coru)]
                for i, label in enumerate(types[opts.type]):
                    table[(str(read.name), label)] = values[i]
        elif opts.type == "consensus":
            for read in c.bs:
                values = [str(x) for x in (read.padded_start, read.padded_end)]
                for i, label in enumerate(types[opts.type]):
                    table[(str(read.name), label)] = values[i]
        elif opts.type == "quality":
            for read in c.reads:
                (r1, r2) = (read.rd, read.qa)
                values = [str(x) for x in (r2.qual_clipping_start, r2.qual_clipping_end, r2.align_clipping_start, r2.align_clipping_end)]
                for i, label in enumerate(types[opts.type]):
                    table[(str(r1.name), label)] = values[i]
        print(tabulate(table), "\n")
925756
public void actionMerge(I_CmsReport report) {

        m_report = report;
        m_report.println(Messages.get().container(Messages.RPT_MERGE_PAGES_BEGIN_0), I_CmsReport.FORMAT_HEADLINE);

        try {
            // collect all pages and sort them depending on their state
            collectResources();
            // merge all pages that can be merged
            mergePages();
            // cleanup
            cleanup();
        } catch (CmsException e) {
            m_report.println(e);
        }

    }
897246
def add_reporter(self, reporter):
        """"""
        with self._lock:
            reporter.init(list(self.metrics.values()))
            self._reporters.append(reporter)
170683
def _GenerateStatsTable(self, feed_merger):
    
    rows = []
    rows.append('<tr><th class="header"/><th class="header">Merged</th>'
                '<th class="header">Copied from old feed</th>'
                '<th class="header">Copied from new feed</th></tr>')
    for merger in feed_merger.GetMergerList():
      stats = merger.GetMergeStats()
      if stats is None:
        continue
      merged, not_merged_a, not_merged_b = stats
      rows.append('<tr><th class="header">%s</th>'
                  '<td class="header">%d</td>'
                  '<td class="header">%d</td>'
                  '<td class="header">%d</td></tr>' %
                  (merger.DATASET_NAME, merged, not_merged_a, not_merged_b))
    return '<table>%s</table>' % '\n'.join(rows)
941868
private void addToStatsTree(ModuleItem mi) {
        ArrayList colMembers = myStatsWithChildren.subCollections();
        if (colMembers == null) {
            colMembers = new ArrayList(1);
            myStatsWithChildren.setSubcollections(colMembers);
        }

        colMembers.add(mi.getStats(true));
    }
1064400
protected void concatenateReports() {

        if (!concatenatedReports.isEmpty()) { // dummy group for page break if needed
            DJGroup globalGroup = createDummyGroup();
            report.getColumnsGroups().add(0, globalGroup);
        }

        for (Subreport subreport : concatenatedReports) {
            DJGroup globalGroup = createDummyGroup();
            globalGroup.getFooterSubreports().add(subreport);
            report.getColumnsGroups().add(0, globalGroup);
        }
    }
717587
def _merge_metadata(samples):
    """"""
    samples = list(utils.flatten(samples))
    out_dir = dd.get_work_dir(samples[0])
    logger.info("summarize metadata")
    out_file = os.path.join(out_dir, "metadata.csv")
    sample_metrics = collections.defaultdict(dict)
    for s in samples:
        m = tz.get_in(['metadata'], s)
        if isinstance(m, six.string_types):
            m = json.loads(m)
        if m:
            for me in list(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)
    pd.DataFrame(sample_metrics).transpose().to_csv(out_file)
    return out_file
1221206
def add_output(summary_output, long_output, helper):
    
    if summary_output != '':
        helper.add_summary(summary_output)
    helper.add_long_output(long_output)
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();
        }
    }
877526
def report(self):
        
        # Add all the genes to the header
        header = 'Sample,'
        data = str()
        with open(os.path.join(self.reportpath, '{at}.csv'.format(at=self.analysistype)), 'w') as report:
            write_header = True
            for sample in self.runmetadata:
                data += sample.name + ','
                # Iterate through all the user-supplied target names
                for target in sorted(self.genes):
                    write_results = False
                    # There was an issue with 'target' not matching 'name' due to a dash being replaced by an underscore
                    # only in 'name'. This will hopefully address this issue
                    target = target.replace('-', '_')
                    if write_header:
                        header += '{target}_match_details,{target},'.format(target=target)
                    for name, identity in sample[self.analysistype].results.items():
                        # Ensure that all dashes are replaced with underscores
                        name = name.replace('-', '_')
                        # If the current target matches the target in the header, add the data to the string
                        if name == target:
                            write_results = True
                            gene_results = '{percent_id}% ({avgdepth} +/- {stddev}),{record},'\
                                .format(percent_id=identity,
                                        avgdepth=sample[self.analysistype].avgdepth[name],
                                        stddev=sample[self.analysistype].standarddev[name],
                                        record=sample[self.analysistype].sequences[target])
                            # Populate the data string appropriately
                            data += gene_results
                    # If the target is not present, write dashes to represent the results and sequence
                    if not write_results:
                        data += '-,-,'
                data += ' \n'
                write_header = False
            header += '\n'
            # Write the strings to the report
            report.write(header)
            report.write(data)
491137
public void appendReport (StringBuilder report, long now, long sinceLast, boolean reset)
    {
        PresentsConMgrStats stats = getStats();
        long eventCount = stats.eventCount - _lastStats.eventCount;
        int connects = stats.connects - _lastStats.connects;
        int disconnects = stats.disconnects - _lastStats.disconnects;
        int closes = stats.closes - _lastStats.closes;
        long bytesIn = stats.bytesIn - _lastStats.bytesIn;
        long bytesOut = stats.bytesOut - _lastStats.bytesOut;
        long msgsIn = stats.msgsIn - _lastStats.msgsIn;
        long msgsOut = stats.msgsOut - _lastStats.msgsOut;
        if (reset) {
            _lastStats = stats;
        }

        // make sure we don't div0 if this method somehow gets called twice in
        // the same millisecond
        sinceLast = Math.max(sinceLast, 1L);

        report.append("* presents.net.ConnectionManager:\n");
        report.append("- Network connections: ");
        report.append(stats.connectionCount).append(" connections, ");
        report.append(stats.handlerCount).append(" handlers\n");
        report.append("- Network activity: ");
        report.append(eventCount).append(" events, ");
        report.append(connects).append(" connects, ");
        report.append(disconnects).append(" disconnects, ");
        report.append(closes).append(" closes\n");
        report.append("- Network input: ");
        report.append(bytesIn).append(" bytes, ");
        report.append(msgsIn).append(" msgs, ");
        report.append(msgsIn*1000/sinceLast).append(" mps, ");
        long avgIn = (msgsIn == 0) ? 0 : (bytesIn/msgsIn);
        report.append(avgIn).append(" avg size, ");
        report.append(bytesIn*1000/sinceLast).append(" bps\n");
        report.append("- Network output: ");
        report.append(bytesOut).append(" bytes, ");
        report.append(msgsOut).append(" msgs, ");
        report.append(msgsOut*1000/sinceLast).append(" mps, ");
        long avgOut = (msgsOut == 0) ? 0 : (bytesOut/msgsOut);
        report.append(avgOut).append(" avg size, ");
        report.append(bytesOut*1000/sinceLast).append(" bps\n");
    }
145300
def set_stats(self, run_stats):
        
        self.stats = run_stats.copy()
        self.stats['files'] = ', '.join(self.stats['files'])
        self.stats['tot_files'] = len(run_stats['files'])
        self.stats['extra_tags'] = ', '.join(self.stats['extra_tags'])
1051108
def addTable(D):
    

    _swap = {
        "1": "measurement",
        "2": "summary",
        "3": "ensemble",
        "4": "distribution"
    }


    print("What type of table would you like to add?\n"
          "1: measurement\n"
          "2: summary\n"
          "3: ensemble (under development)\n"
          "4: distribution (under development)\n"
          "\n Note: if you want to add a whole model, use the addModel() function")
    _ans = input(">")

    if _ans in ["3", "4"]:
        print("I don't know how to do that yet.")
    # if this is a summary or measurement, split the csv into each column
    elif _ans in ["1", "2"]:
        # read in a csv file. have the user point to it
        print("Locate the CSV file with the values for this table: ")
        _path, _files = browse_dialog_file()

        _path = _confirm_file_path(_files)
        _values = read_csv_from_file(_path)
        _table = _build_table(_values)
        _placement = _prompt_placement(D, _swap[_ans])
        D = _put_table(D, _placement, _table)

    else:
        print("That's not a valid option")

    return D
952525
def join_summaries(summary_frames, selected_summaries, keep_old_header=False):
    """"""

    selected_summaries_dict = create_selected_summaries_dict(selected_summaries)
    frames = []
    keys = []
    for key in summary_frames:
        keys.append(key)
        if summary_frames[key].empty:
            logging.debug("Empty summary_frame encountered")
        frames.append(summary_frames[key])

    out = []
    summary_df = pd.concat(frames, keys=keys, axis=1)
    for key, value in selected_summaries_dict.items():
        _summary_df = summary_df.iloc[
                      :, summary_df.columns.get_level_values(1) == value
                      ]
        _summary_df.name = key

        if not keep_old_header:
            try:
                _summary_df.columns = _summary_df.columns.droplevel(-1)
            except AttributeError as e:
                logging.debug("could not drop level from frame")
                logging.debug(e)

        out.append(_summary_df)
    logger.debug("finished joining summaries")

    return out
476746
def add(self, start, end, cut_point = None, skip_rate = None, extend_loop = None):
        ''''''
        self.data.append(self.parse_loop_line(['LOOP', start, end, cut_point, skip_rate, extend_loop]))
        assert(start <= end)
737567
def merge(assembled_gtfs, ref_file, gtf_file, num_cores, data):
    
    assembled_file = tempfile.NamedTemporaryFile(delete=False).name
    with open(assembled_file, "w") as temp_handle:
        for assembled in assembled_gtfs:
            temp_handle.write(assembled + "\n")
    out_dir = os.path.join("assembly", "cuffmerge")
    merged_file = os.path.join(out_dir, "merged.gtf")
    out_file = os.path.join(out_dir, "assembled.gtf")
    if file_exists(out_file):
        return out_file
    if not file_exists(merged_file):
        with file_transaction(data, out_dir) as tmp_out_dir:
            cmd = ("cuffmerge -o {tmp_out_dir} --ref-gtf {gtf_file} "
                   "--num-threads {num_cores} --ref-sequence {ref_file} "
                   "{assembled_file}")
            cmd = cmd.format(**locals())
            message = ("Merging the following transcript assemblies with "
                       "Cuffmerge: %s" % ", ".join(assembled_gtfs))
            do.run(cmd, message)
    clean, _ = clean_assembly(merged_file)
    fixed = fix_cufflinks_attributes(gtf_file, clean, data)
    classified = annotate_gtf.annotate_novel_coding(fixed, gtf_file, ref_file,
                                                    data)
    filtered = annotate_gtf.cleanup_transcripts(classified, gtf_file, ref_file)
    shutil.move(filtered, out_file)
    return out_file