File: table_ids.py

package info (click to toggle)
python-biom-format 2.1.7%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 51,820 kB
  • sloc: python: 12,757; makefile: 155; sh: 79
file content (38 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# -----------------------------------------------------------------------------
# Copyright (c) 2011-2017, The BIOM Format Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------

import click

from biom.cli import cli
from biom import load_table


@cli.command(name='table-ids')
@click.option('-i', '--input-fp', required=True,
              type=click.Path(exists=True, dir_okay=False),
              help='The input BIOM table')
@click.option('--observations', default=False, is_flag=True,
              help="Grab observation IDs")
def summarize_table(input_fp, observations):
    """Dump IDs in a table.

    Dump out the IDs found within a table:

    Example usage:

    Get the sample IDs within a table:

    $ biom table-ids -i table.biom

    Get the observation IDs within a table:

    $ biom table-ids -i table.biom --observations
    """
    tab = load_table(input_fp)
    for id_ in tab.ids(axis='observation' if observations else 'sample'):
        click.echo(id_)