Module: MiGA::Cli::Action::Download::Seqcode
Overview
Helper module including download functions for the seqcode_get action
Instance Method Summary collapse
- #cli_name_modifiers(opt) ⇒ Object
- #cli_task_flags(_opt) ⇒ Object
- #remote_list ⇒ Object
- #remote_row_name(tax, db, asm) ⇒ Object
- #sanitize_cli ⇒ Object
Methods included from Base
#cli_base_flags, #cli_filters, #cli_save_actions, #discard_excluded, #download_entries, #exclude_newer, #finalize_tasks, #generic_perform, #impose_limit, #load_ncbi_taxonomy_dump, #load_tasks, #save_entry, #unlink_entries
Instance Method Details
#cli_name_modifiers(opt) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/miga/cli/action/download/seqcode.rb', line 13 def cli_name_modifiers(opt) opt.on( '--no-version-name', 'Do not add sequence version to the dataset name' ) { |v| cli[:add_version] = v } end |
#cli_task_flags(_opt) ⇒ Object
10 11 |
# File 'lib/miga/cli/action/download/seqcode.rb', line 10 def cli_task_flags(_opt) end |
#remote_list ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/miga/cli/action/download/seqcode.rb', line 24 def remote_list cli.say 'Downloading genome list' current_page = 1 total_pages = 1 ds = {} while current_page <= total_pages json = MiGA::RemoteDataset.download( :seqcode, :'type-genomes', nil, :json, nil, page: current_page ) doc = MiGA::Json.parse(json, contents: true) current_page = doc.dig(:response, :current_page) + 1 total_pages = doc.dig(:response, :total_pages) doc[:values].each do |name| nt = name[:nomenclatural_type] next unless nt && nt[:class] == 'Genome' acc = nt.values.first db = nt.keys.first next unless i[assembly nuccore].include?(db) # No INSDC genome, ignore classif = name[:classification] || {} tax = MiGA::Taxonomy.new(Hash[classif.map { |i| [i[:rank], i[:name]] }]) tax << { 'ns' => 'seqcode', name[:rank] => name[:name] } d = { ids: [acc], db: db, universe: :seqcode, md: { type: :genome, tax: tax, is_type: true, type_rel: 'SeqCode type genome', seqcode_url: "https://seqco.de/i:#{name[:id]}" } } d[:md][:get_ncbi_taxonomy] = true if cli[:get_ncbi_taxonomy] ds[remote_row_name(tax, db, acc)] = d end end ds end |
#remote_row_name(tax, db, asm) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/miga/cli/action/download/seqcode.rb', line 64 def remote_row_name(tax, db, asm) acc = asm.to_s acc.gsub!(/\.\d+\Z/, '') unless cli[:add_version] db_short = { assembly: 'asm', nuccore: 'gb' }[db] "#{tax.lowest[1]}_#{db_short}_#{acc}".miga_name end |
#sanitize_cli ⇒ Object
20 21 22 |
# File 'lib/miga/cli/action/download/seqcode.rb', line 20 def sanitize_cli cli[:save_every] = 1 if cli[:dry] end |