This function yields tuples of table filename, isobaric quant column
    and if necessary number-of-PSM column
547150
def map_psmnrcol_to_quantcol(quantcols, psmcols, tablefn_map):
    """"""
    if not psmcols:
        for fn in quantcols:
            for qcol in quantcols[fn]:
                yield (tablefn_map[fn], qcol)
    else:
        for fn in quantcols:
            for qcol, psmcol in zip(quantcols[fn], psmcols[fn]):
                yield (tablefn_map[fn], qcol, psmcol)
1207518
def create_tables(name, runSetResults, rows, rowsDiff, outputPath, outputFilePattern, options):
    '''
    
    '''

    # get common folder of sourcefiles
    common_prefix = os.path.commonprefix([r.filename for r in rows]) # maybe with parts of filename
    common_prefix = common_prefix[: common_prefix.rfind('/') + 1] # only foldername
    for row in rows:
        Row.set_relative_path(row, common_prefix, outputPath)

    # compute nice name of each run set for displaying
    firstBenchmarkName = Util.prettylist(runSetResults[0].attributes['benchmarkname'])
    allBenchmarkNamesEqual = all(Util.prettylist(r.attributes['benchmarkname']) == firstBenchmarkName for r in runSetResults)
    for r in runSetResults:
        if not r.attributes['name']:
            r.attributes['niceName'] = r.attributes['benchmarkname']
        elif allBenchmarkNamesEqual:
            r.attributes['niceName'] = r.attributes['name']
        else:
            r.attributes['niceName'] = [Util.prettylist(r.attributes['benchmarkname']) + '.' + Util.prettylist(r.attributes['name'])]

    template_values = lambda: None # dummy object as dict replacement for simpler syntax
    template_values.head = get_table_head(runSetResults, common_prefix)
    template_values.run_sets = [runSetResult.attributes for runSetResult in runSetResults]
    template_values.columns = [[column for column in runSet.columns] for runSet in runSetResults]
    template_values.columnTitles =\
        [[column.format_title() for column in runSet.columns] for runSet in runSetResults]

    template_values.relevant_id_columns = select_relevant_id_columns(rows)
    template_values.count_id_columns = template_values.relevant_id_columns.count(True)

    template_values.lib_url = options.lib_url
    template_values.base_dir = outputPath
    template_values.href_base = os.path.dirname(options.xmltablefile) if options.xmltablefile else None
    template_values.version = __version__

    futures = []

    def write_table(table_type, title, rows, use_local_summary):
        # calculate statistics if necessary
        if not options.format == ['csv']:
            local_summary = get_summary(runSetResults) if use_local_summary else None
            stats, stats_columns = get_stats(rows, local_summary, options.correct_only)
        else:
            stats = stats_columns = None

        for template_format in (options.format or TEMPLATE_FORMATS):
            if outputFilePattern == '-':
                outfile = None
                logging.info('Writing %s to stdout...', template_format.upper().ljust(4))
            else:
                outfile = os.path.join(outputPath, outputFilePattern.format(name=name, type=table_type, ext=template_format))
                logging.info('Writing %s into %s ...', template_format.upper().ljust(4), outfile)

            this_template_values = dict(title=title, body=rows, foot=stats, foot_columns=stats_columns)
            this_template_values.update(template_values.__dict__)

            futures.append(parallel.submit(
                write_table_in_format,
                template_format, outfile, this_template_values,
                options.show_table and template_format == 'html',
                ))

    # write normal tables
    write_table("table", name, rows,
                use_local_summary=(not options.correct_only and not options.common))

    # write difference tables
    if rowsDiff:
        write_table("diff", name + " differences", rowsDiff, use_local_summary=False)

    return futures
16859
def get_psms(self):
        """"""
        self.header, isob_header = prep.get_full_and_isobaric_headers(
            self.oldheader, self.lookup, self.isobaric, self.precursor)
        self.psms = prep.generate_psms_quanted(self.lookup, self.fn,
                                               isob_header, self.oldheader,
                                               self.isobaric, self.precursor)
1117041
def get_data_table(filename):
  """"""
  with get_file_object(filename, "r") as rf:
    return DataTable(list(csv.reader(rf)))
