miga-base 0.5.10.0 → 0.6.0.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.
data/lib/miga/version.rb CHANGED
@@ -10,15 +10,15 @@ 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.5, 10, 0]
13
+ VERSION = [0.6, 0, 0]
14
14
 
15
15
  ##
16
16
  # Nickname for the current major.minor version.
17
- VERSION_NAME = 'collotype'
17
+ VERSION_NAME = 'lithograph'
18
18
 
19
19
  ##
20
20
  # Date of the current gem release.
21
- VERSION_DATE = Date.new(2020, 2, 25)
21
+ VERSION_DATE = Date.new(2020, 3, 7)
22
22
 
23
23
  ##
24
24
  # Reference of MiGA.
data/scripts/cds.bash CHANGED
@@ -28,7 +28,7 @@ case "$TYPE" in
28
28
  P_LEN=0
29
29
  BEST_CT=0
30
30
  echo "# Codon table selection:" > "${DATASET}.ct.t"
31
- for ct in 4 11 ; do
31
+ for ct in 11 4 ; do
32
32
  prodigal -a "${DATASET}.faa.$ct" -d "${DATASET}.fna.$ct" \
33
33
  -o "${DATASET}.gff3.$ct" -f gff -q -p single -g "$ct" \
34
34
  -i "../05.assembly/${DATASET}.LargeContigs.fna"
@@ -36,7 +36,7 @@ case "$TYPE" in
36
36
  | perl -pe 's/[^A-Z]//ig' | wc -c | awk '{print $1}')
37
37
  echo "# codon table $ct total length: $C_LEN aa" \
38
38
  >> "${DATASET}.ct.t"
39
- if [[ $C_LEN > $P_LEN ]] ; then
39
+ if [[ $C_LEN > $(($P_LEN * 11 / 10)) ]] ; then
40
40
  for x in faa fna gff3 ; do
41
41
  mv "${DATASET}.$x.$ct" "${DATASET}.$x"
42
42
  done
data/scripts/miga.bash CHANGED
@@ -10,11 +10,6 @@ SCRIPT=${SCRIPT:-$(basename "$0" .bash)}
10
10
  function exists { [[ -e "$1" ]] ; }
11
11
  function fx_exists { [[ $(type -t "$1") == "function" ]] ; }
12
12
 
13
- for i in $(miga plugins -P "$PROJECT") ; do
14
- # shellcheck source=/dev/null
15
- . "$i/scripts-plugin.bash"
16
- done
17
-
18
13
  if [[ "$SCRIPT" != "d" && "$SCRIPT" != "p" ]] ; then
19
14
  echo '############'
20
15
  echo -n "Date: " ; miga date
data/scripts/stats.bash CHANGED
@@ -14,7 +14,7 @@ miga date > "$DATASET.start"
14
14
  # Calculate statistics
15
15
  for i in raw_reads trimmed_fasta assembly cds essential_genes ssu distances taxonomy ; do
16
16
  echo "# $i"
17
- miga result_stats --compute-and-save -P "$PROJECT" -D "$DATASET" -r $i
17
+ miga stats --compute-and-save -P "$PROJECT" -D "$DATASET" -r $i
18
18
  done
19
19
 
20
20
  # Finalize
