miga-base 0.2.2.2 → 0.2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 569b4e7cff6063f23d5c76445ce5fe8379c152bd
4
- data.tar.gz: 9ea1a8bff35874d39a27eb0544e4f9b262441368
3
+ metadata.gz: 08a4a7fe880fa3b6653122e96d4e25fc39832020
4
+ data.tar.gz: 9a154fe5ec29b9b4bcb56cf01f11eb9a5ce77e3a
5
5
  SHA512:
6
- metadata.gz: 0eda211778880b2dcaca0b5504ce560aeed3f7f4d420e0c127019ce86f68511e67af329aa920ab0816460c8730eed8cb0f46f6b12debf637ce8e95891d670cf0
7
- data.tar.gz: 22d7016022c1d63d848b8046ca8899dbf95bf22fa132613783f9c1b72ca0e289e1ce653a5b300824eeb64697354bbdbc705950db8b147604e38318e0456811d6
6
+ metadata.gz: 19b8971dca597bc26a30cefc6b4c9973774a54cfd104ca5f45c8cea844205a01f58370556457426621009e7c7bfbc1c3f28afad93ff76fe818514b392b1fcaa0
7
+ data.tar.gz: ed05189ab71cbe8f8721dd7b584441cc3bf338a2746be46a08aeb1550545a9261c5d86f4d7133f99c5b6d4237fe975353832d7516400cbd1e3c037aef8d6bf38
@@ -23,6 +23,22 @@ OptionParser.new do |opt|
23
23
  opt.on("--update",
24
24
  "Updates the dataset if it already exists."){ o[:update]=true }
25
25
  opt_common(opt, o)
26
+ opt.separator ""
27
+ opt.separator "External input data"
28
+ opt.on("--raw-reads FILE1,FILE2", Array,
29
+ "Comma-delimited paths to the raw reads in FastQ format.",
30
+ "One file is assumed to be single reads, two are assumed to be paired."
31
+ ){ |v| o[:raw_reads] = v }
32
+ opt.on("--trimmed-fasta-single FILE", Array,
33
+ "Path to the single trimmed reads in FastA format."
34
+ ){ |v| o[:trimmed_fasta_s] = v }
35
+ opt.on("--trimmed-fasta-coupled FILE1,FILE2", Array,
36
+ "Comma-delimited paths to the coupled trimmed reads in FastA format.",
37
+ "One file is assumed to be interposed, two are assumed to contain sisters."
38
+ ){ |v| o[:trimmed_fasta_c] = v }
39
+ opt.on("--assembly FILE", Array,
40
+ "Path to the contigs (or scaffolds) of the assembly in FastA format."
41
+ ){ |v| o[:assembly] = v }
26
42
  end.parse!
27
43
 
28
44
  ##=> Main <=
@@ -38,16 +54,39 @@ $stderr.puts "Loading dataset." unless o[:q]
38
54
  d = o[:update] ? p.dataset(o[:dataset]) :
39
55
  MiGA::Dataset.new(p, o[:dataset], o[:ref], {})
40
56
  raise "Dataset does not exist." if d.nil?
57
+
58
+ in_files = [:raw_reads, :trimmed_fasta_s, :trimmed_fasta_c, :assembly]
59
+ def cp_result(o, d, p, sym, res_sym, ext)
60
+ return if o[sym].nil? or o[sym].empty?
61
+ r_dir = MiGA::Dataset.RESULT_DIRS[res_sym]
62
+ r_path = File.expand_path("data/#{r_dir}/#{d.name}", p.path)
63
+ ext.each_index do |i|
64
+ FileUtils.cp o[sym][i], "#{r_path}#{ext[i]}" unless o[sym][i].nil?
65
+ end
66
+ File.open("#{r_path}.done", "w") { |f| f.print Time.now.to_s }
67
+ end
68
+ if in_files.any? { |i| not o[i].nil? }
69
+ $stderr.puts "Copying files." unless o[:q]
70
+ # :raw_reads
71
+ cp_result(o, d, p, :raw_reads, :raw_reads, %w[.1.fastq .2.fastq])
72
+ # :trimmed_fasta
73
+ cp_result(o, d, p, :trimmed_fasta_s, :trimmed_fasta, %w[.SingleReads.fa])
74
+ if (o[:trimmed_fasta_c] || []).size > 1
75
+ cp_result(o, d, p, :trimmed_fasta_c, :trimmed_fasta, %w[.1.fasta .2.fasta])
76
+ else
77
+ cp_result(o, d, p, :trimmed_fasta_c, :trimmed_fasta, %w[.CoupledReads.fa])
78
+ end
79
+ # :assembly
80
+ cp_result(o, d, p, :assembly, :assembly, %w[.LargeContigs.fna])
81
+ end
82
+
41
83
  unless o[:metadata].nil?