565763
def array2tabledef(data, table_type='binary', write_bitcols=False):
    
    is_ascii = (table_type == 'ascii')

    if data.dtype.fields is None:
        raise ValueError("data must have fields")
    names = []
    names_nocase = {}
    formats = []
    dims = []

    descr = data.dtype.descr
    for d in descr:
        # these have the form '<f4' or '|S25', etc.  Extract the pure type
        npy_dtype = d[1][1:]
        if is_ascii:
            if npy_dtype in ['u1', 'i1']:
                raise ValueError(
                    "1-byte integers are not supported for "
                    "ascii tables: '%s'" % npy_dtype)
            if npy_dtype in ['u2']:
                raise ValueError(
                    "unsigned 2-byte integers are not supported for "
                    "ascii tables: '%s'" % npy_dtype)

        if npy_dtype[0] == 'O':
            # this will be a variable length column 1Pt(len) where t is the
            # type and len is max length.  Each element must be convertible to
            # the same type as the first
            name = d[0]
            form, dim = npy_obj2fits(data, name)
        elif npy_dtype[0] == "V":
            continue
        else:
            name, form, dim = _npy2fits(
                d, table_type=table_type, write_bitcols=write_bitcols)

        if name == '':
            raise ValueError("field name is an empty string")

        """
        if is_ascii:
            if dim is not None:
                raise ValueError("array columns are not supported for "
                                 "ascii tables")
        """
        name_nocase = name.upper()
        if name_nocase in names_nocase:
            raise ValueError(
                "duplicate column name found: '%s'.  Note "
                "FITS column names are not case sensitive" % name_nocase)

        names.append(name)
        names_nocase[name_nocase] = name_nocase

        formats.append(form)
        dims.append(dim)

    return names, formats, dims
120641
def read_dependent_peptides(filename):
    
    df = (pd.read_perseus(filename, usecols=_cols)
            .dropna(subset=['DP Ratio mod/base']))
    df['DP Ratio mod/base'] = df['DP Ratio mod/base'].astype(float)
    dep = df.pivot_table('DP Ratio mod/base', index=_index_columns,
                columns='Raw file', aggfunc=np.median)
    localization = _count_localizations(df)
    return dep, localization
507679
def readTableFromDelimited(f, separator="\t"):
    
    rowNames = []
    columnNames = []
    matrix = []

    first = True
    for line in f.readlines():
        line = line.rstrip()
        if len(line) == 0:
            continue

        row = line.split(separator)
        if first:
            columnNames = row[1:]
            first = False
        else:
            rowNames.append(row[0])
            matrix.append([float(c) for c in row[1:]])

    return Table(rowNames, columnNames, matrix)
1220910
def concatenate_table(tup, blen=None, storage=None, create='table', **kwargs):
    """"""

    # setup
    storage = _util.get_storage(storage)
    if not isinstance(tup, (tuple, list)):
        raise ValueError('expected tuple or list, found %r' % tup)
    if len(tup) < 2:
        raise ValueError('expected two or more tables to stack')

    # build output
    expectedlen = sum(len(t) for t in tup)
    out = None
    tnames = None
    for tdata in tup:
        tblen = _util.get_blen_table(tdata, blen)
        tnames, tcolumns = _util.check_table_like(tdata, names=tnames)
        tlen = len(tcolumns[0])
        for i in range(0, tlen, tblen):
            j = min(i+tblen, tlen)
            bcolumns = [c[i:j] for c in tcolumns]
            if out is None:
                out = getattr(storage, create)(bcolumns, names=tnames,
                                               expectedlen=expectedlen,
                                               **kwargs)
            else:
                out.append(bcolumns)
    return out
914636
def base_add_isoquant_data(features, quantfeatures, acc_col, quantacc_col,
                           quantfields):
    """"""
    quant_map = get_quantmap(quantfeatures, quantacc_col, quantfields)
    for feature in features:
        feat_acc = feature[acc_col]
        outfeat = {k: v for k, v in feature.items()}
        try:
            outfeat.update(quant_map[feat_acc])
        except KeyError:
            outfeat.update({field: 'NA' for field in quantfields})
        yield outfeat
647587
def convert_table(app, docname, source):
    """"""
    num_tables = 0
    for i,j in enumerate(source):
        table = []
        output = ''
        in_table = False
        for l in j.split('\n'):
            r = l.strip()
            if r.startswith('|'):
                table.append(r)
                in_table = True
            else:
                if in_table is True:
                    converted = _convert_md_table_to_rst(table)
                    if converted is '':
                        print("Failed to convert the markdown table")
                        print(table)
                    else:
                        num_tables += 1
                    output += converted
                    in_table = False
                    table = []
                output += l + '\n'
        source[i] = output
    if num_tables > 0:
        print('Converted %d tables in %s' % (num_tables, docname))
