bio-samtools 2.3.2 → 2.3.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
  SHA1:
3
- metadata.gz: 2e898f0be5b6f4b1638776a6c6deddf2a6b184cc
4
- data.tar.gz: ecba19c430831daa153829151cbbc26b41596f82
3
+ metadata.gz: 775737792e8669adba78db39510bc7bfa13bb086
4
+ data.tar.gz: 3741d4320545bb862be52f603e7ac6018eb1601d
5
5
  SHA512:
6
- metadata.gz: 3588293b3d0455ed39eeae45054d2c29a7f5276a2cf6c3a7b3a68937c5a5733b15fcfdbaa73f2f2c462fc335409e27331a00b0536b6d5e9894fdc8cb744f83b1
7
- data.tar.gz: 540714f4e6cb193ee69b45600b460a99bdf21bba02d376c0a561d2849d9a9fac7794b3eae89e2b306e1726c5b8ae154a8203760dc9ab765ab6333a51d7ae5395
6
+ metadata.gz: 11f21eab205187229b295bae05bc108a1ccec626b93f277e4e8c26f64dfd1a963c1ec741efef9476ab5717647a04e44079ffaeb14f99ae7561ceaca9e41060b5
7
+ data.tar.gz: d593004ccb8e0dbf6f1f8f37372745e6caffba5e6b27f1f8b97973e180acd4ef25245629dffb438a2888888b49763d364f3f4c9330c793e011820c3f196c10a2
data/.travis.yml CHANGED
@@ -11,3 +11,4 @@ rvm:
11
11
  - 1.9.3
12
12
  - 2.0.0
13
13
  - 2.1.0
14
+ - 2.2.2
data/Rakefile CHANGED
@@ -22,7 +22,7 @@ Jeweler::Tasks.new do |gem|
22
22
 
23
23
  This project was born from the need to add support of BAM files to
