miga-base 1.2.0.1 → 1.2.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27068ded9d2ff63c3575a5aafd3fa68374f4bcf8aef924354e0c9cbde7dc1f6d
4
- data.tar.gz: ef438e828180d304a9e3449d49551ace933a5e5a46128970b3c8bc385c836d58
3
+ metadata.gz: afb7c816474f73c547c7f54982293fe72c24d7829184801ab51fc848adf3d9e3
4
+ data.tar.gz: 06d51ebc47e96c28072c8415321014535ea7576d9e6f1c381e3ca62dc880df15
5
5
  SHA512:
6
- metadata.gz: 894cbeca2aa4f5e29c6bd6e1c23c9c358b9f3b497960998116169fa62d7122da78417e357789dc9b9b7bfdfad824f835b3daa035d1320cb948e5cdc4b1d74bb3
7
- data.tar.gz: 8bea4585b36855195f3a2d76005a6ff664133c1df639a677402907c88fd8f6b0a25fb34cc4bd0e9e38bc7666dbe3a382644137dcf5cddd4005c93256d2c75c05
6
+ metadata.gz: a4f5279fdba54ad1f8bcbce86cb84a7643b473b7742686e8e9992f8c4af7c982d5776a5a06775b10df67b61de90c4a32f915b51a17a9b11a223474574e7f8159
7
+ data.tar.gz: bcd547a1dc5337fbf036ba8e2df6de6db4c4fb34979afeb30ce6c1a692e76166b5412457fb3cc778e03cb601a192af0c8d33709b2e5d7233508dfdbd1c5156ed
@@ -1,5 +1,4 @@
1
- # @package MiGA
2
- # @license Artistic-2.0
1
+ # frozen_string_literal: true
3
2
 
4
3
  require 'miga/cli/action'
5
4
 
@@ -42,33 +41,53 @@ class MiGA::Cli::Action::Ls < MiGA::Cli::Action
42
41
  '-s', '--silent',
43
42
  'No output and exit with non-zero status if the dataset list is empty'
44
43
  ) { |v| cli[:silent] = v }
44
+ opt.on(
45
+ '--exec CMD',
46
+ 'Command to execute per dataset, with the following token variables:',
47
+ '~ {{dataset}}: Name of the dataset',
48
+ '~ {{project}}: Path to the project'
49
+ ) { |v| cli[:exec] = v }
45
50
  end
46
51
  end
47
52
 
48
53
  def perform
49
54
  ds = cli.load_and_filter_datasets(cli[:silent])
55
+ p = cli.load_project
50
56
  exit(ds.empty? ? 1 : 0) if cli[:silent]
51
- if !cli[:datum].nil?
57
+
58
+ head = nil
59
+ fun = nil
60
+ if cli[:datum]
52
61
  cli[:tabular] = true
53
- format_table(ds, [nil, nil]) { |d| [d.name, d.metadata[cli[:datum]]] }
54
- elsif !cli[:fields].nil?
55
- format_table(ds, [:name] + cli[:fields]) do |d|
56
- [d.name] + cli[:fields].map { |f| d.metadata[f] }
57
- end
62
+ head = [nil, nil]
63
+ fun = proc { |d| [d.name, d.metadata[cli[:datum]]] }
64
+ elsif cli[:fields]
65
+ head = [:name] + cli[:fields]
66
+ fun = proc { |d| [d.name] + cli[:fields].map { |f| d.metadata[f] } }
58
67
  elsif cli[:info]
59
- format_table(ds, Dataset.INFO_FIELDS) { |d| d.info }
68
+ head = Dataset.INFO_FIELDS
69
+ fun = proc(&:info)
60
70
  elsif cli[:processing]
61
- comp = %w[- done queued]
62
- format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d|
63
- [d.name] + d.profile_advance.map { |i| comp[i] }
71
+ head = [:name] + MiGA::Dataset.PREPROCESSING_TASKS
72
+ fun = proc do |d|
73
+ [d.name] + d.profile_advance.map { |i| %w[- done queued][i] }
64
74
  end
65
75
  elsif cli[:taskstatus]
66
- format_table(ds, [:name] + MiGA::Dataset.PREPROCESSING_TASKS) do |d|
67
- [d.name] + d.results_status.values
68
- end
76
+ head = [:name] + MiGA::Dataset.PREPROCESSING_TASKS
77
+ fun = proc { |d| [d.name] + d.results_status.values }
69
78
  else
70
79
  cli[:tabular] = true
71
- format_table(ds, [nil]) { |d| [d.name] }
80
+ head = [nil]
81
+ fun = proc { |d| [d.name] }
82
+ end
83
+
84
+ format_table(ds, head) do |d|
85
+ if cli[:exec]
86
+ MiGA::MiGA.run_cmd(
87
+ cli[:exec].miga_variables(dataset: d.name, project: p.path)
88
+ )
89
+ end
90
+ fun[d]
72
91
  end