674175
def load_mib(filenames):
    """"""
    the_mib = {'iso': ['1']}
    unresolved = {}
    for k in six.iterkeys(conf.mib):
        _mib_register(conf.mib[k], k.split("."), the_mib, unresolved)

    if isinstance(filenames, (str, bytes)):
        filenames = [filenames]
    for fnames in filenames:
        for fname in glob(fnames):
            f = open(fname)
            text = f.read()
            cleantext = " ".join(_mib_re_strings.split(" ".join(_mib_re_comments.split(text))))  # noqa: E501
            for m in _mib_re_oiddecl.finditer(cleantext):
                gr = m.groups()
                ident, oid = gr[0], gr[-1]
                ident = fixname(ident)
                oid = oid.split()
                for i, elt in enumerate(oid):
                    m = _mib_re_both.match(elt)
                    if m:
                        oid[i] = m.groups()[1]
                _mib_register(ident, oid, the_mib, unresolved)

    newmib = MIBDict(_name="MIB")
    for oid, key in six.iteritems(the_mib):
        newmib[".".join(key)] = oid
    for oid, key in six.iteritems(unresolved):
        newmib[".".join(key)] = oid

    conf.mib = newmib
877706
def format_table(columns, rows):
    
    rows = [tuple(str(i) for i in r) for r in rows]
    columns = tuple(str(i).upper() for i in columns)
    if rows:
        widths = tuple(max(max(map(len, x)), len(c))
                       for x, c in zip(zip(*rows), columns))
    else:
        widths = tuple(map(len, columns))
    row_template = ('    '.join('%%-%ds' for _ in columns)) % widths
    header = (row_template % tuple(columns)).strip()
    if rows:
        data = '\n'.join((row_template % r).strip() for r in rows)
        return '\n'.join([header, data])
    else:
        return header
457697
def load_data_table(file,
                    index_col,
                    show_progress=False):
    
    with ZipFile(file) as zip_file:
        file_names = zip_file.namelist()
        assert len(file_names) == 1, "Expected a single file from Quandl."
        wiki_prices = file_names.pop()
        with zip_file.open(wiki_prices) as table_file:
            if show_progress:
                log.info('Parsing raw data.')
            data_table = pd.read_csv(
                table_file,
                parse_dates=['date'],
                index_col=index_col,
                usecols=[
                    'ticker',
                    'date',
                    'open',
                    'high',
                    'low',
                    'close',
                    'volume',
                    'ex-dividend',
                    'split_ratio',
                ],
            )

    data_table.rename(
        columns={
            'ticker': 'symbol',
            'ex-dividend': 'ex_dividend',
        },
        inplace=True,
        copy=False,
    )
    return data_table
630803
def kallisto_table(kallisto_dir, index):
    
    quant_dir = os.path.join(kallisto_dir, "quant")
    out_file = os.path.join(quant_dir, "matrix.csv")
    if file_exists(out_file):
        return out_file
    tsvfile = os.path.join(quant_dir, "matrix.tsv")
    ecfile = os.path.join(quant_dir, "matrix.ec")
    cellsfile = os.path.join(quant_dir, "matrix.cells")
    fastafile = os.path.splitext(index)[0] + ".fa"
    fasta_names = fasta.sequence_names(fastafile)
    ec_names = get_ec_names(ecfile, fasta_names)
    df = pd.read_table(tsvfile, header=None, names=["ec", "cell", "count"])
    df["ec"] = [ec_names[x] for x in df["ec"]]
    df = df.pivot(index='ec', columns='cell', values='count')
    cellnames = get_cell_names(cellsfile)
    colnames = [cellnames[x] for x in df.columns]
    df.columns = colnames
    df.to_csv(out_file)
    return out_file
889831
def get_peptable_headerfields(headertypes, lookup=False, poolnames=False):
    """"""
    field_defs = {'isoquant': get_isoquant_fields,
                  'precursorquant': get_precursorquant_fields,
                  'peptidefdr': get_peptidefdr_fields,
                  'peptidepep': get_peptidepep_fields,
                  'proteindata': get_proteininfo_fields,
                  }
    return generate_headerfields(headertypes, field_defs, poolnames, lookup)
