Skip to content

Commit

Permalink
Add hidden flag --ncbi-list-json for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
lmrodriguezr committed Jan 23, 2024
1 parent 4f45e8d commit b1a4056
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
23 changes: 21 additions & 2 deletions lib/miga/cli/action/download/ncbi.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def cli_task_flags(opt)
cli[:scaffold] = true
cli[:contig] = true
end
opt.on('--ncbi-list-json STRING', '::HIDE::') do |v|
cli[:ncbi_list_json] = v
end
end

def cli_name_modifiers(opt)
Expand All @@ -35,7 +38,9 @@ def cli_name_modifiers(opt)
'Only affects --complete and --chromosome'
) { |v| cli[:add_version] = v }
# For backwards compatibility
cli.opt_flag(opt, 'legacy-name', '::HIDE::', :legacy_name)
opt.on('--legacy-name', '::HIDE::') do
warn 'Deprecated flag --legacy-name ignored'
end
end

def sanitize_cli
Expand All @@ -49,6 +54,11 @@ def sanitize_cli
end

def remote_list
if cli[:ncbi_list_json] && File.size?(cli[:ncbi_list_json])
cli.say "Reusing remote list: #{cli[:ncbi_list_json]}"
return MiGA::Json.parse(cli[:ncbi_list_json])
end

list = {}
query = remote_list_query
loop do
Expand All @@ -66,6 +76,14 @@ def remote_list
break unless page[:next_page_token]
query[:page_token] = page[:next_page_token]
end

if cli[:ncbi_list_json]
cli.say "Saving remote list: #{cli[:ncbi_list_json]}"
File.open(cli[:ncbi_list_json], 'w') do |fh|
fh.puts MiGA::Json.generate_plain(list)
end
end

list
end

Expand All @@ -80,7 +98,8 @@ def parse_reports_as_datasets(reports)
ds[n] = {
ids: [asm], db: :assembly, universe: :ncbi,
md: {
type: :genome, ncbi_asm: asm, strain: r.dig(:organism, :infraspecific_names, :strain)
type: :genome, ncbi_asm: asm,
strain: r.dig(:organism, :infraspecific_names, :strain)
}
}
date = r.dig(:assembly_info, :release_date)
Expand Down
2 changes: 1 addition & 1 deletion lib/miga/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module MiGA
# - String indicating release status:
# - rc* release candidate, not released as gem
# - [0-9]+ stable release, released as gem
VERSION = [1.3, 9, 1].freeze
VERSION = [1.3, 9, 2].freeze

##
# Nickname for the current major.minor version.
Expand Down

0 comments on commit b1a4056

Please sign in to comment.