Class: MiGA::Cli::Action::NcbiGet
- Inherits:
-
MiGA::Cli::Action
- Object
- MiGA
- MiGA::Cli::Action
- MiGA::Cli::Action::NcbiGet
- Includes:
- Downloads
- Defined in:
- lib/miga/cli/action/ncbi_get.rb
Defined Under Namespace
Modules: Downloads
Constant Summary
Constants included from MiGA
MiGA::CITATION, VERSION, VERSION_DATE, VERSION_NAME
Instance Attribute Summary
Attributes inherited from MiGA::Cli::Action
Instance Method Summary collapse
Methods included from Downloads
#cli_filters, #cli_name_modifiers, #cli_save_actions, #cli_task_flags, #discard_blacklisted, #download_entries, #impose_limit, #remote_list, #remote_list_url, #remote_row_name, #remote_row_replicons, #sanitize_cli, #save_entry
Methods inherited from MiGA::Cli::Action
#complete, #empty_action, #initialize, #launch, load, #name
Methods inherited from MiGA
CITATION, CITATION_ARRAY, DEBUG, DEBUG_OFF, DEBUG_ON, DEBUG_TRACE_OFF, DEBUG_TRACE_ON, FULL_VERSION, LONG_VERSION, VERSION, VERSION_DATE, #advance, debug?, debug_trace?, initialized?, #like_io?, #num_suffix, #result_files_exist?, #say
Methods included from MiGA::Common::Path
Methods included from MiGA::Common::Format
#clean_fasta_file, #seqs_length, #tabulate
Methods included from MiGA::Common::Net
#download_file_ftp, #known_hosts, #remote_connection
Constructor Details
This class inherits a constructor from MiGA::Cli::Action
Instance Method Details
#parse_cli ⇒ Object
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 39 40 41 |
# File 'lib/miga/cli/action/ncbi_get.rb', line 9 def parse_cli cli.defaults = { query: false, unlink: false, reference: false, legacy_name: false, complete: false, chromosome: false, scaffold: false, contig: false, add_version: true, dry: false, get_md: false, only_md: false, save_every: 1 } cli.parse do |opt| cli.opt_object(opt, [:project]) opt.on( '-T', '--taxon STRING', '(Mandatory) Taxon name (e.g., a species binomial)' ) { |v| cli[:taxon] = v } opt.on( '--max INT', Integer, 'Maximum number of datasets to download (by default: unlimited)' ) { |v| cli[:max_datasets] = v } opt.on( '-m', '--metadata STRING', 'Metadata as key-value pairs separated by = and delimited by comma', 'Values are saved as strings except for booleans (true / false) or nil' ) { |v| cli[:metadata] = v } cli_task_flags(opt) cli_name_modifiers(opt) cli_filters(opt) cli_save_actions(opt) opt.on( '--api-key STRING', 'NCBI API key' ) { |v| ENV['NCBI_API_KEY'] = v } end end |
#perform ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/miga/cli/action/ncbi_get.rb', line 43 def perform sanitize_cli p = cli.load_project ds = remote_list ds = discard_blacklisted(ds) ds = impose_limit(ds) d, downloaded = download_entries(ds, p) # Finalize cli.say "Datasets listed: #{d.size}" act = cli[:dry] ? 'to download' : 'downloaded' cli.say "Datasets #{act}: #{downloaded}" unless cli[:remote_list].nil? File.open(cli[:remote_list], 'w') do |fh| d.each { |i| fh.puts i } end end return unless cli[:unlink] unlink = p.dataset_names - d unlink.each { |i| p.unlink_dataset(i).remove! } cli.say "Datasets unlinked: #{unlink.size}" end |