144370
def quast_table(self):
        
        headers = OrderedDict()

        headers['N50'] = {
            'title': 'N50 ({})'.format(self.contig_length_suffix),
            'description': 'N50 is the contig length such that using longer or equal length contigs produces half (50%) of the bases of the assembly.',
            'min': 0,
            'suffix': self.contig_length_suffix,
            'scale': 'RdYlGn',
            'modify': lambda x: x * self.contig_length_multiplier
        }

        headers['N75'] = {
            'title': 'N75 ({})'.format(self.contig_length_suffix),
            'description': 'N75 is the contig length such that using longer or equal length contigs produces 75% of the bases of the assembly',
            'min': 0,
            'suffix': self.contig_length_suffix,
            'scale': 'RdYlGn',
            'modify': lambda x: x * self.contig_length_multiplier
        }

        headers['L50'] = {
            'title': 'L50 ({})'.format(self.total_number_contigs_suffix) if self.total_number_contigs_suffix else 'L50',
            'description': 'L50 is the number of contigs larger than N50, i.e. the minimum number of contigs comprising 50% of the total assembly length.',
            'min': 0,
            'suffix': self.total_number_contigs_suffix,
            'scale': 'GnYlRd',
            'modify': lambda x: x * self.total_number_contigs_multiplier
        }

        headers['L75'] = {
            'title': 'L75 ({})'.format(self.total_number_contigs_suffix) if self.total_number_contigs_suffix else 'L75',
            'description': 'L75 is the number of contigs larger than N75, i.e. the minimum number of contigs comprising 75% of the total assembly length.',
            'min': 0,
            'suffix': self.total_number_contigs_suffix,
            'scale': 'GnYlRd',
            'mofidy': lambda x: x * self.total_number_contigs_multiplier
        }
        headers['Largest contig'] = {
            'title': 'Largest contig ({})'.format(self.contig_length_suffix),
            'description': 'The size of the largest contig of the assembly',
            'min': 0,
            'suffix': self.contig_length_suffix,
            'scale': 'YlGn',
            'modify': lambda x: x * self.contig_length_multiplier
        }

        headers['Total length'] = {
            'title': 'Length ({})'.format(self.total_length_suffix),
            'description': 'The total number of bases in the assembly.',
            'min': 0,
            'suffix': self.total_length_suffix,
            'scale': 'YlGn',
            'modify': lambda x: x * self.total_length_multiplier
        }

        headers['# misassemblies'] = {
            'title': 'Misassemblies',
            'description': 'The number of positions in the assembled contigs where the left flanking sequence aligns over 1 kbp away from the right flanking sequence on the reference (relocation) or they overlap on more than 1 kbp (relocation) or flanking sequences align on different strands (inversion) or different chromosomes (translocation).',
            'scale': 'RdYlGn-rev',
            'format': '{,:.0f}'
        }
        headers['# mismatches per 100 kbp'] = {
            'title': 'Mismatches/100kbp',
            'description': 'The number of mismatches per 100 kbp',
            'scale': 'YlOrRd',
            'format': '{:,.2f}',
        }
        headers['# indels per 100 kbp'] = {
            'title': 'Indels/100kbp',
            'description': 'The number of indels per 100 kbp',
            'scale': 'YlOrRd',
            'format': '{:,.2f}',
        }
        headers['# genes'] = {
            'title': 'Genes',
            'description': '# Genes',
            'scale': 'YlGnBu',
            'format': '{:,.0f}',
            'shared_key': 'gene_count'
        }
        headers['# genes_partial'] = {
            'title': 'Genes (Partial)',
            'description': '# Genes (Partial)',
            'scale': 'YlGnBu',
            'format': '{:,.0f}',
            'shared_key': 'gene_count'
        }
        headers['# predicted genes (unique)'] = {
            'title': 'Genes',
            'description': '# Predicted Genes (Unique)',
            'scale': 'YlGnBu',
            'format': '{:,.0f}',
            'shared_key': 'gene_count'
        }
        headers['Genome fraction (%)'] = {
            'title': 'Genome Fraction',
            'description': 'The total number of aligned bases in the reference, divided by the genome size.',
            'max': 100,
            'suffix': '%',
            'scale': 'YlGn'
        }
        config = {
            'id': 'quast_table',
            'namespace': 'QUAST',
            'min': 0,
        }
        return table.plot(self.quast_data, headers, config)
1197071
function findColumns (pgColumns, schemaName, tableName) {
  return pgColumns
    .filter(o => o.table_schema === schemaName && o.table_name === tableName)
    .reduce((columns, col) => {
      const columnInfo = {
        columnDefault: col.column_default,
        isNullable: col.is_nullable,
        dataType: col.data_type,
        characterMaximumLength: col.character_maximum_length,
        numericScale: col.numeric_scale,
        comment: col.column_comment
      }
      if (columnInfo.dataType === 'ARRAY') {
        columnInfo.array = true
        columnInfo.dataType = col.array_element_type.slice(1)
      } else {
        columnInfo.array = false
      }
      columns[col.column_name] = columnInfo
      return columns
    },
    {}
    )
}