42
84
  o[:metadata].split(",").each do |pair|
43
85
  (k,v) = pair.split("=")
44
86
  case v
45
- when "true"
46
- v = true
47
- when "false"
48
- v = false
49
- when "nil"
50
- v = nil
87
+ when "true"; v = true
88
+ when "false"; v = false
89
+ when "nil"; v = nil
51
90
  end
52
91
  d.metadata[k] = v
53
92
  end
data/actions/daemon.rb CHANGED
@@ -32,10 +32,10 @@ OptionParser.new do |opt|
32
32
  opt_common(opt, o)
33
33
  opt.separator "Daemon options:"
34
34
  opt.on("-t", "--ontop",
35
- "Stay on top (does not daemonize)"){ o[:daemon_opts] << '-t' }
36
- opt.on("-f", "--force", "Force operation"){ o[:daemon_opts] << '-f' }
35
+ "Stay on top (does not daemonize)."){ o[:daemon_opts] << '-t' }
36
+ opt.on("-f", "--force", "Force operation."){ o[:daemon_opts] << '-f' }
37
37
  opt.on("-n", "--no_wait",
38
- "Do not wait for processes to stop"){ o[:daemon_opts] << '-n' }
38
+ "Do not wait for processes to stop."){ o[:daemon_opts] << '-n' }
39
39
  opt.on("--shush", "Silence the daemon."){ o[:daemon_opts] << '--shush' }
40
40
  end.parse!
41
41
 
@@ -3,12 +3,17 @@
3
3
  # @package MiGA
4
4
  # @license Artistic-2.0
5
5
 
6
- o = {q:true}
6
+ o = {q:true, try_load:false}
7
7
  opts = OptionParser.new do |opt|
8
8
  opt_banner(opt)
9
9
  opt_object(opt, o, [:project, :dataset_opt, :result])
10
+ opt.on("--key STRING",
11
+ "Returns only the value of the requested key."){ |v| o[:key] = v }
10
12
  opt.on("--compute-and-save",
11
13
  "Computes and saves the statistics."){ |v| o[:compute] = v }
14
+ opt.on("--try-load",
15
+ "Checks if stat exists instead of computing on --compute-and-save."
16
+ ){ |v| o[:try_load] = v }
12
17
  opt_common(opt, o)
13
18
  end.parse!
14
19
 
@@ -29,6 +34,9 @@ else
29
34
  end
30
35
  raise "Cannot load result." if r.nil?
31
36
 
37
+ o[:compute] = false if o[:try_load] and
38
+ (not r[:stats].nil?) and (not r[:stats].empty?)
39
+
32
40
  if o[:compute]
33
41
  $stderr.puts "Computing statistics." unless o[:q]
34
42
  stats = {}
@@ -78,8 +86,14 @@ if o[:compute]
78
86
  end
79
87
  end
80
88
 
81
- r[:stats].each do |k,v|
82
- puts "#{k.to_s.unmiga_name.capitalize}: #{v.is_a?(Array) ? v.join(" ") : v}."
89
+ if o[:key].nil?
90
+ r[:stats].each do |k,v|
91
+ puts "#{k.to_s.unmiga_name.capitalize}: #{
92
+ v.is_a?(Array) ? v.join(" ") : v}."
93
+ end
94
+ else
95
+ v = r[:stats][o[:key].downcase.miga_name.to_sym]
96
+ puts v.is_a?(Array) ? v.first : v
83
97
  end
84
98
 
85
99
  $stderr.puts "Done." unless o[:q]
data/lib/miga/daemon.rb CHANGED
@@ -244,7 +244,7 @@ class MiGA::Daemon < MiGA::MiGA
244
244
  check_datasets
245
245
  check_project
246
246
  flush!
247
- if loop_i==12
247
+ if loop_i==4
248
248
  say "Housekeeping for sanity"
249
249
  @loop_i = 0
250
250
  purge!
@@ -25,6 +25,7 @@ module MiGA::DatasetResult
25
25
  {:pair1=>".1.clipped.fastq", :pair2=>".2.clipped.fastq"}) if
26
26
  result_files_exist?(base, ".2.clipped.fastq")