24
24
  the gee_fu genome browser (http://github.com/danmaclean/gee_fu).}
25
- gem.email = "ilpuccio.febo@gmail.com"
25
+ gem.email = "Ricardo.Ramirez-Gonzalez@tgac.ac.uk"
26
26
  gem.authors = ["Ricardo Ramirez-Gonzalez","Dan MacLean","Raoul J.P. Bonnal"]
27
27
  # Include your dependencies below. Runtime dependencies are required when using your gem,
28
28
  # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.3.2
1
+ 2.3.4
data/bin/bam_consensus.rb CHANGED
@@ -63,6 +63,7 @@ fasta_db.load_fai_entries
63
63
 
64
64
  output = $stdout
65
65
 
66
+
66
67
  output = File.open(options[:output_file], "w") if options[:output_file] != "-"
67
68
 
68
69
  fasta_db.index.entries.each do | r |
data/bio-samtools.gemspec CHANGED
@@ -2,19 +2,19 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bio-samtools 2.3.2 ruby lib
5
+ # stub: bio-samtools 2.3.3 ruby lib
6
6
  # stub: ext/mkrf_conf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "bio-samtools"
10
- s.version = "2.3.2"
10
+ s.version = "2.3.3"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Ricardo Ramirez-Gonzalez", "Dan MacLean", "Raoul J.P. Bonnal"]
15
- s.date = "2015-02-26"
15
+ s.date = "2015-06-19"
16
16
  s.description = "Binder of samtools for ruby, on the top of FFI. \n\n This project was born from the need to add support of BAM files to \n the gee_fu genome browser (http://github.com/danmaclean/gee_fu)."
17
- s.email = "ilpuccio.febo@gmail.com"
17
+ s.email = "Ricardo.Ramirez-Gonzalez@tgac.ac.uk"
18
18
  s.executables = ["bam_consensus.rb"]
19
19
  s.extensions = ["ext/mkrf_conf.rb"]
20
20
  s.extra_rdoc_files = [
@@ -145,7 +145,7 @@ Gem::Specification.new do |s|
145
145
  ]
146
146
  s.homepage = "http://github.com/helios/bioruby-samtools"
147
147
  s.licenses = ["MIT"]
148
- s.rubygems_version = "2.2.2"
148
+ s.rubygems_version = "2.4.6"
149
149
  s.summary = "Binder of samtools for ruby, on the top of FFI."
150
150
 
151
151
  if s.respond_to? :specification_version then
data/ext/Rakefile CHANGED
@@ -4,53 +4,47 @@ require 'fileutils'
4
4
  include FileUtils::Verbose
5
5
  require 'rake/clean'
6
6
 
7
- URL = "http://sourceforge.net/projects/samtools/files/samtools/0.1.19/samtools-0.1.19.tar.bz2/download"
7
+ URL = "http://sourceforge.net/projects/samtools/files/samtools/1.2/samtools-1.2.tar.bz2/download"
8
+ URL2 = "https://github.com/samtools/bcftools/releases/download/1.2/bcftools-1.2.tar.bz2"
8
9
 
9
10
  task :download do
10
11
  open(URL) do |uri|
11
- File.open("samtools-0.1.19.tar.bz2",'wb') do |fout|
12
+ File.open("samtools-1.2.tar.bz2",'wb') do |fout|
13
+ fout.write(uri.read)
14
+ end #fout
15
+ end #uri
16
+
17
+ open(URL2) do |uri|
18
+ File.open("bcftools-1.2.tar.bz2",'wb') do |fout|
12
19
  fout.write(uri.read)
13
20
  end #fout
14
21
  end #uri
15
22
  end
16
23
 
17
24
  task :compile do
18
- sh "tar xvfj samtools-0.1.19.tar.bz2"
19
- cd("samtools-0.1.19") do
20
- sh "patch < ../Makefile-bioruby.patch"
21
- # This patch replace CURSES lib with NCURSES which it is the only one available in OpenSUSE
22
- sh "patch < ../Makefile-suse.patch"
23
- case Config::CONFIG['host_os']
24
- when /linux/
25
- #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e"
26
- sh "make"
27
- cp("libbam.a","/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
28
- #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e libbam.so.1-local"
29
- sh "make libbam.so.1-local"
30
- cp("samtools", "/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
31
- cp("libbam.so.1","/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
32
- when /darwin/
33
- sh "make"
34
- cp("libbam.a","/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
35
- sh "make libbam.1.dylib-local"
36
- cp("libbam.1.dylib","/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
37
- sh "make"
38
- cp('samtools', "/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
39
- when /mswin|mingw/ then raise NotImplementedError, "BWA library is not available for Windows platform"
40
- end #case
25
+ sh "tar xvfj samtools-1.2.tar.bz2"
26
+ sh "tar xvfj bcftools-1.2.tar.bz2"
27
+ cd("samtools-1.2") do
28
+ sh "make"
29
+ cp("samtools", "/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
41
30
  end #cd
42
- cd("samtools-0.1.19/bcftools") do
31
+ cd("bcftools-1.2") do
43
32
  sh "make"
44
- cp('bcftools', "/Users/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
33
+ cp('bcftools', "/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
45
34
  end
46
35
  end
47
36
 
48
37
  task :clean do
49
- cd("samtools-0.1.19") do
38
+ cd("samtools-1.2") do
39
+ sh "make clean"
40
+ end
41
+ cd("bcftools-1.2") do
50
42
  sh "make clean"
51
43
  end
52
- rm("samtools-0.1.19.tar.bz2")
53
- rm_rf("samtools-0.1.19")
44
+ rm("samtools-1.2.tar.bz2")
45
+ rm_rf("samtools-1.2")
46
+ rm("bcftools-1.2.tar.bz2")
47
+ rm_rf("bcftools-1.2")
54
48
  end
55
49
 
56
50
  task :default => [:download, :compile, :clean]
data/ext/mkrf_conf.rb CHANGED
@@ -14,6 +14,8 @@ version.close
14
14
 
15
15
  url = "http://sourceforge.net/projects/samtools/files/samtools/#{Version}/samtools-#{Version}.tar.bz2/download"
16
16
  SamToolsFile = "samtools-#{Version}.tar.bz2"
17
+ url2 = "https://github.com/samtools/bcftools/releases/download/#{Version}/bcftools-#{Version}.tar.bz2"
18
+ VcfToolsFile = "bcftools-#{Version}.tar.bz2"
17
19
 
18
20
  File.open(File.join(path,"Rakefile"),"w") do |rakefile|
19
21
  rakefile.write <<-RAKE
@@ -24,6 +26,7 @@ include FileUtils::Verbose
24
26
  require 'rake/clean'
25
27
 
26
28
  URL = "#{url}"
29
+ URL2 = "#{url2}"
27
30
 
28
31
  task :download do
29
32
  open(URL) do |uri|
@@ -31,34 +34,22 @@ task :download do
31
34
  fout.write(uri.read)
32
35
  end #fout
33
36
  end #uri
37
+
38
+ open(URL2) do |uri|
39
+ File.open("#{VcfToolsFile}",'wb') do |fout|
40
+ fout.write(uri.read)
41
+ end #fout
42
+ end #uri
34
43
  end
35
44
 
36
45
  task :compile do
37
46
  sh "tar xvfj #{SamToolsFile}"
47
+ sh "tar xvfj #{VcfToolsFile}"
38
48
  cd("samtools-#{Version}") do
39
- sh "patch < ../Makefile-bioruby.patch"
40
- # This patch replace CURSES lib with NCURSES which it is the only one available in OpenSUSE
41
- sh "patch < ../Makefile-suse.patch"
42
- case Config::CONFIG['host_os']
43
- when /linux/
44
- #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e"
45
- sh "make"
46
- cp("libbam.a","#{path_external}")
47
- #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e libbam.so.1-local"
48
- sh "make libbam.so.1-local"
49
- cp("samtools", "#{path_external}")
50
- cp("libbam.so.1","#{path_external}")
51
- when /darwin/
52
- sh "make"
53
- cp("libbam.a","#{path_external}")
54
- sh "make libbam.1.dylib-local"
55
- cp("libbam.1.dylib","#{path_external}")
56
- sh "make"
57
- cp('samtools', "#{path_external}")
58
- when /mswin|mingw/ then raise NotImplementedError, "BWA library is not available for Windows platform"
59
- end #case
49
+ sh "make"
50
+ cp("samtools", "#{path_external}")
60
51
  end #cd
61
- cd("samtools-#{Version}/bcftools") do
52
+ cd("bcftools-#{Version}") do
62
53
  sh "make"
63
54
  cp('bcftools', "#{path_external}")
64
55
  end
@@ -68,8 +59,13 @@ task :clean do
68
59
  cd("samtools-#{Version}") do
69
60
  sh "make clean"
70
61
  end
62
+ cd("bcftools-#{Version}") do
63
+ sh "make clean"
64
+ end
71
65
  rm("#{SamToolsFile}")
72
66
  rm_rf("samtools-#{Version}")
67
+ rm("#{VcfToolsFile}")
68
+ rm_rf("bcftools-#{Version}")
73
69
  end
74
70
 
75
71
  task :default => [:download, :compile, :clean]
data/lib/bio/db/sam.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'open3'
1
2
  module Bio
2
3
  class DB
3
4
  class Sam
@@ -24,7 +25,7 @@ module Bio
24
25
 
25
26
  @last_command = nil
26
27
  raise ArgumentError, "Need Fasta and at least one BAM or SAM" if not @fasta or not @bam
27
- raise IOError, "File not found #{@files}" if not files_ok?
28
+ raise IOError, "File not found #{files}" if not files_ok?
28
29
  @bams = [@bams] if @bams.instance_of? String
29
30
 
30
31
  end
@@ -79,7 +80,7 @@ module Bio
79
80
  end
80
81
  command = String.new
81
82
  command = form_opt_string(@samtools, 'view', opts, [:b, :h, :H, :S, :u, '1', :x, :X, :c, :B])
82
- command = command + " '#{region}'" if region.size > 0
83
+ commad = command + " '#{region}'" if region.size > 0
83
84
  @last_command = command
84
85
  type = (opts[:u] or opts[:b]) ? :binary : :text
85
86
  klass = (type == :binary) ? String : Bio::DB::Alignment
@@ -319,9 +320,11 @@ module Bio
319
320
  end
320
321
 
321
322
  #Index sorted alignment for fast random access. Index file <aln.bam>.bai will be created of no out_index is provided.
322
- #* out_index - [STRING] name of index
323
+ #* out_index - [STRING] name of index Depreciated. It will fail now as
324
+ #* samtools doesn't support it anymore.
323
325
  def index(opts={})
324
- command = "#{@samtools} index #{@bam} #{opts[:out_index]}"
326
+ raise Exception.new "Index can't recieve parameters" if opts.size > 0
327
+ command = "#{@samtools} index #{@bam}"
325
328
  puts stderr.read if $VERBOSE
326
329
  @last_command = command
327
330
  system(command)
@@ -330,13 +333,14 @@ module Bio
330
333
  #Fill in mate coordinates, ISIZE and mate related flags from a name-sorted alignment
331
334
  #* out_bam name of outfile
332
335
  #* r - remove unmapped reads and secondary alignments
336
+ #* p - Disable FR proper pair check.
337
+ #* o - Add template cigar ct tag.
338
+ #* O FORMAT Write the final output as sam, bam, or cram.
333
339
  def fix_mates(opts={})
334
- #opts.merge!({:out_index=>nil})
335
- remove_reads = ""
336
- if opts[:r]
337
- remove_reads = "-r"
338
- end
339
- command = "#{@samtools} fixmate #{remove_reads} #{@bam} #{opts[:out_bam]}"
340
+ out_bam = opts[:out_bam]
341
+ opts.delete(:out_bam)
342
+ command = form_opt_string(@samtools, "fixmate", opts, [:r,:p,:c])
343
+ command << " #{out_bam}"
340
344
  puts stderr.read if $VERBOSE
341
345
  @last_command = command
342
346
  system(command)
@@ -478,6 +482,7 @@ module Bio
478
482
  #* S - treat PE reads as SE in rmdup (force -s)
479
483
  #* out - [FILE] output bam
480
484
  def remove_duplicates(opts={})
485
+ raise Exception.new(), "Remove duplicates is unsuported in samtools 1.2. This function will come back onece rmdup is available again."
481
486
  out = opts[:out]
482
487
  opts.delete(:out)
483
488
  command = "#{form_opt_string(@samtools, "rmdup", opts, [:s, :S])} #{out} #{@bam}"
@@ -1 +1 @@
1
- 0.1.19
1
+ 1.2
data/lib/bio/db/vcf.rb CHANGED
@@ -24,6 +24,13 @@ module Bio
24
24
  Integer.new(x) rescue x
25
25
  end
26
26
 
27
+ def method_missing(method, *args)
28
+ method_name = method.to_s
29
+ return true if @info.has_key?(method_name) and @info[method_name] == nil
30
+ return @info[method_name] if @info[method_name]
31
+ return false
32
+ end
33
+
27
34
  #returns vcf format line
28
35
  def to_s
29
36
  if !@chrom.nil?
data/test/test_sam.rb CHANGED
@@ -10,12 +10,12 @@ gem 'test-unit'
10
10
 
11
11
  class TestBioDbSam < Test::Unit::TestCase
12
12
  # include RubyProf::Test
13
-
14
- class << self
15
13
 
16
- def shutdown
17
- File.delete("test/samples/small/different_index.bam.bai")
18
- File.delete("test/samples/small/dupes_rmdup.bam")
14
+ class << self
15
+
16
+ def shutdown
17
+ #File.delete("test/samples/small/different_index.bam.bai")
18
+ #File.delete("test/samples/small/dupes_rmdup.bam")
19
19
  File.delete("test/samples/small/mates_fixed.bam")
20
20
  File.delete("test/samples/small/reheader.bam")
21
21
  File.delete("test/samples/small/test_chr.fasta.fai")
@@ -34,27 +34,15 @@ class TestBioDbSam < Test::Unit::TestCase
34
34
  @testReference = @test_folder + "/test_chr.fasta"
35
35
  @bed_file = @test_folder + "/testu.bed"
36
36
  @sam = Bio::DB::Sam.new(
37
- :fasta => @testReference,
38
- :bam => @testBAMFile
39
- )
37
+ :fasta => @testReference,
38
+ :bam => @testBAMFile
39
+ )
40
40
  end
41
41
 
42
42
 
43
43
 
44
44
  def test_new
45
45
  assert_kind_of(Bio::DB::Sam, @sam)
46
-
47
- assert_raise(IOError) do
48
- Bio::DB::Sam.new(
49
- :fasta => @testReference,
50
- :bam => @testBAMFile + "ads"
51
- )
52
-
53
- end
54
- assert_raise(ArgumentError) do
55
- Bio::DB::Sam.new()
56
- end
57
-
58
46
  end
59
47
 
60
48
  def test_index
@@ -64,7 +52,7 @@ class TestBioDbSam < Test::Unit::TestCase
64
52
  puts "bam index exists....deleting..."
65
53
  File.delete(test_bai_file)
66
54
  end
67
-
55
+
68
56
  #No bam file
69
57
  assert_equal(@sam.indexed?, false)
70
58
  #index the bam file
@@ -77,11 +65,22 @@ class TestBioDbSam < Test::Unit::TestCase
77
65
  assert(File.size(test_bai_file) > 0, "From test_index: .bai file is empty")
78
66
  #as above, but give the output a different name
79
67
  test_bai_file = @test_folder+"/different_index.bam.bai"
80
- @sam.index(:out_index=> test_bai_file)
81
- assert_nothing_thrown do
82
- File.open(test_bai_file, "r")
68
+
69
+ raised = false
70
+ begin
71
+ @sam.index(:out_index=> test_bai_file)
72
+ rescue Exception => e
73
+ raised = true
83
74
  end
84
- assert(File.size(test_bai_file) > 0, "From test_index: .bai file is empty")
75
+ assert_equal(raised, true)
76
+
77
+ #puts "Writing: #{test_bai_file}"
78
+ #File.open(test_bai_file, "r") do |f|
79
+ # puts "Read"
80
+ # puts f.read
81
+ #end
82
+
83
+ #assert(File.size(test_bai_file) > 0, "From test_index: .bai file is empty")
85
84
  end
86
85
 
87
86
  def test_view
@@ -95,9 +94,9 @@ class TestBioDbSam < Test::Unit::TestCase
95
94
 
96
95
  def test_fetch
97
96
  #puts @sam.inspect
98
- i = 0
99
- @sam.index
100
- @sam.fetch("chr_1", 10,1000) do |sam|
97
+ i = 0
98
+ @sam.index
99
+ @sam.fetch("chr_1", 10,1000) do |sam|
101
100
  #test that all the objects are Bio::DB::Alignment objects
102
101
  assert_equal(sam.class, Bio::DB::Alignment)
103
102
  assert_equal(sam.rname, "chr_1")
@@ -110,18 +109,8 @@ class TestBioDbSam < Test::Unit::TestCase
110
109
 
111
110
  def test_fetch_with_function
112
111
  #pass the assert to method
113
- count = 0
114
- block = Proc.new do |a|
115
- assert_equal(a.class, Bio::DB::Alignment)
116
- count += 1
117
- end
118
-
112
+ block = Proc.new {|a| assert_equal(a.class, Bio::DB::Alignment)}
119
113
  @sam.fetch_with_function("chr_1", 10, 1000, &block)
120
- assert_equal(count, 9)
121
-
122
- count = 0
123
- @sam.fetch_with_function("chr_1", 82, 140, &block)
124
- assert_equal(count, 4)
125
114
  end
126
115
 
127
116
  def test_chromosome_coverage
@@ -153,7 +142,7 @@ class TestBioDbSam < Test::Unit::TestCase
153
142
  #test that the file is not empty
154
143
  assert(File.size(test_fai_file) > 0, "From test_faidx: .fai file is empty")
155
144
  end
156
-
145
+
157
146
  def test_index_stats
158
147
  @sam.index_stats.each_pair do |seq, stat|
159
148
  assert_send([['chr_1' , '*'], :member?, seq])
@@ -175,41 +164,41 @@ class TestBioDbSam < Test::Unit::TestCase
175
164
  @sam.sort(:prefix=>@test_folder + "/test_sorted")
176
165
  #create a new Bio::DB::Sam from the sorted bam
177
166
  @sortsam = Bio::DB::Sam.new(
178
- :fasta => @testReference,
179
- :bam => sortedsam
180
- )
167
+ :fasta => @testReference,
168
+ :bam => sortedsam
169
+ )
181
170
  pos = 0
182
171
  #iterate over the sorted sam file and make sure that the it's sorted by checking the order of the start positions for each read.
183
172
  @sortsam.view()do |sam|
184
- assert(sam.pos > pos, "Not sorted by position")
185
- pos = sam.pos
186
- end
173
+ assert(sam.pos > pos, "Not sorted by position")
174
+ pos = sam.pos
187
175
  end
176
+ end
177
+
178
+ def test_reheader
179
+ sam_header = @test_folder + "/map_for_reheader.sam"
180
+ outfile = @test_folder + "/reheader.bam"
188
181
 
189
- def test_reheader
190
- sam_header = @test_folder + "/map_for_reheader.sam"
191
- outfile = @test_folder + "/reheader.bam"
192
-
193
- @sam.reheader(sam_header, :out=>outfile)
194
- reheader_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => outfile)
182
+ @sam.reheader(sam_header, :out=>outfile)
183
+ reheader_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => outfile)
195
184
  #check that the reference is 'chr_2'
196
185
  reheader_bam.view()do |sam|
197
- assert_equal(sam.rname, "chr_2")
198
- end
186
+ assert_equal(sam.rname, "chr_2")
199
187
  end
188
+ end
200
189
 
201
- def test_calmd
202
- no_md_sam = @test_folder + "/no_md.sam"
203
- md = Bio::DB::Sam.new(:fasta => @testReference, :bam => no_md_sam)
204
- block = Proc.new {|a| assert(a.tags.has_key?('MD'), "From test_calmd: couldn't find the MD tag")}
205
- md.calmd(:S=>true, &block)
206
-
207
- end
190
+ def test_calmd
191
+ no_md_sam = @test_folder + "/no_md.sam"
192
+ md = Bio::DB::Sam.new(:fasta => @testReference, :bam => no_md_sam)
193
+ block = Proc.new {|a| assert(a.tags.has_key?('MD'), "From test_calmd: couldn't find the MD tag")}
194
+ md.calmd(:S=>true, &block)
208
195
 
209
- def test_mpileup
196
+ end
197
+
198
+ def test_mpileup
210
199
  #create an mpileup
211
200
  # @sam.index
212
- @sam.mpileup(:g => false) do |pileup|
201
+ @sam.mpileup(:g => false) do |pileup|
213
202
  #test that all the objects are Bio::DB::Pileup objects
214
203
  assert_kind_of(Bio::DB::Pileup, pileup)
215
204
  #test that the reference name is 'chr_1' for all objects
@@ -245,13 +234,13 @@ class TestBioDbSam < Test::Unit::TestCase
245
234
  #puts pileup
246
235
  assert_equal(pileup.ref_name, 'chr_1')
247
236
  end
248
-
237
+
249
238
  region = @sam.cached_regions[reg.to_s]
250
239
  #puts "cahced_region: #{region.inspect}"
251
- puts "AVG COV: #{region.average_coverage}"
252
- puts "Reference: #{region.reference}"
253
- puts "Consensus: #{region.consensus}"
254
- puts "called: #{region.called}"
240
+ #puts "AVG COV: #{region.average_coverage}"
241
+ #puts "Reference: #{region.reference}"
242
+ #puts "Consensus: #{region.consensus}"
243
+ #puts "called: #{region.called}"
255
244
  #, :snps, :reference, :base_ratios, :consensus, :coverages
256
245
  snps_tot = Bio::Sequence.snps_between(region.reference, region.consensus)
257
246
  assert_equal(snps_tot, 5)
@@ -267,9 +256,9 @@ class TestBioDbSam < Test::Unit::TestCase
267
256
  #test that the reference name is 'chr_1' for all objects
268
257
  #puts pileup
269
258
  assert_equal(pileup.ref_name, 'chr_1')
270
-
259
+
271
260
  end
272
-
261
+
273
262
  region = @sam.cached_regions[reg.to_s]
274
263
 
275
264
  #, :snps, :reference, :base_ratios, :consensus, :coverages
@@ -287,7 +276,9 @@ class TestBioDbSam < Test::Unit::TestCase
287
276
 
288
277
  def test_fixmate
289
278
  mates_fixed_bam = @test_folder + "/mates_fixed.bam"
290
- @sam.fix_mates(:out_bam=>mates_fixed_bam)
279
+ @sam.fix_mates(:out_bam=>mates_fixed_bam, :r =>true, :p =>true, :c =>true)
280
+ puts "FIXMATE!!!"
281
+ puts @sam.last_command
291
282
  assert_nothing_thrown do
292
283
  File.open(mates_fixed_bam, "r")
293
284
  end
@@ -313,18 +304,18 @@ class TestBioDbSam < Test::Unit::TestCase
313
304
  merged_bam_file = @test_folder + "/maps_merged.bam"
314
305
  File.delete merged_bam_file if File.exists?(merged_bam_file)
315
306
  # File.delete("test/samples/small/maps_merged.bam")
316
- @sam.merge(:out=>merged_bam_file, :bams=>bam_files, :n=>true)
317
- merged_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => merged_bam_file)
318
- no_reads_mapped = 0;
319
-
320
- merged_bam.view() do |al|
321
- assert_kind_of(Bio::DB::Alignment, al)
322
- no_reads_mapped+=1
323
- end
324
- assert_equal(no_reads_mapped, 10)
325
- end
326
-
327
- def test_cat
307
+ @sam.merge(:out=>merged_bam_file, :bams=>bam_files, :n=>true)
308
+ merged_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => merged_bam_file)
309
+ no_reads_mapped = 0;
310
+
311
+ merged_bam.view() do |al|
312
+ assert_kind_of(Bio::DB::Alignment, al)
313
+ no_reads_mapped+=1
314
+ end
315
+ assert_equal(no_reads_mapped, 10)
316
+ end
317
+
318
+ def test_cat
328
319
  #same files used for merge, but we'll cat them instead
329
320
  bam1 = @test_folder + "/map_to_merge1.bam"
330
321
  bam2 = @test_folder + "/map_to_merge2.bam"
@@ -350,26 +341,29 @@ class TestBioDbSam < Test::Unit::TestCase
350
341
  dupes = @test_folder + "/dupes.bam"
351
342
  unduped = @test_folder + "/dupes_rmdup.bam"
352
343
  bam_with_dupes = Bio::DB::Sam.new(:fasta => @testReference, :bam => dupes)
353
- bam_with_dupes.remove_duplicates(:s=>true, :out=>unduped)
354
-
355
- unduped_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => unduped)
344
+ #This is a temporarry patch while samtools 1.+ restores rmdup
345
+ assert_raise do
346
+ bam_with_dupes.remove_duplicates(:s=>true, :out=>unduped)
347
+
348
+ unduped_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => unduped)
356
349
  #rmdup should remove 267 of the 268 reads mapping to the same place, so producing a bam file with 5 reads
357
350
  readcount = 0
358
351
  unduped_bam.view()do |sam|
359
- readcount +=1
360
- end
361
- assert_equal(readcount, 5)
352
+ readcount +=1
362
353
  end
363
-
364
- def test_targetcut
365
- sorted_bam = @test_folder + "/sorted.bam"
366
- cut = Bio::DB::Sam.new(:fasta => @testReference, :bam => sorted_bam)
367
- assert_nothing_thrown do
368
- cut.targetcut
369
- end
354
+ assert_equal(readcount, 5)
355
+ end
356
+ end
357
+
358
+ def test_targetcut
359
+ sorted_bam = @test_folder + "/sorted.bam"
360
+ cut = Bio::DB::Sam.new(:fasta => @testReference, :bam => sorted_bam)
361
+ assert_nothing_thrown do
362
+ cut.targetcut
370
363
  end
371
-
372
- def test_docs
364
+ end
365
+
366
+ def test_docs
373
367
  #force an error (use 'samtool' instead of 'samtools')
374
368
  output = Bio::DB::Sam.docs('samtool', 'tview')
375
369
  assert_equal(output, "program must be 'samtools' or 'bcftools'")
data/test/test_vcf.rb CHANGED
@@ -41,6 +41,13 @@ class TestVcf < Test::Unit::TestCase
41
41
  "2"=>{"DP"=>"8", "GT"=>"1|0", "HQ"=>"51,51", "GQ"=>"48"},
42
42
  "3"=>{"DP"=>"5", "GT"=>"1/1", "HQ"=>"-1,-1", "GQ"=>"43"}}, @vcf2.samples)