data/test/hook_test.rb ADDED
@@ -0,0 +1,110 @@
1
+ require 'test_helper'
2
+ require 'miga/project'
3
+
4
+ class HookTest < Test::Unit::TestCase
5
+
6
+ def setup
7
+ $tmp = Dir.mktmpdir
8
+ ENV['MIGA_HOME'] = $tmp
9
+ FileUtils.touch("#{ENV['MIGA_HOME']}/.miga_rc")
10
+ FileUtils.touch("#{ENV['MIGA_HOME']}/.miga_daemon.json")
11
+ $p1 = MiGA::Project.new(File.expand_path('project1', $tmp))
12
+ $d1 = $p1.add_dataset('dataset1')
13
+ end
14
+
15
+ def teardown
16
+ FileUtils.rm_rf $tmp
17
+ ENV['MIGA_HOME'] = nil
18
+ end
19
+
20
+ def test_add_hook
21
+ assert_nil($d1.hooks[:on_save])
22
+ $d1.add_hook(:on_save, :run_lambda, Proc.new { $counter += 1 })
23
+ assert_equal(1, $d1.hooks[:on_save].size)
24
+ $counter = 1
25
+ $d1.save
26
+ assert_equal(2, $counter)
27
+ end
28
+
29
+ def test_missing_action
30
+ $d1.add_hook(:on_save, :this_is_not_an_action)
31
+ assert_raise do
32
+ $d1.save
33
+ end
34
+ end
35
+
36
+ class MyHanger
37
+ include MiGA::Common::Hooks
38
+ end
39
+
40
+ def test_empty_hooks
41
+ a = MyHanger.new
42
+ assert_equal({}, a.hooks)
43
+ end
44
+
45
+ def test_dataset_result_hooks
46
+ $res = :test
47
+ $counter = 1
48
+ $d1.add_hook(:on_result_ready,
49
+ :run_lambda, Proc.new { |r| $res = r })
50
+ $d1.add_hook(:on_result_ready_trimmed_reads,
51
+ :run_lambda, Proc.new { $counter += 1 })
52
+ FileUtils.touch(File.expand_path(
53
+ "data/02.trimmed_reads/#{$d1.name}.1.clipped.fastq", $p1.path))
54
+ FileUtils.touch(File.expand_path(
55
+ "data/02.trimmed_reads/#{$d1.name}.done", $p1.path))
56
+ assert_equal(:test, $res)
57
+ $d1.add_result(:trimmed_reads)
58
+ assert_equal(:trimmed_reads, $res)
59
+ assert_equal(2, $counter)
60
+ end
61
+
62
+ def test_dataset_clear_run_counts
63
+ $d1.metadata[:_try_something] = 1
64
+ $d1.metadata[:_not_a_counter] = 1
65
+ $d1.save
66
+ assert_equal(1, $d1.metadata[:_try_something])
67
+ $d1.add_hook(:on_remove, :clear_run_counts)
68
+ $d1.remove!
69
+ assert_nil($d1.metadata[:_try_something])
70
+ assert_equal(1, $d1.metadata[:_not_a_counter])
71
+ end
72
+
73
+ def test_dataset_run_cmd
74
+ f = File.expand_path('hook_ds_cmd', $tmp)
75
+ $d1.metadata[:on_remove] = [[:run_cmd, "echo {{dataset}} > '#{f}'"]]
76
+ assert(! File.exist?(f))
77
+ $d1.remove!
78
+ assert(File.exist? f)
79
+ assert_equal($d1.name, File.read(f).chomp)
80
+ end
81
+
82
+ def test_project_run_cmd
83
+ f = File.expand_path('hook_pr_cmd', $tmp)
84
+ $p1.add_hook(:on_save, :run_cmd, "echo {{project}} > '#{f}'")
85
+ assert(! File.exist?(f))
86
+ $p1.save
87
+ assert(File.exist? f)
88
+ assert_equal($p1.path, File.read(f).chomp)
89
+ end
90
+
91
+ def test_project_result_hooks
92
+ $res = :test
93
+ $counter = 1
94
+ $p1.add_hook(:on_result_ready,
95
+ :run_lambda, Proc.new { |r| $res = r })
96
+ $p1.add_hook(:on_result_ready_project_stats,
97
+ :run_lambda, Proc.new { $counter += 1 })
98
+ %w[taxonomy.json metadata.db done].each do |ext|
99
+ FileUtils.touch(File.expand_path(
100
+ "data/90.stats/miga-project.#{ext}", $p1.path))
101
+ end
102
+ assert_equal(:project_stats, $p1.next_task(nil, false))
103
+ assert_equal(:test, $res)
104
+ assert_equal(1, $counter)
105
+ assert_equal(:haai_distances, $p1.next_task)
106
+ assert_equal(:project_stats, $res)
107
+ assert_equal(2, $counter)
108
+ end
109
+
110
+ end
data/utils/subclades.R CHANGED
@@ -133,7 +133,7 @@ subclade_clustering <- function(out_base, thr, ani.d, dist_rdata) {
133
133
 
134
134
  # Classify genomes
135
135
  say("Classify => k :", top.n, "| n :", length(labels(ani.d)))
136
- ani.cl <- pam(ani.d, top.n, pamonce=1)
136
+ ani.cl <- pam(ani.d, top.n)
137
137
  ani.types <- ani.cl$clustering
138
138
  ani.medoids <- ani.cl$medoids
139
139
 
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.5.10.0
4
+ version: 0.6.0.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: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-03-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons
@@ -121,7 +121,6 @@ files:
121
121
  - lib/miga/cli/action/ncbi_get.rb
122
122
  - lib/miga/cli/action/new.rb
123
123
  - lib/miga/cli/action/next_step.rb
124
- - lib/miga/cli/action/plugins.rb
125
124
  - lib/miga/cli/action/preproc_wf.rb
126
125
  - lib/miga/cli/action/quality_wf.rb
127
126
  - lib/miga/cli/action/rm.rb
@@ -139,18 +138,20 @@ files:
139
138
  - lib/miga/common.rb
140
139
  - lib/miga/common/base.rb
141
140
  - lib/miga/common/format.rb
141
+ - lib/miga/common/hooks.rb
142
142
  - lib/miga/common/path.rb
143
143
  - lib/miga/daemon.rb
144
144
  - lib/miga/daemon/base.rb
145
145
  - lib/miga/dataset.rb
146
146
  - lib/miga/dataset/base.rb
147
+ - lib/miga/dataset/hooks.rb
147
148
  - lib/miga/dataset/result.rb
148
149
  - lib/miga/json.rb
149
150
  - lib/miga/metadata.rb
150
151
  - lib/miga/project.rb
151
152
  - lib/miga/project/base.rb
152
153
  - lib/miga/project/dataset.rb
153
- - lib/miga/project/plugins.rb
154
+ - lib/miga/project/hooks.rb
154
155
  - lib/miga/project/result.rb
155
156
  - lib/miga/remote_dataset.rb
156
157
  - lib/miga/remote_dataset/base.rb
@@ -158,6 +159,8 @@ files:
158
159
  - lib/miga/result.rb
159
160
  - lib/miga/result/base.rb
160
161
  - lib/miga/result/dates.rb
162
+ - lib/miga/result/source.rb
163
+ - lib/miga/result/stats.rb
161
164
  - lib/miga/tax_dist.rb
162
165
  - lib/miga/tax_index.rb
163
166
  - lib/miga/taxonomy.rb
@@ -189,6 +192,7 @@ files:
189
192
  - test/common_test.rb
190
193
  - test/daemon_test.rb
191
194
  - test/dataset_test.rb
195
+ - test/hook_test.rb
192
196
  - test/json_test.rb
193
197
  - test/metadata_test.rb
194
198
  - test/project_test.rb
@@ -1,28 +0,0 @@
1
- # @package MiGA
2
- # @license Artistic-2.0
3
-
4
- require 'miga/cli/action'
5
-
6
- class MiGA::Cli::Action::Plugins < MiGA::Cli::Action
7
-
8
- def parse_cli
9
- cli.parse do |opt|
10
- cli.opt_object(opt, [:project])
11
- opt.on(
12
- '--install PATH',
13
- 'Install the specified plugin in the project'
14
- ){ |v| cli[:install] = v }
15
- opt.on(
16
- '--uninstall PATH',
17
- 'Uninstall the specified plugin from the project'
18
- ){ |v| cli[:uninstall] = v }
19
- end
20
- end
21
-
22
- def perform
23
- p = cli.load_project
24
- p.install_plugin(cli[:install]) unless cli[:install].nil?
25
- p.uninstall_plugin(cli[:uninstall]) unless cli[:uninstall].nil?
26
- p.plugins.each { |i| cli.puts i }
27
- end
28
- end
@@ -1,41 +0,0 @@
1
- # @package MiGA
2
- # @license Artistic-2.0
3
-
4
- ##
5
- # Helper module including specific functions handle plugins.
6
- module MiGA::Project::Plugins
7
-
8
- ##
9
- # Installs the plugin in the specified path.
10
- def install_plugin(path)
11
- abs_path = File.absolute_path(path)
12
- raise "Plugin already installed in project: #{abs_path}." unless
13
- metadata[:plugins].nil? or not metadata[:plugins].include?(abs_path)
14
- raise "Malformed MiGA plugin: #{abs_path}." unless
15
- File.exist?(File.expand_path("miga-plugin.json", abs_path))
16
- self.metadata[:plugins] ||= []
17
- self.metadata[:plugins] << abs_path
18
- save
19
- end
20
-
21
- ##
22
- # Uninstall the plugin in the specified path.
23
- def uninstall_plugin(path)
24
- abs_path = File.absolute_path(path)
25
- raise "Plugin not currently installed: #{abs_path}." if
26
- metadata[:plugins].nil? or not metadata[:plugins].include?(abs_path)
27
- self.metadata[:plugins].delete(abs_path)
28
- save
29
- end
30
-
31
- ##
32
- # List plugins installed in the project.
33
- def plugins ; metadata[:plugins] ||= [] ; end
34
-
35
- ##
36
- # Loads the plugins installed in the project.
37
- def load_plugins
38
- plugins.each { |pl| require File.expand_path("lib-plugin.rb", pl) }
39
- end
40
-
41
- end