miga-base 0.3.1.2 → 0.3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/actions/doctor.rb +78 -0
- data/bin/miga +2 -1
- data/lib/miga/remote_dataset.rb +5 -3
- data/lib/miga/version.rb +2 -2
- data/test/remote_dataset_test.rb +22 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d05cad62382523776174b6300e3a3cc8cbf87b6
|
4
|
+
data.tar.gz: 71db2e7e0d361c770f978ab265d862e52cd30727
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 761cf711acb535bacc7e789e16545904b2147f498caf9edcb190f7d2a3a6417bf567d86175bb255ff3d1c353bf7b9eaffdc50f9fb998458f2db81d91286a5217
|
7
|
+
data.tar.gz: 91bdc8ddbb06407ea78b120a96823dd46efb5521f85423a5840b0f2e72771f9d67c6ccf8291fd6e7033ebd711a0d1c32c5c48ad2f4e98179ec4d36d108b91347
|
data/actions/doctor.rb
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @package MiGA
|
4
|
+
# @license Artistic-2.0
|
5
|
+
|
6
|
+
o = {q:true, v:false}
|
7
|
+
OptionParser.new do |opt|
|
8
|
+
opt_banner(opt)
|
9
|
+
opt_object(opt, o, [:project])
|
10
|
+
opt.on("-v", "--verbose",
|
11
|
+
"Print additional information on advance."){ |v| o[:v]=v }
|
12
|
+
opt_common(opt, o)
|
13
|
+
end.parse!
|
14
|
+
|
15
|
+
##=> Main <=
|
16
|
+
opt_require(o, project:"-P")
|
17
|
+
|
18
|
+
$stderr.puts "Loading project" unless o[:q]
|
19
|
+
p = MiGA::Project.load(o[:project])
|
20
|
+
raise "Impossible to load project: #{o[:project]}" if p.nil?
|
21
|
+
|
22
|
+
[:ani, :aai].each do |dist|
|
23
|
+
r = p.result("#{dist}_distances")
|
24
|
+
next if r.nil?
|
25
|
+
$stderr.puts "o Checking #{dist} table for consistent datasets" unless o[:q]
|
26
|
+
ok = true
|
27
|
+
fix = {}
|
28
|
+
Zlib::GzipReader.open(r.file_path(:matrix)) do |fh|
|
29
|
+
fh.each_line do |ln|
|
30
|
+
next if $.==1
|
31
|
+
r = ln.split("\t")
|
32
|
+
if p.dataset(r[1]).nil? or p.dataset(r[2]).nil?
|
33
|
+
fix[r[2]] = true unless p.dataset(r[2]).nil?
|
34
|
+
fix[r[1]] = true unless p.dataset(r[1]).nil?
|
35
|
+
ok = false
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
$stderr.puts " - Fixing #{fix.size} datasets" unless fix.empty? or o[:q]
|
41
|
+
fix.keys.each do |d_n|
|
42
|
+
$stderr.puts " > Fixing #{d_n}." if o[:v]
|
43
|
+
p.dataset(d_n).cleanup_distances!
|
44
|
+
end
|
45
|
+
|
46
|
+
unless ok
|
47
|
+
$stderr.puts " - Removing tables, recompute" unless o[:q]
|
48
|
+
r.remove!
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
$stderr.puts "o Looking for outdated files in results" unless o[:q]
|
53
|
+
p.each_dataset do |d|
|
54
|
+
d.each_result do |r_k, r|
|
55
|
+
ok = true
|
56
|
+
r.each_file do |_f_sym, _f_rel, f_abs|
|
57
|
+
unless File.exist? f_abs
|
58
|
+
ok = false
|
59
|
+
break
|
60
|
+
end
|
61
|
+
end
|
62
|
+
unless ok
|
63
|
+
$stderr.puts " - Registering again #{d.name}:#{r_k}" if o[:v]
|
64
|
+
d.add_result(r_k, true, force:true)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
#$stderr.puts "o Looking for unarchived essential genes." unless o[:q]
|
70
|
+
#p.each_dataset do |d|
|
71
|
+
# TODO: Check unarchived protein files
|
72
|
+
#end
|
73
|
+
|
74
|
+
#$stderr.puts "o Checking for taxonomy/distances consistency" unless o[:q]
|
75
|
+
# TODO: Find 95%ANI clusters with entries from different species
|
76
|
+
|
77
|
+
$stderr.puts "Done" unless o[:q]
|
78
|
+
|
data/bin/miga
CHANGED
@@ -15,9 +15,10 @@ $task_desc = {
|
|
15
15
|
new: "Creates an empty MiGA project.",
|
16
16
|
about: "Displays information about a MiGA project.",
|
17
17
|
plugins: "Lists or (un)installs plugins in a MiGA project.",
|
18
|
+
doctor: "Performs consistency checks on a MiGA project.",
|
18
19
|
# Datasets
|
19
20
|
add: "Creates an empty dataset in a pre-existing MiGA project.",
|
20
|
-
get: "
|
21
|
+
get: "Downloads a dataset from public databases into a MiGA project.",
|
21
22
|
rm: "Removes a dataset from an MiGA project.",
|
22
23
|
find: "Finds unregistered datasets based on result files.",
|
23
24
|
ln: "Link datasets (including results) from one project to another.",
|
data/lib/miga/remote_dataset.rb
CHANGED
@@ -71,7 +71,7 @@ class MiGA::RemoteDataset < MiGA::MiGA
|
|
71
71
|
end
|
72
72
|
|
73
73
|
##
|
74
|
-
# Download data
|
74
|
+
# Download data using a REST method from the +universe+ in the database +db+
|
75
75
|
# with IDs +ids+ and in +format+. Returns the doc as String.
|
76
76
|
def self.download_rest(universe, db, ids, format)
|
77
77
|
u = @@UNIVERSE[universe]
|
@@ -85,10 +85,12 @@ class MiGA::RemoteDataset < MiGA::MiGA
|
|
85
85
|
end
|
86
86
|
|
87
87
|
##
|
88
|
-
# Download data
|
88
|
+
# Download data using a GET request from the +universe+ in the database +db+
|
89
89
|
# with IDs +ids+ and in +format+. Returns the doc as String.
|
90
90
|
def self.download_net(universe, db, ids, format)
|
91
|
-
|
91
|
+
u = @@UNIVERSE[universe]
|
92
|
+
map_to = u[:dbs][db].nil? ? nil : u[:dbs][db][:map_to]
|
93
|
+
url = sprintf(u[:url], db, ids.join(","), format, map_to)
|
92
94
|
doc = ""
|
93
95
|
@timeout_try = 0
|
94
96
|
begin
|
data/lib/miga/version.rb
CHANGED
@@ -10,7 +10,7 @@ module MiGA
|
|
10
10
|
# - Float representing the major.minor version.
|
11
11
|
# - Integer representing gem releases of the current version.
|
12
12
|
# - Integer representing minor changes that require new version number.
|
13
|
-
VERSION = [0.3, 1,
|
13
|
+
VERSION = [0.3, 1, 3]
|
14
14
|
|
15
15
|
##
|
16
16
|
# Nickname for the current major.minor version.
|
@@ -18,7 +18,7 @@ module MiGA
|
|
18
18
|
|
19
19
|
##
|
20
20
|
# Date of the current gem release.
|
21
|
-
VERSION_DATE = Date.
|
21
|
+
VERSION_DATE = Date.today
|
22
22
|
|
23
23
|
##
|
24
24
|
# Reference of MiGA.
|
data/test/remote_dataset_test.rb
CHANGED
@@ -38,4 +38,26 @@ class RemoteDatasetTest < Test::Unit::TestCase
|
|
38
38
|
assert_equal("Lentivirus", tx[:g])
|
39
39
|
end
|
40
40
|
|
41
|
+
def test_net_ftp
|
42
|
+
cjac = "ftp://ftp.ebi.ac.uk/pub/databases/ena/tsa/public/ga/GAPJ01.fasta.gz"
|
43
|
+
n = "Cjac_L14"
|
44
|
+
rd = MiGA::RemoteDataset.new(cjac, :assembly_gz, :web)
|
45
|
+
assert_equal([cjac], rd.ids)
|
46
|
+
omit_if(!$remote_tests, "Remote access is error-prone.")
|
47
|
+
p = $p1
|
48
|
+
assert_nil(p.dataset(n))
|
49
|
+
rd.save_to(p, n)
|
50
|
+
p.add_dataset(n)
|
51
|
+
assert_equal(MiGA::Dataset, p.dataset(n).class)
|
52
|
+
assert_equal(MiGA::Result, p.dataset(n).result(:assembly).class)
|
53
|
+
end
|
54
|
+
|
55
|
+
# This test is too expensive (too much time to run it!)
|
56
|
+
#def test_net_timeout
|
57
|
+
# omit_if(!$remote_tests, "Remote access is error-prone.")
|
58
|
+
# bad = "ftp://example.com/miga"
|
59
|
+
# rd = MiGA::RemoteDataset.new(bad, :assembly, :web)
|
60
|
+
# assert_raise(Net::ReadTimeout) { rd.save_to($p1, "bad") }
|
61
|
+
#end
|
62
|
+
|
41
63
|
end
|
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: 0.3.1.
|
4
|
+
version: 0.3.1.3
|
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: 2017-11-
|
11
|
+
date: 2017-11-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- actions/add_result.rb
|
124
124
|
- actions/daemon.rb
|
125
125
|
- actions/date.rb
|
126
|
+
- actions/doctor.rb
|
126
127
|
- actions/files.rb
|
127
128
|
- actions/find.rb
|
128
129
|
- actions/get.rb
|