miga-base 1.3.12.0 → 1.3.12.2
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/remote_dataset.rb +1 -0
- 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: cf660d951441269a671b7fb57d3e91a572fdb62d5ffbaeda9ff412042798759b
|
4
|
+
data.tar.gz: 1721194dcce4a70e4cad66ca4cea5db88f521323022b62c2c93740458a1b0bea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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/remote_dataset.rb
CHANGED
@@ -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,
|
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
|
-
|
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
|