27
27
  r.add_file(:single, name + ".1.clipped.single.fastq")
28
+ r.add_file(:trimming_sumary, name + ".1.fastq.trimmed.summary.txt")
28
29
  add_result(:raw_reads) #-> Post gunzip
29
30
  r
30
31
  end
@@ -60,7 +61,7 @@ module MiGA::DatasetResult
60
61
  return nil unless result_files_exist?(base, ".LargeContigs.fna")
61
62
  r = MiGA::Result.new(base + ".json")
62
63
  r = add_files_to_ds_result(r, name, {:largecontigs=>".LargeContigs.fna",
63
- :allcontigs=>".AllContigs.fna"})
64
+ :allcontigs=>".AllContigs.fna", :assembly_data=>""})
64
65
  add_result(:trimmed_fasta) #-> Post interposing
65
66
  r
66
67
  end
data/lib/miga/project.rb CHANGED
@@ -2,11 +2,14 @@
2
2
  # @license Artistic-2.0
3
3
 
4
4
  require "miga/dataset"
5
+ require "miga/project_result"
5
6
 
6
7
  ##
7
8
  # MiGA representation of a project.
8
9
  class MiGA::Project < MiGA::MiGA
9
10
 
11
+ include MiGA::ProjectResult
12
+
10
13
  # Class-level
11
14
 
12
15
  ##
@@ -365,62 +368,4 @@ class MiGA::Project < MiGA::MiGA
365
368
  plugins.each { |pl| require File.expand_path("lib-plugin.rb", pl) }
366
369
  end
367
370
 
368
- private
369
-
370
- ##
371
- # Internal alias for all add_result_*_distances.
372
- def add_result_distances(base)
373
- return nil unless result_files_exist?(base, %w[.Rdata .log .txt])
374
- r = Result.new(base + ".json")
375
- r.add_file(:rdata, "miga-project.Rdata")
376
- r.add_file(:matrix, "miga-project.txt")
377
- r.add_file(:log, "miga-project.log")
378
- r.add_file(:hist, "miga-project.hist")
379
- r
380
- end
381
-
382
- def add_result_clade_finding(base)
383
- return nil unless result_files_exist?(base,
384
- %w[.proposed-clades])
385
- return nil unless is_clade? or result_files_exist?(base,
386
- %w[.pdf .classif .medoids .class.tsv .class.nwk])
387
- r = add_result_iter_clades(base)
388
- r.add_file(:aai_tree, "miga-project.aai.nwk")
389
- r.add_file(:proposal, "miga-project.proposed-clades")
390
- r.add_file(:clades_aai90, "miga-project.aai90-clades")
391
- r.add_file(:clades_ani95, "miga-project.ani95-clades")
392
- r
393
- end
394
-
395
- def add_result_subclades(base)
396
- return nil unless result_files_exist?(base,
397
- %w[.pdf .classif .medoids .class.tsv .class.nwk])
398
- r = add_result_iter_clades(base)
399
- r.add_file(:ani_tree, "miga-project.ani.nwk")
400
- r
401
- end
402
-
403
- def add_result_iter_clades(base)
404
- r = Result.new(base + ".json")
405
- r.add_file(:report, "miga-project.pdf")
406
- r.add_file(:class_table, "miga-project.class.tsv")
407
- r.add_file(:class_tree, "miga-project.class.nwk")
408
- r.add_file(:classif, "miga-project.classif")
409
- r.add_file(:medoids, "miga-project.medoids")
410
- r
411
- end
412
-
413
- def add_result_ogs(base)
414
- return nil unless result_files_exist?(base, %w[.ogs .stats])
415
- r = Result.new(base + ".json")
416
- r.add_file(:ogs, "miga-project.ogs")
417
- r.add_file(:stats, "miga-project.stats")
418
- r.add_file(:rbm, "miga-project.rbm")
419
- r
420
- end
421
-
422
- alias add_result_haai_distances add_result_distances
423
- alias add_result_aai_distances add_result_distances
424
- alias add_result_ani_distances add_result_distances
425
- alias add_result_ssu_distances add_result_distances
426
371
  end