43
43
 
44
+ assert_equal(true, @vcf2.H2)
45
+ assert_equal(true, @vcf2.DB)
46
+ assert_equal(false, @vcf2.XX)
47
+ assert_equal("14", @vcf2.DP)
48
+ assert_equal("0.5", @vcf2.AF)
49
+ assert_equal("3", @vcf2.NS)
50
+
44
51
  assert_equal("19", @vcf3.chrom)
45
52
  assert_equal(111, @vcf3.pos)
46
53
  assert_equal(nil, @vcf3.id)
@@ -61,6 +68,12 @@ class TestVcf < Test::Unit::TestCase
61
68
  assert_equal(29,@vcf4.qual)
62
69
  assert_equal("PASS", @vcf4.filter)
63
70
  assert_equal({"DP"=>"14", "AF"=>"0.5", "NS"=>"3", "DB"=>nil, "H2"=>nil}, @vcf4.info)
71
+ assert_equal(true, @vcf4.H2)
72
+ assert_equal(true, @vcf4.DB)
73
+ assert_equal(false, @vcf4.XX)
74
+ assert_equal("14", @vcf4.DP)
75
+ assert_equal("0.5", @vcf4.AF)
76
+ assert_equal("3", @vcf4.NS)
64
77
  assert_equal({"1"=>{"DP"=>"1", "GT"=>"0|0", "HQ"=>"51,51", "GQ"=>"48"},
65
78
  "2"=>{"DP"=>"8", "GT"=>"1|0", "HQ"=>"51,51", "GQ"=>"48"},
66
79
  "3"=>{"DP"=>"5", "GT"=>"1/1", "HQ"=>".,", "GQ"=>"43"}}, @vcf4.samples)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-samtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.2
4
+ version: 2.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Ramirez-Gonzalez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-02-26 00:00:00.000000000 Z
13
+ date: 2015-06-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bio-svgenes
@@ -183,7 +183,7 @@ dependencies:
183
183
  description: "Binder of samtools for ruby, on the top of FFI. \n\n This project was
184
184
  born from the need to add support of BAM files to \n the gee_fu genome browser
185
185
  (http://github.com/danmaclean/gee_fu)."
186
- email: ilpuccio.febo@gmail.com
186
+ email: Ricardo.Ramirez-Gonzalez@tgac.ac.uk
187
187
  executables:
188
188
  - bam_consensus.rb
189
189
  extensions:
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  version: '0'
333
333
  requirements: []
334
334
  rubyforge_project:
335
- rubygems_version: 2.2.2
335
+ rubygems_version: 2.4.6
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: Binder of samtools for ruby, on the top of FFI.