miga-base 1.2.2.2 → 1.2.2.3

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: 4b1fb93676b3b4c48d2204f48a106575274ee50ab294bbf34a3790e7c9adb94b
4
- data.tar.gz: 629d74fd9c861b9afc99c9764b1990e8ea8c9b89e5d10780201828fd68ab3c7c
3
+ metadata.gz: 3b3fd16e90667560b5cba41046eb92613187279fd7194d1825cc3dee9690273d
4
+ data.tar.gz: 84043b09c234b825ba0b89ca057b4301a97d5234a87282583516abffbc377e05
5
5
  SHA512:
6
- metadata.gz: 46d9ad97e0033b0c99e06476594148baaf2bc630f59c4775d763a2ab322a2ad449229fa9f342509fdfe6ca9a0949405f50b17c719fc817eb426f32a9dd287f54
7
- data.tar.gz: 4e6ae0abee96441ac65eb2e8e886f4c2f3d00cc9716205936563022d7858f0d966d28d110c3b18ecdaa8aa328ef58b3b53410e9c32560aa0368b88e7ea6604b8
6
+ metadata.gz: 2e0d76139cfd93f77a91ee266bd596d74e8881da94fb750d97b03bb6c491424e75af208177687525d284ae3fe96e77f1e373f0bdce0583445a4070f3ed09cac0
7
+ data.tar.gz: 5bd98ea9eb89bcb4af4b74128c2d84ac1f32047322bb2177f7d47543efcc4122a4f8c23f463e8ae8291c8e6dff753182a39fd11fbdf42679975e5b2dba0ca571
@@ -31,6 +31,7 @@ module MiGA::Cli::Action::Doctor::Base
31
31
  file = File.join(base, dir, file_db)
32
32
  blk[file, metric, result, rank] if File.exist? file
33
33
  end
34
+ # Query databases for reference databases refer to taxonomy runs
34
35
  base = File.join(base, '05.taxonomy')
35
36
  result = :taxonomy
36
37
  end
@@ -137,10 +138,11 @@ module MiGA::Cli::Action::Doctor::Base
137
138
  def save_bidirectional(a, dist)
138
139
  each_database_file(a) do |db_file, metric, result, rank|
139
140
  next if rank == :haai # No need for hAAI to be bidirectional
141
+ next if result == :taxonomy # Taxonomy is never bidirectional
140
142
 
141
143
  b2a = dist[rank].map { |b_name, v| b_name if v[a.name] }.compact
142
144
  a2b = dist[rank][a.name]&.keys || []
143
- SQLite3::Database.new(db_file) do |db|
145
+ MiGA::SQLite.new(db_file).run do |db|
144
146
  sql = <<~SQL
145
147
  insert into #{metric}(seq1, seq2, #{metric}, sd, n, omega) \
146
148
  values(?, ?, ?, ?, ?, ?);
@@ -26,9 +26,7 @@ module MiGA::Common::WithResult
26
26
  task = task.to_sym
27
27
  return nil if result_dirs[task].nil?
28
28
 
29
- base = File.join(
30
- project.path, "data/#{result_dirs[task]}/#{result_base}"
31
- )
29
+ base = File.join(project.path, 'data', result_dirs[task], result_base)
32
30
  json = "#{base}.json"
33
31
  return MiGA::Result.load(json) unless save
34
32
 
data/lib/miga/sqlite.rb CHANGED
@@ -31,16 +31,30 @@ class MiGA::SQLite < MiGA::MiGA
31
31
  def initialize(path, opts = {})
32
32
  @opts = MiGA::SQLite.default_opts(opts)
33
33
  @path = File.absolute_path(path)
34
+ MiGA::MiGA.DEBUG("Accessing database: #{path}")
34
35
  end
35
36
 
36
37
  ##
37
- # Executes +cmd+ and returns the result
38
+ # Executes +cmd+ and returns the result. Alternatively, if a block is
39
+ # passed, the commands are ignored and the block is executed with a
40
+ # single parameter of the database connection
38
41
  def run(*cmd)
42
+ if block_given?
43
+ run_block { |conn| yield(conn) }
44
+ else
45
+ y = nil
46
+ run_block { |conn| y = conn.execute(*cmd) }
47
+ y
48
+ end
49
+ end
50
+
51
+ ##
52
+ # Executes +blk+ that accepts a single parameter for the database
53
+ # connection
54
+ def run_block(&blk)
39
55
  busy_attempts ||= 0
40
56
  io_attempts ||= 0
41
- y = nil
42
- SQLite3::Database.new(path) { |conn| y = conn.execute(*cmd) }
43
- y
57
+ SQLite3::Database.new(path) { |conn| blk[conn] }
44
58
  rescue SQLite3::BusyException => e
