Skip to content

Commit

Permalink
Merge pull request #89 from wasade/restrict_to_metadata_columns
Browse files Browse the repository at this point in the history
MAINT: allow extracting specific metadata columns
  • Loading branch information
wasade authored Oct 31, 2019
2 parents 5dd7b27 + d4640cc commit 5acae76
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion redbiom/commands/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,26 @@ def fetch_features_contained(context):
@click.option('--tagged', is_flag=True, default=False,
help=("Obtain the tag specific metadata (e.g., preparation "
"information)."))
@click.option('--force-category', type=str, required=False, multiple=True,
help=("Force the output to include specific metadata variables "
"if the metadata variable was observed in any of the "
"samples. This can be specified mulitple times for "
"multiple categories."))
@click.argument('samples', nargs=-1)
def fetch_sample_metadata(from_, samples, all_columns, context, output,
tagged):
tagged, force_category):
"""Retreive sample metadata."""
import redbiom.util
iterator = redbiom.util.from_or_nargs(from_, samples)

import redbiom.fetch

if not force_category:
force_category = None

md, map_ = redbiom.fetch.sample_metadata(iterator, context=context,
common=not all_columns,
restrict_to=force_category,
tagged=tagged)

md.to_csv(output, sep='\t', header=True, index=False, encoding='utf-8')
Expand Down

0 comments on commit 5acae76

Please sign in to comment.