73
92
  end
74
93
 
data/lib/miga/cli/base.rb CHANGED
@@ -1,5 +1,4 @@
1
- # @package MiGA
2
- # @license Artistic-2.0
1
+ # frozen_string_literal: true
3
2
 
4
3
  module MiGA::Cli::Base
5
4
  @@TASK_DESC = {
@@ -20,10 +19,10 @@ module MiGA::Cli::Base
20
19
  add: 'Create a dataset in a MiGA project',
21
20
  get: 'Download a dataset from public databases into a MiGA project',
22
21
  ncbi_get: 'Download all genomes in a taxon from NCBI into a MiGA project',
23
- rm: 'Remove a dataset from an MiGA project',
22
+ rm: 'Remove a dataset from a MiGA project',
24
23
  find: 'Find unregistered datasets based on result files',
25
24
  ln: 'Link datasets (including results) from one project to another',
26
- ls: 'List all registered datasets in an MiGA project',
25
+ ls: 'List all registered datasets in a MiGA project',
27
26
  archive: 'Generate a tar-ball with all files from select datasets',
28
27
  # Results
29
28
  add_result: 'Register a result',
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tempfile'
2
4
 
3
5
  ##
@@ -37,13 +39,13 @@ module MiGA::Common::Format
37
39
  tmp_path = tmp_fh.path
38
40
  fh = File.open(file, 'r')
39
41
  end
40
- buffer = ''
42
+ buffer = ''.dup
41
43
  fh.each_line do |ln|
42
44
  ln.chomp!
43
45
  if ln =~ /^>\s*(\S+)(.*)/
44
46
  id, df = $1, $2
45
47
  tmp_fh.print buffer.wrap_width(80)
46
- buffer = ''
48
+ buffer = ''.dup
47
49
  tmp_fh.puts ">#{id.gsub(/[^A-Za-z0-9_\|\.]/, '_')}#{df}"
48
50
  else
49
51
  buffer << ln.gsub(/[^A-Za-z\.\-]/, '')
@@ -165,7 +167,7 @@ class String
165
167
  ##
166
168
  # Replace {{variables}} using the +vars+ hash
167
169
  def miga_variables(vars)
168
- o = "#{self}"
170
+ o = self.dup
169
171
  vars.each { |k, v| o.gsub!("{{#{k}}}", v.to_s) }
170
172
  o
171
173
  end
data/lib/miga/common.rb CHANGED
@@ -1,5 +1,4 @@
1
- # @package MiGA
2
- # @license Artistic-2.0
1
+ # frozen_string_literal: true
3
2
 
4
3
  require 'zlib'
5
4
  require 'stringio'
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.2, 0, 1].freeze
15
+ VERSION = [1.2, 1, 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(2021, 12, 11)
23
+ VERSION_DATE = Date.new(2021, 12, 12)
24
24
 
25
25
  ##
26
26
  # References of MiGA
data/test/format_test.rb CHANGED
@@ -58,6 +58,9 @@ class FormatTest < Test::Unit::TestCase
58
58
  assert_equal(50.0, o[:gc])
59
59
  assert_equal(5, o[:n50])
60
60
  assert_equal(4.0, o[:med])
61
+ o = MiGA::MiGA.seqs_length(f, :fasta, skew: true)
62
+ assert_equal(-50.0, o[:at_skew])
63
+ assert_equal(-25.0, o[:gc_skew])
61
64
  end
62
65
 
63
66
  def test_seqs_length_fastq
@@ -77,4 +80,22 @@ class FormatTest < Test::Unit::TestCase
77
80
  assert_equal('123 45', tab[2])
78
81
  assert_equal('678 90', tab[3])
79
82
  end
83
+
84
+ def test_miga_name
85
+ assert_not('a-bad-name'.miga_name?)
86
+ assert('a_good_one'.miga_name?)
87
+
88
+ assert('After_it_s_fixed_', 'After it\'s fixed!'.miga_name)
89
+
90
+ assert('A sp.', 'A_sp_'.unmiga_name)
91
+ assert('B str. C', 'B_sp_C'.unmiga_name)
92
+ assert('The X content', 'The_x_content'.unmiga_name)
93
+ end
94
+
95
+ def test_miga_variables
96
+ assert_equal(
97
+ '1 a box!',
98
+ '{{n}} {{my}} {{secret}}!'.miga_variables(my: 'a', secret: :box, n: 1)
99
+ )
100
+ end
80
101
  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: 1.2.0.1
4
+ version: 1.2.1.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: 2021-12-11 00:00:00.000000000 Z
11
+ date: 2021-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons