Permalink
Browse files

New option --active for all dataset listings in CLI

  • Loading branch information...
lmrodriguezr committed Nov 18, 2018
1 parent 77caba6 commit 596a8d18a7e436f5301e3526312a377fa4d3807c
Showing with 7 additions and 3 deletions.
  1. +7 −3 bin/miga
@@ -19,7 +19,7 @@ $task_desc = {
# Datasets
add: "Creates an empty dataset in a pre-existing MiGA project.",
get: "Downloads a dataset from public databases into a MiGA project.",
ncbi_get: "Downloads all genomes in a taxon or RefSeq from NCBI into a MiGA project.",
ncbi_get: "Downloads all genomes in a taxon from NCBI into a MiGA project.",
rm: "Removes a dataset from an MiGA project.",
find: "Finds unregistered datasets based on result files.",
ln: "Link datasets (including results) from one project to another.",
@@ -137,13 +137,16 @@ def opt_common(opt, o)
end

# OptParse flags to filter lists of datasets.
def opt_filter_datasets(opt, o, what=[:ref, :multi, :taxonomy])
def opt_filter_datasets(opt, o, what=[:ref, :multi, :active, :taxonomy])
opt.on("--[no-]ref",
"If set, uses only reference (or only non-reference) datasets."
){ |v| o[:ref]=v } if what.include? :ref
opt.on("--[no-]multi",
"If set, uses only multi-species (or only single-species) datasets."
){ |v| o[:multi]=v } if what.include? :multi
opt.on("--[no-]active",
"If set, uses only active (or inactive) datasets."
){ |v| o[:active]=v } if what.include? :active
opt.on("-t", "--taxonomy RANK:TAXON", "Filter by taxonomy."
){ |v| o[:taxonomy]=MiGA::Taxonomy.new v } if what.include? :taxonomy
opt.on("-k", "--key INTEGER",
@@ -163,7 +166,8 @@ end

# Filters datasets by keys set in +opt_filter_datasets+.
def filter_datasets!(ds, o)
ds.select!{|d| d.is_ref? == o[:ref] } unless o[:ref].nil?
ds.select! { |d| d.is_ref? == o[:ref] } unless o[:ref].nil?
ds.select! { |d| d.is_active? == o[:active] } unless o[:active].nil?
ds.select! do |d|
o[:multi] ? d.is_multi? : d.is_nonmulti?
end unless o[:multi].nil?

0 comments on commit 596a8d1

Please sign in to comment.