miga-base 1.3.12.0 → 1.3.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/miga/cli/action/download/base.rb +19 -5
- data/lib/miga/common/net.rb +2 -1
- data/lib/miga/version.rb +1 -1
- data/test/net_test.rb +7 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 728f619f35f3e43fbd400b82372165e92b9126076d97e8a38883cf85f210be36
|
4
|
+
data.tar.gz: 94c49190af3cfb2325352ce2bbe8f8c4218c0beba4631cadeb2bbbf833af097f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eef58d0024f7a17818f3b4802325817ca1c4f33398f38d9a444645b89526aa68e3a0b70b7b4ba23c4789b5c9367005ca7f2d27f69b42b6c8b5e87c0e2187f897
|
7
|
+
data.tar.gz: be8aa042bb9733da10d559fbc6b0210c4904c94aa66c1bd5de6ea84e2c5f0d9ede5ca77f64cf9e90671c54cc1e85ffdb895b2f77df237ef686302b3121b546f1
|
@@ -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
|
73
|
-
'Path to an NCBI Taxonomy dump directory to query instead of API calls'
|
74
|
-
|
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
|
-
|
101
|
-
|
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
|
|
data/lib/miga/common/net.rb
CHANGED
@@ -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
|
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,
|
15
|
+
VERSION = [1.3, 12, 1].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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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
|