45
59
  busy_attempts += 1
46
60
  raise "Database busy #{path}: #{e.message}" if busy_attempts >= 3
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, 2, 2].freeze
15
+ VERSION = [1.2, 2, 3].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(2022, 2, 2)
23
+ VERSION_DATE = Date.new(2022, 2, 9)
24
24
 
25
25
  ##
26
26
  # References of MiGA
@@ -1,29 +1,48 @@
1
1
  #!/usr/bin/env Rscript
2
2
 
3
- argv <- commandArgs(trailingOnly=T)
3
+ argv <- commandArgs(trailingOnly = TRUE)
4
4
 
5
- plot_core_pan <- function(core_pan, pdf){
6
- a <- read.table(core_pan, sep="\t", header=TRUE)
5
+ plot_core_pan <- function (core_pan, pdf) {
6
+ a <- read.table(core_pan, sep = "\t", header = TRUE)
7
+ col <- c(
8
+ rgb(96, 11, 64, max = 255),
9
+ rgb(0, 121, 166, max = 255),
10
+ rgb(0.5, 0.5, 0.5, 1/3),
11
+ rep(rgb(0.5, 0.5, 0.5), 2)
12
+ )
7
13
  pdf(pdf, 7, 5)
8
- plot(1, type="n", xlim=c(0, max(a$genomes)*1.05), xaxs="i", yaxs="i",
9
- ylim=c(0, max(a$pan_q3)*1.05), xlab="Genomes", ylab="Orthologous Groups")
14
+ plot(
15
+ 1, type = "n", xlim = c(0, max(a$genomes) * 1.05), xaxs = "i", yaxs = "i",
16
+ ylim = c(0, max(a$pan_q3) * 1.05)/1e3, xlab = "Genomes",
17
+ ylab = "Orthologous Groups (thousands)"
18
+ )
19
+
10
20
  # Core
11
- polygon(c(a$genomes, rev(a$genomes)), c(a$core_q1, rev(a$core_q3)),
12
- border=NA, col=rgb(0, 121, 166, 128/2, max=255))
13
- lines(a$genomes, a$core_avg, col=rgb(0,121,166,max=255), lty=2)
14
- lines(a$genomes, a$core_q2, col=rgb(0,121,166,max=255), lty=1)
21
+ polygon(
22
+ c(a$genomes, rev(a$genomes)), c(a$core_q1, rev(a$core_q3))/1e3,
23
+ border = NA, col = rgb(0, 121, 166, 256/4, max = 255)
24
+ )
25
+ lines(a$genomes, a$core_avg/1e3, col = col[2], lty = 2)
26
+ lines(a$genomes, a$core_q2/1e3, col = col[2], lty = 1)
27
+
15
28
  # Pan
16
- polygon(c(a$genomes, rev(a$genomes)), c(a$pan_q1, rev(a$pan_q3)),
17
- border=NA, col=rgb(96, 11, 64, 128/2, max=255))
18
- lines(a$genomes, a$pan_avg, col=rgb(96,11,64,max=255), lty=2)
19
- lines(a$genomes, a$pan_q2, col=rgb(96,11,64,max=255), lty=1)
29
+ polygon(
30
+ c(a$genomes, rev(a$genomes)), c(a$pan_q1, rev(a$pan_q3))/1e3,
31
+ border = NA, col = rgb(96, 11, 64, 256/4, max = 255)
32
+ )
33
+ lines(a$genomes, a$pan_avg/1e3, col = col[1], lty = 2)
34
+ lines(a$genomes, a$pan_q2/1e3, col = col[1], lty = 1)
35
+
20
36
  # Legend
21
- legend("topleft",
22
- legend=c("pangenome","core genome","Inter-Quartile","Median","Average"),
23
- pch=c(16,16,15,NA,NA),lty=c(NA,NA,NA,1,2), pt.cex=c(1,1,2,NA,NA),
24
- col=c(rgb(96,11,64,max=255), rgb(0,121,166,max=255),
25
- rgb(0.5,0.5,0.5,166/255), rep(rgb(0.5,0.5,0.5),2)), bty="n")
37
+ legend <- c("pangenome", "core genome", "Inter-Quartile", "Median", "Average")
38
+ legend(
39
+ "topleft", legend = legend, col = col, bty = "n",
40
+ pch = c(16, 16, 15, NA, NA),
41
+ lty = c(NA, NA, NA, 1, 2),
42
+ pt.cex = c(1, 1, 2, NA, NA),
43
+ )
26
44
  dev.off()
27
45
  }
28
46
 
29
47
  plot_core_pan(argv[1], argv[2])
48
+
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.2.2
4
+ version: 1.2.2.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: 2022-02-02 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: daemons