@@ -0,0 +1,67 @@
1
+ # @package MiGA
2
+ # @license Artistic-2.0
3
+
4
+ ##
5
+ # Helper module including specific functions to add project results.
6
+ module MiGA::ProjectResult
7
+
8
+ private
9
+
10
+ ##
11
+ # Internal alias for all add_result_*_distances.
12
+ def add_result_distances(base)
13
+ return nil unless result_files_exist?(base, %w[.Rdata .log .txt])
14
+ r = Result.new(base + ".json")
15
+ r.add_file(:rdata, "miga-project.Rdata")
16
+ r.add_file(:matrix, "miga-project.txt")
17
+ r.add_file(:log, "miga-project.log")
18
+ r.add_file(:hist, "miga-project.hist")
19
+ r
20
+ end
21
+
22
+ def add_result_clade_finding(base)
23
+ return nil unless result_files_exist?(base,
24
+ %w[.proposed-clades])
25
+ return nil unless is_clade? or result_files_exist?(base,
26
+ %w[.pdf .classif .medoids .class.tsv .class.nwk])
27
+ r = add_result_iter_clades(base)
28
+ r.add_file(:aai_tree, "miga-project.aai.nwk")
29
+ r.add_file(:proposal, "miga-project.proposed-clades")
30
+ r.add_file(:clades_aai90, "miga-project.aai90-clades")
31
+ r.add_file(:clades_ani95, "miga-project.ani95-clades")
32
+ r
33
+ end
34
+
35
+ def add_result_subclades(base)
36
+ return nil unless result_files_exist?(base,
37
+ %w[.pdf .classif .medoids .class.tsv .class.nwk])
38
+ r = add_result_iter_clades(base)
39
+ r.add_file(:ani_tree, "miga-project.ani.nwk")
40
+ r
41
+ end
42
+
43
+ def add_result_iter_clades(base)
44
+ r = Result.new(base + ".json")
45
+ r.add_file(:report, "miga-project.pdf")
46
+ r.add_file(:class_table, "miga-project.class.tsv")
47
+ r.add_file(:class_tree, "miga-project.class.nwk")
48
+ r.add_file(:classif, "miga-project.classif")
49
+ r.add_file(:medoids, "miga-project.medoids")
50
+ r
51
+ end
52
+
53
+ def add_result_ogs(base)
54
+ return nil unless result_files_exist?(base, %w[.ogs .stats])
55
+ r = Result.new(base + ".json")
56
+ r.add_file(:ogs, "miga-project.ogs")
57
+ r.add_file(:stats, "miga-project.stats")
58
+ r.add_file(:rbm, "miga-project.rbm")
59
+ r
60
+ end
61
+
62
+ alias add_result_haai_distances add_result_distances
63
+ alias add_result_aai_distances add_result_distances
64
+ alias add_result_ani_distances add_result_distances
65
+ alias add_result_ssu_distances add_result_distances
66
+
67
+ end
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.2, 2, 2]
13
+ VERSION = [0.2, 3, 0]
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.new(2016, 8, 31)
21
+ VERSION_DATE = Date.new(2017, 3, 14)
22
22
 
23
23
  ##
24
24
  # Reference of MiGA.
@@ -16,11 +16,11 @@ fi
16
16
  fx_exists miga-make_empty_aai_db || function miga-make_empty_aai_db {
17
17
  local DB=$1
18
18
  echo "create table if not exists aai(seq1 varchar(256), seq2 varchar(256)," \
19
- " aai float, sd float, n int, omega int);" | sqlite3 $DB
19
+ " aai float, sd float, n int, omega int);" | sqlite3 "$DB"
20
20
  }
21
21
 
22
22
  fx_exists miga-ds_name || function miga-ds_name {
23
- basename $1 | perl -pe "s/[^A-Za-z0-9_].*//"
23
+ basename "$1" | perl -pe "s/[^A-Za-z0-9_].*//"
24
24
  }
25
25
 
