ncbi-taxonomy 0.2.7 → 0.2.8
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/bin/ncbi_taxonomy +29 -7
- data/lib/ncbi_taxonomy.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba922fa5117153ff37efbfdd32d00f1ebab44bdc
|
4
|
+
data.tar.gz: 44cc81dbc4364b4d28e4ef579d9a010bc2dbf6d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c4b4b4b491955470cb15e161323ea0995ab83cbc303838348d1e236fd5941af52352248b22d764822b4e3cf668b3f998d55802858d56bdbae9309ffb93e4622
|
7
|
+
data.tar.gz: a1ee97cf153a9f6c7d307b00342bea1e43aee3a268a0ac499592c42c88c0e2aa3e52bff8207c4dc821863fb4da147c2b34d74dc5bddddb69137315ff36ee00ce
|
data/bin/ncbi_taxonomy
CHANGED
@@ -4,7 +4,7 @@ require 'ncbi_taxonomy_update'
|
|
4
4
|
|
5
5
|
def help msg
|
6
6
|
STDERR.puts msg
|
7
|
-
STDERR.puts "usage: #{$0.split("/")[-1]} <command> {-r} {-f} <args>"
|
7
|
+
STDERR.puts "usage: #{$0.split("/")[-1]} <command> {-i} {-r} {-f} <args>"
|
8
8
|
STDERR.puts
|
9
9
|
STDERR.puts "These commands are used for search."
|
10
10
|
STDERR.puts " name Search taxonomic names using organism name with all ranks"
|
@@ -25,6 +25,10 @@ def help msg
|
|
25
25
|
#STDERR.puts " example using file) ncbi_taxonomy fid -f list.txt"
|
26
26
|
STDERR.puts
|
27
27
|
STDERR.puts "Common option for search command"
|
28
|
+
STDERR.puts " -i read multiple names or taxon ids from file"
|
29
|
+
STDERR.puts " example) $ ncbi_taxonomy name -i names_list.txt"
|
30
|
+
STDERR.puts " example) $ ncbi_taxonomy id -i taxon_id_list.txt"
|
31
|
+
STDERR.puts
|
28
32
|
STDERR.puts " -r show each rank name in the result (default is hiding rank name)"
|
29
33
|
STDERR.puts " example) $ ncbi_taxonomy name -r \"Escherichia coli SE11\""
|
30
34
|
STDERR.puts
|
@@ -50,20 +54,28 @@ def help msg
|
|
50
54
|
exit 1
|
51
55
|
end
|
52
56
|
|
57
|
+
def read_list f
|
58
|
+
list = Array.new
|
59
|
+
IO.foreach(f) do |el|
|
60
|
+
list << el.chomp unless el.chomp == ''
|
61
|
+
end
|
62
|
+
|
63
|
+
list
|
64
|
+
end
|
65
|
+
|
53
66
|
def search command, arg, opts
|
54
|
-
t = Taxonomy.new
|
55
67
|
out = nil
|
56
68
|
if command =~ /^na/
|
57
|
-
outs = t.get_allrank_by_name arg
|
69
|
+
outs = $t.get_allrank_by_name arg
|
58
70
|
STDERR.puts "[WARNING] name in multiple taxon" if outs.size > 1
|
59
71
|
elsif command =~ /^fn/
|
60
|
-
outs = t.get_fixedrank_by_name arg
|
72
|
+
outs = $t.get_fixedrank_by_name arg
|
61
73
|
STDERR.puts "[WARNING] name in multiple taxon" if outs.size > 1
|
62
74
|
elsif command =~ /^id/
|
63
|
-
outs = t.get_allrank_by_id arg.to_i
|
75
|
+
outs = $t.get_allrank_by_id arg.to_i
|
64
76
|
outs = [ outs ]
|
65
77
|
elsif command =~ /^fi/
|
66
|
-
outs = t.get_fixedrank_by_id arg.to_i
|
78
|
+
outs = $t.get_fixedrank_by_id arg.to_i
|
67
79
|
outs = [ outs ]
|
68
80
|
else
|
69
81
|
help "Incorrect command: #{command}"
|
@@ -114,6 +126,8 @@ when 'update'
|
|
114
126
|
ARGV.shift == '-f' ? flag = true : flag = false
|
115
127
|
update flag
|
116
128
|
else
|
129
|
+
$t = Taxonomy.new
|
130
|
+
|
117
131
|
while ARGV.size > 0
|
118
132
|
arg = ARGV.shift
|
119
133
|
if arg =~ /^-/
|
@@ -124,6 +138,14 @@ else
|
|
124
138
|
end
|
125
139
|
|
126
140
|
args.each do |x|
|
127
|
-
|
141
|
+
if opts.index('-i') != nil
|
142
|
+
#$t.memory unless $t.memory?
|
143
|
+
list = read_list x
|
144
|
+
list.each do |el|
|
145
|
+
search command, el, opts
|
146
|
+
end
|
147
|
+
else
|
148
|
+
search command, x, opts
|
149
|
+
end
|
128
150
|
end
|
129
151
|
end
|
data/lib/ncbi_taxonomy.rb
CHANGED
@@ -17,6 +17,7 @@ class Taxonomy
|
|
17
17
|
@home_dir = Dir.home
|
18
18
|
@work_dir = @home_dir + "/.ncbi_taxonomy"
|
19
19
|
@taxdb_release = @work_dir + "/taxonomy.db"
|
20
|
+
@in_memory = false
|
20
21
|
begin
|
21
22
|
@db = SQLite3::Database.new @taxdb_release
|
22
23
|
rescue SQLite3::CantOpenException => e
|
@@ -32,6 +33,11 @@ class Taxonomy
|
|
32
33
|
backup.step -1
|
33
34
|
backup.finish
|
34
35
|
@db = tmp
|
36
|
+
@in_memory = true
|
37
|
+
end
|
38
|
+
|
39
|
+
def memory?
|
40
|
+
@in_memory
|
35
41
|
end
|
36
42
|
|
37
43
|
def check_sqlite_version
|
@@ -81,7 +87,7 @@ class Taxonomy
|
|
81
87
|
id = id.to_i
|
82
88
|
out = Array.new
|
83
89
|
if check_sqlite_version
|
84
|
-
rs = @db.execute "WITH RECURSIVE allrank(id, pid, rank, name) AS ( VALUES(0, #{id}, 'no_rank', 'Homo sapiens javamintus') UNION ALL SELECT nodes.tax_id, nodes.parent_tax_id, nodes.rank, names.name_txt FROM nodes, names, allrank WHERE nodes.tax_id=allrank.pid AND names.tax_id = nodes.tax_id AND names.name_class='scientific name' AND nodes.tax_id<>1) SELECT * FROM allrank;"
|
90
|
+
rs = @db.execute "WITH RECURSIVE allrank (id, pid, rank, name) AS ( VALUES (0, #{id}, 'no_rank', 'Homo sapiens javamintus') UNION ALL SELECT nodes.tax_id, nodes.parent_tax_id, nodes.rank, names.name_txt FROM nodes, names, allrank WHERE nodes.tax_id=allrank.pid AND names.tax_id = nodes.tax_id AND names.name_class='scientific name' AND nodes.tax_id<>1) SELECT * FROM allrank;"
|
85
91
|
rs[1..-2].each {|x| out << [ x[2], x[3] ] }
|
86
92
|
else
|
87
93
|
while true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ncbi-taxonomy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seok-Won Kim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|