Debian Codegraph @

biom/cli/table_ids.py

raw
1 # -----------------------------------------------------------------------------
2 # Copyright (c) 2011-2017, The BIOM Format Development Team.
3 #
4 # Distributed under the terms of the Modified BSD License.
5 #
6 # The full license is in the file COPYING.txt, distributed with this software.
7 # -----------------------------------------------------------------------------
8
9 import click
10
11 from biom.cli import cli
12 from biom import load_table
13
14
15 @cli.command(name='table-ids')
16 @click.option('-i', '--input-fp', required=True,
17 type=click.Path(exists=True, dir_okay=False),
18 help='The input BIOM table')
19 @click.option('--observations', default=False, is_flag=True,
20 help="Grab observation IDs")
21 def summarize_table(input_fp, observations):
22 """Dump IDs in a table.
23
24 Dump out the IDs found within a table:
25
26 Example usage:
27
28 Get the sample IDs within a table:
29
30 $ biom table-ids -i table.biom
31
32 Get the observation IDs within a table:
33
34 $ biom table-ids -i table.biom --observations
35 """
36 tab = load_table(input_fp)
37 for id_ in tab.ids(axis='observation' if observations else 'sample'):
38 click.echo(id_)