rbbt-util 5.26.150 → 5.26.151

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: ad40e6919c3e8e77360dbfae0ea25c736c6144989517232d958f1438c8f80097
4
- data.tar.gz: 825d7c86c2ae9acf7d47341cc9871a9e999e9591cdcdbfc6270e197be156ebae
3
+ metadata.gz: 11b833bbcd15bc363a8bc7923828bc7545c276f79d9ed2d41a1078e8d57fff10
4
+ data.tar.gz: 83bfc6713a4333ae904cd8636eb8e9724545085d1c4aff1973b534287521d342
5
5
  SHA512:
6
- metadata.gz: 34951a010cac42122a179959356a0e8f164489de0de3f04888754826563c156a384af687d7c8119b4ea228a0429db5d7cc1757f60c8ee81117b5ad161d0fc01d
7
- data.tar.gz: 7a5ca9c1f0bf6cc2684aecd6a44eb2fe4f777b6c16de2069a01eed8196525e5ec40a521ad9a6b026dba9fd5c44bb63ffc789051eab14d88bd78bc32046565ccf
6
+ metadata.gz: 23f47354eba951a3d299b132c25e096d6de81e3e1254fda1a5a6b0a245455139c9bfcbf4db4d20ca50b7d91828a04fdca517109235ffd4fae69feb118f252392
7
+ data.tar.gz: a3fbc000a6626b94da9a6895a473a1300b388e7350d05327cd824e3a027a7ca50c5c761a29fe7c52b39ea66be8e89f81c6c76137ee6283be0a1ad254e95b4960
data/lib/rbbt/util/cmd.rb CHANGED
@@ -29,7 +29,18 @@ module CMD
29
29
  block.call
30
30
  end
31
31
  end
32
- @@init_cmd_tool[tool] = true
32
+ version_txt = ""
33
+ %w(--version -version --help).each do |f|
34
+ begin
35
+ version_txt += CMD.cmd("#{tool} #{f}").read
36
+ break
37
+ rescue
38
+ end
39
+ end
40
+
41
+ version = Misc.scan_version_text(version_txt, tool)
42
+
43
+ @@init_cmd_tool[tool] = version || true
33
44
 
34
45
  return cmd if cmd
35
46
  end
@@ -37,6 +48,11 @@ module CMD
37
48
  tool.to_s
38
49
  end
39
50
 
51
+ def self.versions
52
+ return {} unless defined? @@init_cmd_tool
53
+ @@init_cmd_tool.select{|k,v| v =~ /\d+\./ }
54
+ end
55
+
40
56
  def self.gzip_pipe(file)
41
57
  Open.gzip?(file) ? "<(gunzip -c '#{file}')" : "'#{file}'"
42
58
  end
@@ -88,7 +104,7 @@ module CMD
88
104
 
89
105
  log = true if log.nil?
90
106
 
91
- if cmd.nil? and ! Symbol === tool
107
+ if cmd.nil? && ! Symbol === tool
92
108
  cmd = tool
93
109
  else
94
110
  tool = get_tool(tool)
@@ -398,4 +398,11 @@ module Misc
398
398
  nil
399
399
  end
400
400
  end
401
+
402
+ def self.scan_version_text(text, cmd = nil)
403
+ cmd = "NOCMDGIVE" if cmd.nil? || cmd.empty?
404
+ m = text.match(/(?:version.*?|#{cmd}.*?|v)((?:\d+\.)*\d+(?:-[a-z_]+)?)/i)
405
+ return nil if m.nil?
406
+ m[1]
407
+ end
401
408
  end
@@ -41,6 +41,8 @@ module Rbbt
41
41
  versions[name] = version
42
42
  end
43
43
  versions
44
+
45
+ versions.merge(CMD.versions)
44
46
  end
45
47
 
46
48
  Rbbt.add_version(__FILE__)
@@ -420,6 +420,7 @@ class Step
420
420
  result
421
421
  end # END PERSIST
422
422
  log :done, "Completed step #{Log.color :yellow, task.name.to_s || ""} in #{time_elapsed.to_i}+#{(total_time_elapsed - time_elapsed).to_i} sec." unless stream or time_elapsed.nil?
423
+ set_info :versions, Rbbt.versions
423
424
 
424
425
  if no_load
425
426
  @result ||= result
@@ -626,5 +626,69 @@ EOF
626
626
  assert_match /^[0-9a-z]{10,}$/, Misc.file2md5(file)
627
627
  end
628
628
  end
629
+
630
+ def test_scan_version_text
631
+ txt =<<-EOF
632
+ Program: bcftools (Tools for variant calling and manipulating VCFs and BCFs)
633
+ Version: 1.10.2-dirty (using htslib 1.10.2-12-gd807564-dirty)
634
+
635
+ Usage: bcftools [--version|--version-only] [--help] <command> <argument>
636
+
637
+ Commands:
638
+
639
+ -- Indexing
640
+ index index VCF/BCF files
641
+
642
+ -- VCF/BCF manipulation
643
+ annotate annotate and edit VCF/BCF files
644
+ concat concatenate VCF/BCF files from the same set of samples
645
+ convert convert VCF/BCF files to different formats and back
646
+ isec intersections of VCF/BCF files
647
+ merge merge VCF/BCF files files from non-overlapping sample sets
648
+ norm left-align and normalize indels
649
+ plugin user-defined plugins
650
+ query transform VCF/BCF into user-defined formats
651
+ reheader modify VCF/BCF header, change sample names
652
+ sort sort VCF/BCF file
653
+ view VCF/BCF conversion, view, subset and filter VCF/BCF files
654
+
655
+ -- VCF/BCF analysis
656
+ call SNP/indel calling
657
+ consensus create consensus sequence by applying VCF variants
658
+ cnv HMM CNV calling
659
+ csq call variation consequences
660
+ filter filter VCF/BCF files using fixed thresholds
661
+ gtcheck check sample concordance, detect sample swaps and contamination
662
+ mpileup multi-way pileup producing genotype likelihoods
663
+ roh identify runs of autozygosity (HMM)
664
+ stats produce VCF/BCF stats
665
+
666
+ Most commands accept VCF, bgzipped VCF, and BCF with the file type detected
667
+ automatically even when streaming from a pipe. Indexed VCF and BCF will work
668
+ in all situations. Un-indexed VCF and BCF and streams will work in most but
669
+ not all situations.
670
+ EOF
671
+
672
+ assert_equal "1.10.2-dirty", Misc.scan_version_text(txt, "bcftools")
673
+
674
+ txt =<<-EOF
675
+ The Genome Analysis Toolkit (GATK) v4.1.4.1
676
+ HTSJDK Version: 2.21.0
677
+ Picard Version: 2.21.2
678
+ EOF
679
+ assert_equal "4.1.4.1", Misc.scan_version_text(txt, "gatk")
680
+
681
+
682
+ txt =<<-EOF
683
+ grep (GNU grep) 3.1
684
+ Copyright (C) 2017 Free Software Foundation, Inc.
685
+ License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
686
+ This is free software: you are free to change and redistribute it.
687
+ There is NO WARRANTY, to the extent permitted by law.
688
+
689
+ Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
690
+ EOF
691
+ assert_equal "3.1", Misc.scan_version_text(txt, "grep")
692
+ end
629
693
  end
630
694
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.26.150
4
+ version: 5.26.151
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez