miga-base 1.3.9.8 → 1.3.10.0
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 +4 -4
- data/lib/miga/cli/action/download/ncbi.rb +5 -4
- data/lib/miga/cli/action/ncbi_get.rb +7 -8
- data/lib/miga/remote_dataset.rb +53 -0
- data/lib/miga/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0239e39a0588b73d042da7d970925d2d93a5334c858453e032d51b0af760fa27'
|
4
|
+
data.tar.gz: 81e6903e1feba6571d76fe5d113a60414bd0d3b1b3090d6e26367a93cf8d0da7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d68e55d5335f3da03eb9cea737aad5fa21a7a272e3958db6130e7260387844c1bed92b0b2f655a5a5133772797212b717559da9701723c9885cc9ee7cffc962f
|
7
|
+
data.tar.gz: 8d27c2f580106c0d1f74e6daaf1cb81ffd7c6fbabf86e7569342027ff9e09b1810c245ad560eff0179c3d06a88b2d1a087344c56e34a2d54c799004e2f6370c0
|
@@ -17,10 +17,7 @@ module MiGA::Cli::Action::Download::Ncbi
|
|
17
17
|
cli.opt_flag(opt, 'chromosome', 'Download complete chromosomes')
|
18
18
|
cli.opt_flag(opt, 'scaffold', 'Download genomes in scaffolds')
|
19
19
|
cli.opt_flag(opt, 'contig', 'Download genomes in contigs')
|
20
|
-
opt.on(
|
21
|
-
'--all',
|
22
|
-
'Download all genomes (in any status)'
|
23
|
-
) do
|
20
|
+
opt.on('--all', 'Download all genomes (in any status)') do
|
24
21
|
cli[:complete] = true
|
25
22
|
cli[:chromosome] = true
|
26
23
|
cli[:scaffold] = true
|
@@ -29,6 +26,10 @@ module MiGA::Cli::Action::Download::Ncbi
|
|
29
26
|
opt.on('--ncbi-list-json STRING', '::HIDE::') do |v|
|
30
27
|
cli[:ncbi_list_json] = v
|
31
28
|
end
|
29
|
+
opt.on(
|
30
|
+
'--ncbi-taxonomy-dump STRING',
|
31
|
+
'Path to an NCBI Taxonomy dump directory to query instead of API calls'
|
32
|
+
) { |v| MiGA::RemoteDataset.use_ncbi_taxonomy_dump(v) }
|
32
33
|
end
|
33
34
|
|
34
35
|
def cli_name_modifiers(opt)
|
@@ -24,14 +24,13 @@ class MiGA::Cli::Action::NcbiGet < MiGA::Cli::Action
|
|
24
24
|
cli_name_modifiers(opt)
|
25
25
|
cli_filters(opt)
|
26
26
|
cli_save_actions(opt)
|
27
|
-
opt.on(
|
28
|
-
|
29
|
-
'
|
30
|
-
|
31
|
-
opt.on(
|
32
|
-
'
|
33
|
-
|
34
|
-
) { |v| ENV['NCBI_API_KEY'] = v }
|
27
|
+
opt.on('--api-key STRING', '::HIDE::') do |v|
|
28
|
+
warn "The use of --api-key is deprecated, please use --ncbi-api-key"
|
29
|
+
ENV['NCBI_API_KEY'] = v
|
30
|
+
end
|
31
|
+
opt.on('--ncbi-api-key STRING', 'NCBI API key') do |v|
|
32
|
+
ENV['NCBI_API_KEY'] = v
|
33
|
+
end
|
35
34
|
end
|
36
35
|
end
|
37
36
|
|
data/lib/miga/remote_dataset.rb
CHANGED
@@ -12,6 +12,55 @@ class MiGA::RemoteDataset < MiGA::MiGA
|
|
12
12
|
# Class-level
|
13
13
|
|
14
14
|
class << self
|
15
|
+
##
|
16
|
+
# Path to a directory with a recent NCBI Taxonomy dump to use instead of
|
17
|
+
# making API calls to NCBI servers, which can be obtained at:
|
18
|
+
# https://ftp.ncbi.nih.gov/pub/taxonomy/taxdump.tar.gz
|
19
|
+
def use_ncbi_taxonomy_dump(path)
|
20
|
+
raise "Directory doesn't exist: #{path}" unless File.directory?(path)
|
21
|
+
|
22
|
+
# Structure: { TaxID => ["name", "rank", parent TaxID] }
|
23
|
+
@ncbi_taxonomy_names = {}
|
24
|
+
|
25
|
+
# Read names.dmp
|
26
|
+
File.open(File.join(path, 'names.dmp')) do |fh|
|
27
|
+
fh.each do |ln|
|
28
|
+
row = ln.split(/\t\|\t?/)
|
29
|
+
next unless row[3] == 'scientific name'
|
30
|
+
@ncbi_taxonomy_names[row[0].to_i] = [row[1].strip]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Read nodes.dmp
|
35
|
+
File.open(File.join(path, 'nodes.dmp')) do |fh|
|
36
|
+
fh.each do |ln|
|
37
|
+
row = ln.split(/\t\|\t?/)
|
38
|
+
child = row[0].to_i
|
39
|
+
parent = row[1].to_i
|
40
|
+
@ncbi_taxonomy_names[child][1] = row[2]
|
41
|
+
@ncbi_taxonomy_names[child][2] = parent unless parent == child
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
##
|
47
|
+
# Is a local NCBI Taxonomy dump available?
|
48
|
+
def ncbi_taxonomy_dump?
|
49
|
+
(@ncbi_taxonomy_names ||= nil) ? true : false
|
50
|
+
end
|
51
|
+
|
52
|
+
##
|
53
|
+
# Get the MiGA::Taxonomy object for the lineage of the taxon with TaxID
|
54
|
+
# +id+ using the local NCBI Taxonomy dump.
|
55
|
+
def taxonomy_from_ncbi_dump(id)
|
56
|
+
MiGA::Taxonomy.new(ns: 'ncbi').tap do |tax|
|
57
|
+
while @ncbi_taxonomy_names[id]
|
58
|
+
tax << { @ncbi_taxonomy_names[id][1] => @ncbi_taxonomy_names[id][0] }
|
59
|
+
id = @ncbi_taxonomy_names[id][2]
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
15
64
|
##
|
16
65
|
# Translate an NCBI Assembly Accession (+acc+) to corresponding internal
|
17
66
|
# NCBI ID, with up to +retrials+ retrials if the returned JSON document
|
@@ -173,6 +222,10 @@ class MiGA::RemoteDataset < MiGA::MiGA
|
|
173
222
|
def get_ncbi_taxonomy
|
174
223
|
tax_id = get_ncbi_taxid or return
|
175
224
|
|
225
|
+
if self.class.ncbi_taxonomy_dump?
|
226
|
+
return self.class.taxonomy_from_ncbi_dump(tax_id)
|
227
|
+
end
|
228
|
+
|
176
229
|
lineage = { ns: 'ncbi' }
|
177
230
|
doc = MiGA::RemoteDataset.download(:ncbi, :taxonomy, tax_id, :xml)
|
178
231
|
doc.scan(%r{<Taxon>(.*?)</Taxon>}m).map(&:first).each do |i|
|
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,
|
15
|
+
VERSION = [1.3, 10, 0].freeze
|
16
16
|
|
17
17
|
##
|
18
18
|
# Nickname for the current major.minor version.
|
@@ -20,7 +20,7 @@ module MiGA
|
|
20
20
|
|
21
21
|
##
|
22
22
|
# Date of the current gem relese.
|
23
|
-
VERSION_DATE = Date.new(2024, 1,
|
23
|
+
VERSION_DATE = Date.new(2024, 1, 31)
|
24
24
|
|
25
25
|
##
|
26
26
|
# References of MiGA
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miga-base
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: daemons
|