26
26
  fx_exists miga-aai || function miga-aai {
@@ -28,10 +28,10 @@ fx_exists miga-aai || function miga-aai {
28
28
  local F2=$2
29
29
  local TH=$3
30
30
  local DB=$4
31
- local N1=$(miga-ds_name $F1)
32
- local N2=$(miga-ds_name $F2)
33
- aai.rb -1 $F1 -2 $F2 -t $TH -a --lookup-first -S $DB --name1 $N1 --name2 $N2 \
34
- --$MIGA_AAI_SAVE_RBM || echo "0"
31
+ local N1=$(miga-ds_name "$F1")
32
+ local N2=$(miga-ds_name "$F2")
33
+ aai.rb -1 "$F1" -2 "$F2" -t "$TH" -a --lookup-first -S "$DB" --name1 "$N1" \
34
+ --name2 "$N2" --$MIGA_AAI_SAVE_RBM || echo "0"
35
35
  }
36
36
 
37
37
  fx_exists miga-ani || function miga-ani {
@@ -39,10 +39,10 @@ fx_exists miga-ani || function miga-ani {
39
39
  local F2=$2
40
40
  local TH=$3
41
41
  local DB=$4
42
- local N1=$(miga-ds_name $F1)
43
- local N2=$(miga-ds_name $F2)
44
- ani.rb -1 $F1 -2 $F2 -t $TH -a --no-save-regions --no-save-rbm \
45
- --lookup-first -S $DB --name1 $N1 --name2 $N2 || echo "0"
42
+ local N1=$(miga-ds_name "$F1")
43
+ local N2=$(miga-ds_name "$F2")
44
+ ani.rb -1 "$F1" -2 "$F2" -t "$TH" -a --no-save-regions --no-save-rbm \
45
+ --lookup-first -S "$DB" --name1 "$N1" --name2 "$N2" || echo "0"
46
46
  }
47
47
 
48
48
  fx_exists miga-haai || function miga-haai {
@@ -51,14 +51,14 @@ fx_exists miga-haai || function miga-haai {
51
51
  local TH=$3
52
52
  local DB=$4
53
53
  local AAI_DB=$5
54
- local N1=$(miga-ds_name $F1)
55
- local N2=$(miga-ds_name $F2)
56
- local HAAI=$(MIGA_AAI_SAVE_RBM="no-save-rbm" miga-aai $F1 $F2 $TH $DB)
54
+ local N1=$(miga-ds_name "$F1")
55
+ local N2=$(miga-ds_name "$F2")
56
+ local HAAI=$(MIGA_AAI_SAVE_RBM="no-save-rbm" miga-aai "$F1" "$F2" "$TH" "$DB")
57
57
  if [[ "$HAAI" != "" && $(perl -e "print 1 if '$HAAI' <= 90") == "1" ]] ; then
58
58
  local AAI=$(perl -e "print (100-exp(2.435076 + 0.4275193*log(100-$HAAI)))")
59
- [[ ! -s $AAI_DB ]] && make_empty_aai_db $AAI_DB
60
- echo "insert into aai values('$N1','$N2','$AAI',0,0,0);" | sqlite3 $AAI_DB
61
- echo $AAI
59
+ [[ ! -s $AAI_DB ]] && make_empty_aai_db "$AAI_DB"
60
+ echo "insert into aai values('$N1','$N2','$AAI',0,0,0);" | sqlite3 "$AAI_DB"
61
+ echo "$AAI"
62
62
  fi
63
63
  }
64
64
 
@@ -70,9 +70,9 @@ fx_exists miga-haai_or_aai || function miga-haai_or_aai {
70
70
  local F2=$5
71
71
  local DB=$6
72
72
  local TH=$7
73
- AAI=$(miga-haai $FH1 $FH2 $TH $DBH $DB)
74
- [[ "${AAI%.*}" -le 0 ]] && AAI=$(miga-aai $F1 $F2 $TH $DB)
75
- echo $AAI
73
+ AAI=$(miga-haai "$FH1" "$FH2" "$TH" "$DBH" "$DB")
74
+ [[ "${AAI%.*}" -le 0 ]] && AAI=$(miga-aai "$F1" "$F2" "$TH" "$DB")
75
+ echo "$AAI"
76
76
  }
77
77
 
78
78
  fx_exists miga-val_from_db || function miga-val_from_db {
@@ -82,14 +82,14 @@ fx_exists miga-val_from_db || function miga-val_from_db {
82
82
  local MT=$4
83
83
  if [[ -s $DB ]] ; then
84
84
  echo "select $MT from $MT where seq1='$N1' and seq2='$N2';" \
85
- | sqlite3 $DB || echo 0
85
+ | sqlite3 "$DB" || echo 0
86
86
  fi
87
87
  }
88
88
 
89
89
  fx_exists miga-aai_from_db || function miga-aai_from_db {
90
- miga-val_from_db $1 $2 $3 aai
90
+ miga-val_from_db "$1" "$2" "$3" aai
91
91
  }
92
92
 
93
93
  fx_exists miga-ani_from_db || function miga-ani_from_db {
94
- miga-val_from_db $1 $2 $3 ani
94
+ miga-val_from_db "$1" "$2" "$3" ani
95
95
  }
@@ -5,9 +5,9 @@
5
5
  set -e
6
6
 
7
7
  # Deal with previous runs (if any)
8
- exists $DATASET.haai.db && cp $DATASET.haai.db $TMPDIR
9
- exists $DATASET.a[an]i.db && cp $DATASET.a[an]i.db $TMPDIR
10
- exists $DATASET.a[an]i.9[05] && rm $DATASET.a[an]i.9[05]
8
+ exists "$DATASET".haai.db && cp "$DATASET".haai.db "$TMPDIR"
9
+ exists "$DATASET".a[an]i.db && cp "$DATASET".a[an]i.db "$TMPDIR"
10
+ exists "$DATASET".a[an]i.9[05] && rm "$DATASET".a[an]i.9[05]
11
11
  N=0
12
12
  fx_exists miga-checkpoint_n || function miga-checkpoint_n {
13
13
  let N=$N+1
@@ -15,9 +15,9 @@ fx_exists miga-checkpoint_n || function miga-checkpoint_n {
15
15
  for metric in haai aai ani ; do
16
16
  if [[ -s $TMPDIR/$DATASET.$metric.db ]] ; then
17
17
  echo "select count(*) from ${metric#h};" \
18
- | sqlite3 $TMPDIR/$DATASET.$metric.db \
18
+ | sqlite3 "$TMPDIR/$DATASET.$metric.db" \
19
19
  >/dev/null || exit 1
20
- cp $TMPDIR/$DATASET.$metric.db .
20
+ cp "$TMPDIR/$DATASET.$metric.db" .
21
21
  fi
22
22
  done
23
23
  N=0
@@ -28,18 +28,18 @@ fx_exists miga-noref_haai_or_aai || function miga-noref_haai_or_aai {
28
28
  local Q=$1
29
29
  local S=$2
30
30
  [[ -s $TMPDIR/$Q.faa ]] \
31
- || cp ../06.cds/$Q.faa $TMPDIR/$Q.faa
32
- miga-haai_or_aai $ESS/$Q.ess.faa $ESS/$S.ess.faa $TMPDIR/$Q.haai.db \
33
- $TMPDIR/$Q.faa ../06.cds/$S.faa $TMPDIR/$Q.aai.db $CORES
31
+ || cp "../06.cds/$Q.faa" "$TMPDIR/$Q.faa"
32
+ miga-haai_or_aai "$ESS/$Q.ess.faa" "$ESS/$S.ess.faa" "$TMPDIR/$Q.haai.db" \
33
+ "$TMPDIR/$Q.faa" "../06.cds/$S.faa" "$TMPDIR/$Q.aai.db" "$CORES"
34
34
  }
35
35
 
36
36
  fx_exists miga-noref_ani || function miga-noref_ani {
37
37
  local Q=$1
38
38
  local S=$2
39
39
  [[ -s $TMPDIR/$Q.LargeContigs.fna ]] \
40
- || cp ../05.assembly/$Q.LargeContigs.fna $TMPDIR/$Q.LargeContigs.fna
41
- miga-ani $TMPDIR/$Q.LargeContigs.fna ../05.assembly/$S.LargeContigs.fna \
42
- $CORES $TMPDIR/$Q.ani.db
40
+ || cp ../05.assembly/$Q.LargeContigs.fna "$TMPDIR/$Q.LargeContigs.fna"
41
+ miga-ani "$TMPDIR/$Q.LargeContigs.fna" "../05.assembly/$S.LargeContigs.fna" \
42
+ "$CORES" "$TMPDIR/$Q.ani.db"
43
43
  }
44
44
 
45
45
 
@@ -63,12 +63,12 @@ while [[ -e "$CLADES/$CLASSIF/miga-project.medoids" ]] ; do
63
63
  VAL_MED=""
64
64
  VAL_CLS=""
65
65
  i_n=0
66
- for i in $(cat "$CLADES/$CLASSIF/miga-project.medoids") ; do
66
+ while read i ; do
67
67
  let i_n=$i_n+1
68
68
  if [[ $METRIC == "aai" ]] ; then
69
- VAL=$(miga-noref_haai_or_aai $DATASET $i)
69
+ VAL=$(miga-noref_haai_or_aai "$DATASET" "$i")
70
70
  else
71
- VAL=$(miga-noref_ani $DATASET $i)
71
+ VAL=$(miga-noref_ani "$DATASET" "$i")
72
72
  fi
73
73
  miga-checkpoint_n
74
74
  if [[ $(perl -e "print 1 if '$VAL' >= '$MAX_VAL'") == "1" ]] ; then
@@ -77,7 +77,7 @@ while [[ -e "$CLADES/$CLASSIF/miga-project.medoids" ]] ; do
77
77
  VAL_CLS=$i_n
78
78
  echo "[$CLASSIF] New max: $VAL_MED ($VAL_CLS): $MAX_VAL"
79
79
  fi
80
- done
80
+ done < "$CLADES/$CLASSIF/miga-project.medoids"
81
81
  CLASSIF="$CLASSIF/miga-project.sc-$VAL_CLS"
82
82
  echo "$VAL_CLS $VAL_MED $MAX_VAL $CLASSIF" \
83
83
  >> "$DATASET.$METRIC-medoids.tsv"
@@ -87,17 +87,17 @@ done
87
87
  if [[ "$CLASSIF" != "." ]] ; then
88
88
  PAR=$(dirname "$CLADES/$CLASSIF")/miga-project.classif
89
89
  if [[ -s "$PAR" ]] ; then
90
- for i in $(cat "$PAR" | awk "\$2==$VAL_CLS{print \$1}") ; do
90
+ while read i ; do
91
91
  if [[ $METRIC == "aai" ]] ; then
92
- AAI=$(miga-noref_haai_or_aai $DATASET $i)
92
+ AAI=$(miga-noref_haai_or_aai "$DATASET" "$i")
93
93
  else
94
94
  AAI=100
95
95
  fi
96
96
  if [[ $(perl -e "print 1 if '$AAI' >= 90") == "1" ]] ; then
97
- miga-noref_ani $DATASET $i
97
+ miga-noref_ani "$DATASET" "$i"
98
98
  fi
99
99
  miga-checkpoint_n
100
- done
100
+ done < <(awk "\$2==$VAL_CLS{print \$1}" < "$PAR")
101
101
  fi
102
102
  fi
103
103
 
@@ -11,9 +11,9 @@ fx_exists miga-checkpoint_n || function miga-checkpoint_n {
11
11
  tab="aai"
12
12
  [[ "$t" == "03.ani" ]] && tab="ani"
13
13
  echo "select count(*) from $tab;" \
14
- | sqlite3 $TMPDIR/$t.db \
14
+ | sqlite3 "$TMPDIR/$t.db" \
15
15
  >/dev/null || exit 1
16
- cp $TMPDIR/$t.db $t/$DATASET.db
16
+ cp "$TMPDIR/$t.db" "$t/$DATASET.db"
17
17
  fi
18
18
  done
19
19
  N=0
@@ -25,7 +25,7 @@ ESS="../07.annotation/01.function/01.essential"
25
25
 
26
26
  # Initialize temporals
27
27
  for t in 01.haai 02.aai 03.ani ; do
28
- [[ -s $t/$DATASET.db ]] && cp $t/$DATASET.db $TMPDIR/$t.db
28
+ [[ -s $t/$DATASET.db ]] && cp "$t/$DATASET.db" "$TMPDIR/$t.db"
29
29
  done
30
30
  N=1
31
31
 
@@ -36,38 +36,40 @@ for i in $(miga list_datasets -P "$PROJECT" --ref --no-multi) ; do
36
36
  # Check if the i-th dataset is ready
37
37
  [[ -s $ESS/$i.done && -s $ESS/$i.json ]] || continue
38
38
  # Check if this is done (e.g., in a previous failed iteration)
39
- AAI=$(miga-aai_from_db $DATASET $i $TMPDIR/02.aai.db)
39
+ AAI=$(miga-aai_from_db "$DATASET" "$i" "$TMPDIR/02.aai.db")
40
40
  # Try the other direction
41
- [[ "${AAI%.*}" -le 0 ]] && AAI=$(miga-aai_from_db $i $DATASET 02.aai/$i.db)
41
+ [[ "${AAI%.*}" -le 0 ]] \
42
+ && AAI=$(miga-aai_from_db "$i" "$DATASET" "02.aai/$i.db")
42
43
  # Try with hAAI
43
44
  if [[ "${AAI%.*}" -le 0 ]] ; then
44
45
  [[ -e "$TMPDIR/$DATASET.ess.faa" ]] \
45
- || cp $ESS/$DATASET.ess.faa $TMPDIR/$DATASET.ess.faa
46
- AAI=$(miga-haai $TMPDIR/$DATASET.ess.faa $ESS/$i.ess.faa \
47
- $CORES $TMPDIR/01.haai.db $TMPDIR/02.aai.db)
46
+ || cp "$ESS/$DATASET.ess.faa" "$TMPDIR/$DATASET.ess.faa"
47
+ AAI=$(miga-haai "$TMPDIR/$DATASET.ess.faa" "$ESS/$i.ess.faa" \
48
+ "$CORES" "$TMPDIR/01.haai.db" "$TMPDIR/02.aai.db")
48
49
  fi
49
50
  # Try with complete AAI
50
51
  if [[ "${AAI%.*}" -le 0 ]] ; then
51
52
  [[ -e "$TMPDIR/$DATASET.faa" ]] \
52
- || cp ../06.cds/$DATASET.faa $TMPDIR/$DATASET.faa
53
- AAI=$(miga-aai $TMPDIR/$DATASET.faa ../06.cds/$i.faa \
54
- $CORES $TMPDIR/02.aai.db)
53
+ || cp "../06.cds/$DATASET.faa" "$TMPDIR/$DATASET.faa"
54
+ AAI=$(miga-aai "$TMPDIR/$DATASET.faa" "../06.cds/$i.faa" \
55
+ "$CORES" "$TMPDIR/02.aai.db")
55
56
  fi
56
57
  # Check if ANI is meaningful
57
58
  if [[ -e "../05.assembly/$DATASET.LargeContigs.fna" \
58
59
  && -e "../05.assembly/$i.LargeContigs.fna" \
59
60
  && $(perl -e "print 1 if '$AAI' >= 90") == "1" ]] ; then
60
61
  # Check if this is done (e.g., in a previous failed iteration)
61
- ANI=$(miga-ani_from_db $DATASET $i $TMPDIR/03.ani.db)
62
+ ANI=$(miga-ani_from_db "$DATASET" "$i" "$TMPDIR/03.ani.db")
62
63
  # Try the other direction
63
- [[ "${ANI%.*}" -le 0 ]] && ANI=$(miga-ani_from_db $i $DATASET 03.ani/$i.db)
64
+ [[ "${ANI%.*}" -le 0 ]] \
65
+ && ANI=$(miga-ani_from_db "$i" "$DATASET" "03.ani/$i.db")
64
66
  # Calculate it
65
67
  if [[ "${ANI%.*}" -le 0 ]] ; then
66
68
  [[ -e "$TMPDIR/$DATASET.LargeContigs.fna" ]] \
67
- || cp ../05.assembly/$DATASET.LargeContigs.fna \
68
- $TMPDIR/$DATASET.LargeContigs.fna
69
- ANI=$(miga-ani $TMPDIR/$DATASET.LargeContigs.fna \
70
- ../05.assembly/$i.LargeContigs.fna $CORES $TMPDIR/03.ani.db)
69
+ || cp "../05.assembly/$DATASET.LargeContigs.fna" \
70
+ "$TMPDIR/$DATASET.LargeContigs.fna"
71
+ ANI=$(miga-ani "$TMPDIR/$DATASET.LargeContigs.fna" \
72
+ "../05.assembly/$i.LargeContigs.fna" "$CORES" "$TMPDIR/03.ani.db")
71
73
  fi
72
74
  fi
73
75
  miga-checkpoint_n
data/test/daemon_test.rb CHANGED
@@ -57,8 +57,8 @@ class DaemonTest < Test::Unit::TestCase
57
57
  end
58
58
  assert_equal(DateTime, d.last_alive.class)
59
59
  assert(out.string =~ /-{20}\n.*MiGA:#{p.name} launched/)
60
- 10.times{ d.in_loop }
61
- assert_equal(11, d.loop_i)
60
+ 2.times{ d.in_loop }
61
+ assert_equal(3, d.loop_i)
62
62
  out = capture_stdout do
63
63
  d.in_loop
64
64
  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.2.2.2
4
+ version: 0.2.3.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: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2017-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client
@@ -94,6 +94,7 @@ files:
94
94
  - lib/miga/dataset_result.rb
95
95
  - lib/miga/metadata.rb
96
96
  - lib/miga/project.rb
97
+ - lib/miga/project_result.rb
97
98
  - lib/miga/remote_dataset.rb
98
99
  - lib/miga/result.rb
99
100
  - lib/miga/tax_dist.rb
@@ -191,8 +192,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  version: '0'
192
193
  requirements: []
193
194
  rubyforge_project:
194
- rubygems_version: 2.0.14
195
+ rubygems_version: 2.0.14.1
195
196
  signing_key:
196
197
  specification_version: 4
197
198
  summary: MiGA
198
199
  test_files: []
200
+ has_rdoc: true