miga-base 1.3.12.0 → 1.3.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45ab052e74f73fe87a2383443285dae3fb218c659618c1d2d7278ff8bb0de6f4
4
- data.tar.gz: 553c70d1a5c15093686260a0dec176a0f8ecd196f0884218484ff9964e416661
3
+ metadata.gz: cf660d951441269a671b7fb57d3e91a572fdb62d5ffbaeda9ff412042798759b
4
+ data.tar.gz: 1721194dcce4a70e4cad66ca4cea5db88f521323022b62c2c93740458a1b0bea
5
5
  SHA512:
6
- metadata.gz: 27a87882655d6875f482042d388273ce46135329919f9738913022af6fd97f411e9db6238b4bd7fbcc50d7d605da51f447d85b68ff77758cf324ce9e59c7e592
7
- data.tar.gz: 116737b9a5ca99d97a8ad8f704a5df9146177c2d9603c8c4b19e631baa52e60183888369dcec96f671238f6ad934ce8c6324bc368aaff8bc8645f3b1d3dee247
6
+ metadata.gz: ff0b9c3a8db37fa9b0d75a0b884154b416669e068eab9f22f406facf9822345a38baccc224138a15fb5e9e1dff786e55e2ebc0d870573b892f056bf7e18e275a
7
+ data.tar.gz: af7dcea647e3ead8fdbde6f917264efd93335cc9c7878bd7a4b43b8dbb27434882dff76728fa984c5724802a581421ddd333f6cfe46ab1d6c75fb4bb953bc378
@@ -69,9 +69,10 @@ module MiGA::Cli::Action::Download::Base
69
69
  'Path to an output file with the list of all datasets listed remotely'
70
70
  ) { |v| cli[:remote_list] = v }
71
71
  opt.on(
72
- '--ncbi-taxonomy-dump STRING',
73
- 'Path to an NCBI Taxonomy dump directory to query instead of API calls'
74
- ) { |v| cli[:ncbi_taxonomy_dump] = v }
72
+ '--ncbi-taxonomy-dump [path]',
73
+ 'Path to an NCBI Taxonomy dump directory to query instead of API calls',
74
+ 'If the path is not passed, the dump is automatically downloaded'
75
+ ) { |v| cli[:ncbi_taxonomy_dump] = v || true }
75
76
  end
76
77
 
77
78
  def generic_perform
@@ -97,8 +98,21 @@ module MiGA::Cli::Action::Download::Base
97
98
  def load_ncbi_taxonomy_dump
98
99
  return unless cli[:ncbi_taxonomy_dump]
99
100
 
100
- cli.say "Reading NCBI Taxonomy dump: #{cli[:ncbi_taxonomy_dump]}"
101
- MiGA::RemoteDataset.use_ncbi_taxonomy_dump(cli[:ncbi_taxonomy_dump], cli)
101
+ if cli[:ncbi_taxonomy_dump] == true
102
+ cli.say 'Downloading and reading NCBI Taxonomy dump'
103
+ Dir.mktmpdir do |dir|
104
+ file = 'taxdump.tar.gz'
105
+ path = File.join(dir, file)
106
+ url = 'https://ftp.ncbi.nih.gov/pub/taxonomy/%s' % file
107
+
108
+ File.open(path, 'wb') { |fh| fh.print MiGA::MiGA.net_method(:get, url) }
109
+ MiGA::MiGA.run_cmd('cd "%s" && tar -zxf "%s"' % [dir, file])
110
+ MiGA::RemoteDataset.use_ncbi_taxonomy_dump(dir, cli)
111
+ end
112
+ else
113
+ cli.say "Reading NCBI Taxonomy dump: #{cli[:ncbi_taxonomy_dump]}"
114
+ MiGA::RemoteDataset.use_ncbi_taxonomy_dump(cli[:ncbi_taxonomy_dump], cli)
115
+ end
102
116
  end
103
117
 
104
118
 
@@ -123,10 +123,11 @@ module MiGA::Common::Net
123
123
 
124
124
  def net_method(method, uri, *opts)
125
125
  attempts ||= 0
126
+ uri = URI.parse(uri) if uri.is_a? String
126
127
  DEBUG "#{method.to_s.upcase}: #{uri} #{opts}"
127
128
  case method.to_sym
128
129
  when :ftp
129
- download_file_ftp(uri)
130
+ download_file_ftp(uri, *opts)
130
131
  else
131
132
  http_request(method, uri, *opts)
132
133
  end
@@ -67,6 +67,7 @@ class MiGA::RemoteDataset < MiGA::MiGA
67
67
  # Get the MiGA::Taxonomy object for the lineage of the taxon with TaxID
68
68
  # +id+ using the local NCBI Taxonomy dump.
69
69
  def taxonomy_from_ncbi_dump(id)
70
+ id = id.to_i unless id.is_a? Integer
70
71
  MiGA::Taxonomy.new(ns: 'ncbi').tap do |tax|
71
72
  while @ncbi_taxonomy_names[id]
72
73
  tax << { @ncbi_taxonomy_names[id][1] => @ncbi_taxonomy_names[id][0] }
data/lib/miga/version.rb CHANGED
@@ -12,7 +12,7 @@ module MiGA
12
12
  # - String indicating release status:
13
13
  # - rc* release candidate, not released as gem
14
14
  # - [0-9]+ stable release, released as gem
15
- VERSION = [1.3, 12, 0].freeze
15
+ VERSION = [1.3, 12, 2].freeze
16
16
 
17
17
  ##
18
18
  # Nickname for the current major.minor version.
data/test/net_test.rb CHANGED
@@ -37,15 +37,13 @@ class FormatTest < Test::Unit::TestCase
37
37
  f = tmpfile('t/test.txt')
38
38
  d = File.dirname(f)
39
39
  assert(!Dir.exist?(d))
40
- # TODO
41
- # Bring back when I can connect to the Gatech's FTP
42
- ### m = MiGA::MiGA
43
- ### m.download_file_ftp(:miga_online_ftp, 'api_test.txt', f)
44
- ### assert(Dir.exist?(d))
45
- ### assert_equal('miga', File.read(f).chomp)
46
- ### File.unlink(f)
47
- ### m.download_file_ftp(:miga_db, '../api_test.txt', f)
48
- ### assert_equal('miga', File.read(f).chomp)
40
+ m = MiGA::MiGA
41
+ m.download_file_ftp(:miga_online_ftp, 'api_test.txt', f)
42
+ assert(Dir.exist?(d))
43
+ assert_equal('miga', File.read(f).chomp)
44
+ File.unlink(f)
45
+ m.download_file_ftp(:miga_db, '../api_test.txt', f)
46
+ assert_equal('miga', File.read(f).chomp)
49
47
  end
50
48
 
51
49
  def test_encoding
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miga-base
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.12.0
4
+ version: 1.3.12.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luis M. Rodriguez-R