bio-samtools 2.4.0 → 2.5.1

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: 90e15e76b4d1f9b079ab0f3fd6ecca9833a67e99
4
- data.tar.gz: 251a8a0a110617d3894cfa6e287bc06bbd24ed89
3
+ metadata.gz: 536e4a02119f2315755d2768e868ca21b29213ac
4
+ data.tar.gz: 6b4c39ca800763b7f654d4d04994338ea9b809a1
5
5
  SHA512:
6
- metadata.gz: 84b928dc4aeb6b96f7854beb4cf54bdc94d8a8e7b6a50e5a581d9a5d2d7d22f435f765ebae9ef4765701dd823c603ca84896714b5685269c9e4d33f7fceb1eff
7
- data.tar.gz: 6eca1fbf0fcb285c2c4cf7a436eab0b087a697d1e858e8a4b491bd1ec13e2bc90fccec00c1c1d8c12c70b1bcb88ad4663271720c0b6de9fc5121c4b263cb4841
6
+ metadata.gz: 94d1754483e138a78321e5d73a94406aaa51186a01f9bf70239b2f4089cef3378ac06d075180631e815eec52336e0bbc834bb4724ed454845bd63d93ac591f70
7
+ data.tar.gz: 1cce66d5dbab92a6fc1ccd167b5df3827d8f44efac002fd970c789335abf6dace5ea32aab75e82a6a977b47241da967531660131059ddc8224cdaaff0bb8f3f2
@@ -12,8 +12,9 @@ before_script:
12
12
  - rake -f Rakefile
13
13
  - cd ../
14
14
  rvm:
15
- - 1.9.3
16
15
  - 2.0.0
17
- - 2.1.0
16
+ - 2.1.10
18
17
  - 2.2.2
19
18
  - 2.2.3
19
+ - 2.2.5
20
+ - 2.3.1
data/Gemfile CHANGED
@@ -1,22 +1,21 @@
1
1
  source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
- # gem "activesupport", ">= 2.3.5"
5
4
  gem "bio-svgenes", ">= 0.4.1"
6
5
  gem "bio", ">= 1.4.2"
7
- gem 'open_uri_redirections'
6
+ #gem 'open_uri_redirections'
8
7
 
9
8
  # Add dependencies to develop your gem here.
10
9
  # Include everything needed to run rake, tests, features, etc.
11
10
  group :development do
12
- gem "shoulda", "> 2.10"
13
- gem "shoulda-context"
14
- gem "shoulda-matchers"
15
- gem "bundler", "> 1.0.21"
16
- gem "jeweler"
17
- gem "rcov", ">=0", :platforms => :ruby_18
18
- gem "simplecov", ">= 0", :platforms => :ruby_19
19
- gem "ruby-prof"
20
- gem 'rdoc'
11
+ gem "shoulda", "= 2.10"
21
12
  gem 'test-unit'
13
+ if RUBY_VERSION.start_with?("2.1") or RUBY_VERSION.start_with?("2.2") or RUBY_VERSION.start_with?("2.0")
14
+ gem "jeweler", "= 2.0.1"
15
+ else
16
+ gem "juwelier" , :platforms => :ruby_23 #jeweler support is being dropped
17
+ end
18
+ gem "rack", "1.6.4", :platforms => :ruby_21
19
+
20
+
22
21
  end
data/Rakefile CHANGED
@@ -11,8 +11,19 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require 'jeweler'
15
- Jeweler::Tasks.new do |gem|
14
+
15
+ if RUBY_VERSION.start_with?("2.1") or RUBY_VERSION.start_with?("2.2") or RUBY_VERSION.start_with?("2.0")
16
+ require 'jeweler'
17
+ @taskClass = Jeweler
18
+ else
19
+ require 'juwelier'
20
+ @taskClass = Juwelier
21
+ end
22
+
23
+
24
+ #Juwelier
25
+
26
+ @taskClass::Tasks.new do |gem|
16
27
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
28
  gem.name = "bio-samtools"
18
29
  gem.homepage = "http://github.com/helios/bioruby-samtools"
@@ -30,7 +41,7 @@ Jeweler::Tasks.new do |gem|
30
41
  # gem.add_development_dependency 'rspec', '> 1.2.3'
31
42
  gem.extensions = "ext/mkrf_conf.rb"
32
43
  end
33
- Jeweler::RubygemsDotOrgTasks.new
44
+ @taskClass::RubygemsDotOrgTasks.new
34
45
 
35
46
  require 'rake/testtask'
36
47
  Rake::TestTask.new(:test) do |test|
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.4.0
1
+ 2.5.1
@@ -1,18 +1,18 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bio-samtools 2.4.0 ruby lib
5
+ # stub: bio-samtools 2.5.1 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.4.0"
10
+ s.version = "2.5.1"
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 = "2016-05-25"
15
+ s.date = "2016-11-04"
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
17
  s.email = "Ricardo.Ramirez-Gonzalez@tgac.ac.uk"
18
18
  s.executables = ["bam_consensus.rb"]
@@ -135,9 +135,11 @@ Gem::Specification.new do |s|
135
135
  "test/samples/small/test_chr.fasta.rsa",
136
136
  "test/samples/small/test_chr.fasta.sa",
137
137
  "test/samples/small/test_cov.svg",
138
+ "test/samples/small/test_fastadb.fasta",
138
139
  "test/samples/small/testu.bam",
139
140
  "test/samples/small/testu.bed",
140
141
  "test/test_bio-samtools.rb",
142
+ "test/test_fastadb.rb",
141
143
  "test/test_pileup.rb",
142
144
  "test/test_sam.rb",
143
145
  "test/test_vcf.rb",
@@ -147,7 +149,7 @@ Gem::Specification.new do |s|
147
149
  ]
148
150
  s.homepage = "http://github.com/helios/bioruby-samtools"
149
151
  s.licenses = ["MIT"]
150
- s.rubygems_version = "2.2.2"
152
+ s.rubygems_version = "2.5.1"
151
153
  s.summary = "Binder of samtools for ruby, on the top of FFI."
152
154
 
153
155
  if s.respond_to? :specification_version then
@@ -156,46 +158,25 @@ Gem::Specification.new do |s|
156
158
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
157
159
  s.add_runtime_dependency(%q<bio-svgenes>, [">= 0.4.1"])
158
160
  s.add_runtime_dependency(%q<bio>, [">= 1.4.2"])
159
- s.add_runtime_dependency(%q<open_uri_redirections>, [">= 0"])
160
- s.add_development_dependency(%q<shoulda>, ["> 2.10"])
161
- s.add_development_dependency(%q<shoulda-context>, [">= 0"])
162
- s.add_development_dependency(%q<shoulda-matchers>, [">= 0"])
163
- s.add_development_dependency(%q<bundler>, ["> 1.0.21"])
164
- s.add_development_dependency(%q<jeweler>, [">= 0"])
165
- s.add_development_dependency(%q<rcov>, [">= 0"])
166
- s.add_development_dependency(%q<simplecov>, [">= 0"])
167
- s.add_development_dependency(%q<ruby-prof>, [">= 0"])
168
- s.add_development_dependency(%q<rdoc>, [">= 0"])
161
+ s.add_development_dependency(%q<shoulda>, ["= 2.10"])
169
162
  s.add_development_dependency(%q<test-unit>, [">= 0"])
163
+ s.add_development_dependency(%q<juwelier>, [">= 0"])
164
+ s.add_development_dependency(%q<rack>, ["= 1.6.4"])
170
165
  else
171
166
  s.add_dependency(%q<bio-svgenes>, [">= 0.4.1"])
172
167
  s.add_dependency(%q<bio>, [">= 1.4.2"])
173
- s.add_dependency(%q<open_uri_redirections>, [">= 0"])
174
- s.add_dependency(%q<shoulda>, ["> 2.10"])
175
- s.add_dependency(%q<shoulda-context>, [">= 0"])
176
- s.add_dependency(%q<shoulda-matchers>, [">= 0"])
177
- s.add_dependency(%q<bundler>, ["> 1.0.21"])
178
- s.add_dependency(%q<jeweler>, [">= 0"])
179
- s.add_dependency(%q<rcov>, [">= 0"])
180
- s.add_dependency(%q<simplecov>, [">= 0"])
181
- s.add_dependency(%q<ruby-prof>, [">= 0"])
182
- s.add_dependency(%q<rdoc>, [">= 0"])
168
+ s.add_dependency(%q<shoulda>, ["= 2.10"])
183
169
  s.add_dependency(%q<test-unit>, [">= 0"])
170
+ s.add_dependency(%q<juwelier>, [">= 0"])
171
+ s.add_dependency(%q<rack>, ["= 1.6.4"])
184
172
  end
185
173
  else
186
174
  s.add_dependency(%q<bio-svgenes>, [">= 0.4.1"])
187
175
  s.add_dependency(%q<bio>, [">= 1.4.2"])
188
- s.add_dependency(%q<open_uri_redirections>, [">= 0"])
189
- s.add_dependency(%q<shoulda>, ["> 2.10"])
190
- s.add_dependency(%q<shoulda-context>, [">= 0"])
191
- s.add_dependency(%q<shoulda-matchers>, [">= 0"])
192
- s.add_dependency(%q<bundler>, ["> 1.0.21"])
193
- s.add_dependency(%q<jeweler>, [">= 0"])
194
- s.add_dependency(%q<rcov>, [">= 0"])
195
- s.add_dependency(%q<simplecov>, [">= 0"])
196
- s.add_dependency(%q<ruby-prof>, [">= 0"])
197
- s.add_dependency(%q<rdoc>, [">= 0"])
176
+ s.add_dependency(%q<shoulda>, ["= 2.10"])
198
177
  s.add_dependency(%q<test-unit>, [">= 0"])
178
+ s.add_dependency(%q<juwelier>, [">= 0"])
179
+ s.add_dependency(%q<rack>, ["= 1.6.4"])
199
180
  end
200
181
  end
201
182
 
@@ -45,11 +45,25 @@ module Bio::DB::Fasta
45
45
  end
46
46
 
47
47
  class Entry
48
- attr_reader :id, :length
49
-
50
- def initialize(id, length)
48
+ attr_reader :id, :length, :line_bases, :line_length, :offset
49
+ alias_method :size, :length
50
+ def initialize(id, length, offset = 0 , line_bases= 0 , line_length = 0 )
51
51
  @id=id
52
52
  @length=length.to_i
53
+ @offset = offset.to_i
54
+ @line_bases = line_bases.to_i
55
+ @line_length = line_length.to_i
56
+ end
57
+
58
+ def get_base_coordinate(coordinate)
59
+ lines_for_offset = coordinate / line_bases
60
+ line_offset = coordinate % line_bases
61
+ #puts "get_base_coordinate"
62
+ #puts "Coordinate: #{coordinate}"
63
+ #puts "lines_for_offset: #{lines_for_offset}"
64
+ #puts "line pffset: #{line_offset}"
65
+ #puts self.inspect
66
+ pointer = offset + (line_length * lines_for_offset) + line_offset - 1
53
67
  end
54
68
 
55
69
  def get_full_region
@@ -79,9 +93,6 @@ module Bio::DB::Fasta
79
93
  @orientation = args[:orientation]
80
94
  end
81
95
 
82
-
83
-
84
-
85
96
  #TODO: Debug, as it hasnt been tested in the actual code.
86
97
  def allele_freq_for_base(base)
87
98
  @all_ratios = Hash.new unless @all_ratios
@@ -144,8 +155,9 @@ module Bio::DB::Fasta
144
155
  def self.parse_region(reg_str)
145
156
  string = reg_str.delete("'")
146
157
  fields_1 = string.split(":")
158
+ raise FastaDBException.new(), "Invalid region. #{string}" if fields_1.length != 2
147
159
  fields_2 = fields_1[1].split("-")
148
- raise FastaDBException.new(), "Invalid region. #{string}" if fields_1.length != 2 || fields_2.length != 2
160
+ raise FastaDBException.new(), "Invalid region. #{string}" if fields_2.length != 2
149
161
 
150
162
  reg = Region.new(:entry=> fields_1[0], :start=>fields_2[0].to_i, :end=>fields_2[1].to_i)
151
163
 
@@ -174,9 +186,11 @@ module Bio::DB::Fasta
174
186
  #Initialize the fasta file. If the fai file doesn't exists, it is generated at startup
175
187
  #* fasta path to the fasta file
176
188
  #* samtools path to samtools, if it is not provided, use the bundled version
177
- def initialize(args)
178
- @fasta_path = args[:fasta]
179
- @samtools = args[:samtools] || File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools')
189
+ def initialize(fasta: nil, samtools: false)
190
+ #puts "The arguments are: '#{fasta}':'#{samtools}'"
191
+ @fasta_path = fasta
192
+ @samtools = samtools
193
+ @samtools = File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools') if samtools == true
180
194
  raise FastaDBException.new(), "No path for the refernce fasta file. " if @fasta_path.nil?
181
195
  @fai_file = @fasta_path + ".fai"
182
196
  unless File.file?(@fai_file) then
@@ -184,7 +198,6 @@ module Bio::DB::Fasta
184
198
  @last_command = command
185
199
  system(command)
186
200
  end
187
-
188
201
  end
189
202
 
190
203
  #Loads the fai entries
@@ -194,7 +207,7 @@ module Bio::DB::Fasta
194
207
  fai_file = @fai_file
195
208
  File.open(fai_file).each do | line |
196
209
  fields = line.split("\t")
197
- @index << Entry.new(fields[0], fields[1])
210
+ @index << Entry.new(fields[0], fields[1], fields[2], fields[3], fields[4])
198
211
  end
199
212
  @index.length
200
213
  end
@@ -217,9 +230,22 @@ module Bio::DB::Fasta
217
230
  end
218
231
  end
219
232
 
233
+ def index
234
+ return @index if @index
235
+ if @samtools
236
+ faidx
237
+ else
238
+ samtools = File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools')
239
+ #TODO: make a ruby implementations
240
+ command = "#{samtools} faidx #{@fasta_path}"
241
+ @last_command = command
242
+ system(command)
243
+ end
244
+ load_fai_entries
245
+ return @index
246
+ end
220
247
 
221
- #The region needs to have a method to_region or a method to_s that ha the format "chromosome:start-end" as in samtools
222
- def fetch_sequence(region)
248
+ def fetch_sequence_samtools(region)
223
249
  query = region.to_s
224
250
  query = region.to_region.to_s if region.respond_to?(:to_region)
225
251
  command = "#{@samtools} faidx #{@fasta_path} '#{query}'"
@@ -227,11 +253,38 @@ module Bio::DB::Fasta
227
253
  @last_command = command
228
254
  seq = ""
229
255
  yield_from_pipe(command, String, :text ) {|line| seq = seq + line unless line =~ /^>/}
256
+ seq
257
+ end
230
258
 
231
- reference = Bio::Sequence::NA.new(seq)
259
+ def fetch_sequence_native(region)
260
+ query = region
261
+ query = Region.parse_region(region) unless region.is_a?(Region)
262
+ seq = ""
263
+ #In order to make this reentrant, if we want to make a multithreaded
264
+ #version of this function, we need to get a lock. Currently, only one thred
265
+ #can be assosiated with eache fastadb object
266
+ @fasta_file = File.open(@fasta_path) unless @fasta_file
267
+ entry = index.region_for_entry(query.entry)
268
+
269
+ start_pointer = entry.get_base_coordinate(query.start)
270
+ @fasta_file.seek(start_pointer, IO::SEEK_SET)
271
+ end_pointer = entry.get_base_coordinate(query.end)
272
+ to_read = end_pointer - start_pointer + 1
273
+ seq = @fasta_file.read(to_read)
274
+ seq.gsub!(/\s+/, '')
275
+ seq
276
+ end
232
277
 
233
- if region.orientation == :reverse
234
- #puts "reversing! #{reference.to_s}"
278
+ #The region needs to have a method to_region or a method to_s that ha the format "chromosome:start-end" as in samtools
279
+ def fetch_sequence(region)
280
+ load_fai_entries
281
+ region = Region.parse_region(region.to_s) unless region.is_a?(Region)
282
+ entry = index.region_for_entry(region.entry)
283
+ raise FastaDBException.new "Entry (#{region.entry})not found in reference" unless entry
284
+ raise FastaDBException.new "Region in invalid range (#{region}): Valid range: #{entry.to_region.to_s} has a size of #{entry.size}." if region.end > entry.size or region.start < 1
285
+ seq = @samtools ? fetch_sequence_samtools(region): fetch_sequence_native(region)
286
+ reference = Bio::Sequence::NA.new(seq)
287
+ if region.respond_to? :orientation and region.orientation == :reverse
235
288
  reference.reverse_complement!()
236
289
  end
237
290
  reference
@@ -0,0 +1,34 @@
1
+ >chr_1
2
+ CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTA
3
+ ACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC
4
+ TAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAAC
5
+ CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTA
6
+ ACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACGTGAATGCCGAGGA
7
+ TTATACCGATGTTGTTGGTCAGCTTGCCCGCGGACATATGGATGAAGAGGAGAAGATTCTTGAGGTGGCC
8
+ AAGAAGCTTATGCCTTCTAAGCCAACAACCCTCAAGGATATGAGCAAGTGGCGTTCCTTCTTTGAAAACT
9
+ GGAACTTGTACATGAGTCAGTGTCGCGGTGCTGCGGCTATCCCTCTTTCGTACGTTTACCGTACCAACGA
10
+ GCAGCCCGAGACCGCTTTGGTCGGAACCTATGTGAATATGGATGCCTATTTGGTTGCCCAGACAGTACTG
11
+ TCTGGTTCCAACTTTGAGATCGATAATCAATGGGTTTTTGACGAATTCAAGGAAGCAATCACTACAACCG
12
+ GACCTGGTTGGTCTTTCATCAAGACGTACAACCGAAGCAAGGACGGTCGTGCTGCCATTTTGAAATTAAA
13
+ GGAACAGGCGGAAGGAACATTAAACGAGTCCGTTCGCCGTGATGATGCCATCAAGATCCTGTCAACTACG
14
+ >chr.2
15
+ ACATACAATGGTCCGAGTTGTAACTGGAATATTGATATGCTGTTGCAGAAATTTCAGTATGCCATCTCGG
16
+ AATTGGTCGAAATTGACGGAGTCGCGTTGCCGGATGGGCAGCTTGTGACTTATTTGGTCCAGGCATTGAA
17
+ GCGCAGCTTTTTGTGAAGACTTTTGTGTCTTCGTCCACGAGCAAATCCGAAAACACGCCTCGACAGGTCA
18
+ ATGATGTGCAAACATCAGGTAGTGGGGCCTCCGGTGGGAGTAAGAAAGGAGGTACCGGGAAAGGAGCCAG
19
+ CAAGCAGACTCCCTTCAAGGGTGCAGTCACGGCTCGCAGTTATACTCCGGGAGAATGGAAAAGATTGTCC
20
+ AAGGACCAACAGGAAAAAGTGCGATCGCTGCGTAATAAAAAGAAGCAAGGAGGGAAACCCGAGGAATCAG
21
+ AGAGGAGTGTTGACAGTGTAGCACGGGATGAGCCTGTGGACACTAAGGAAGTCCATACCAGCAGTGATAT
22
+ GGAACCGACTTCAGATGCGGCTGGCCTGCAATTTGGCCGTGGTGCGTATAAGAAATCGGTCGGATTCACT
23
+ GCGGACACCGCTTCTCCTTCAGAAAACGGAACGAAGAAGCAGAAAACGCATCACGATGCGTGAAACGCGG
24
+ CACCCAATGCCAGTGTTTCGGGGACTAAGCAATGCATTTTACCAGATCGAGTGATATTGAGCCTCACCTC
25
+ TACACGCAGCATTTGTGATCTCAACGCATGCACTCATCTTGGTGAGGGCCGCTGCGAGTTGGATTCACAT
26
+ >chr_3
27
+ GCAGACACATGCGTGGCTGGGGCAAACACTGTCTTGATTGGTGAATCGCAGAAGTCCGTAACTGTGCG
28
+ CTTTCTCCGGTGAATATTCTGCACTGAAGAATATCCCCATTGGAACGGTTGCCACAGCTTACACAGCC
29
+ AGAAGACGGGAGAGTGGTGCTTCTTATTATTAATCAGGCCCTATTCTTTGGGGACAGATTGAAACACC
30
+ CTAGACCCCCAACCAGATGCGAGACTTTGGCATTGAAGTTGACGATGCCCCTCGGCAGTACGTCGCCA
31
+ ACCAAGCACTCTTTGTATGTTCCTGACTCCCAACTTCGGATTCCGCTGCAGCTGCGCGGTATATTCTC
32
+ GTTTTTGGAGTCGGAAGCCCACGCAACAGGAACTTGACGAGTGTGAGCATATCATACTCACCTCTGAT
33
+ GTGCCGTGGGACTTGCTCAACGGACTTTGCCCGTCGAGAAGAAGAGGCCGCTAAGAGAGACCGGAGCG
34
+ TATCATTGACACAACGGGACTTTCCACTGGCCACGCAATCCTATCAGCACACCCATATGGTATACG
@@ -0,0 +1,87 @@
1
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
2
+ $: << File.expand_path('.')
3
+
4
+ require 'rubygems'
5
+ require 'bio/db/sam'
6
+ require "test/unit"
7
+ #gem 'ruby-prof'
8
+ gem 'test-unit'
9
+ #require "ruby-prof"
10
+
11
+
12
+ class TestBioDbfastaDB < Test::Unit::TestCase
13
+
14
+ def setup
15
+ @test_folder = "test/samples/small"
16
+ @testReference = @test_folder + "/test_fastadb.fasta"
17
+ @fasta_local = Bio::DB::Fasta::FastaFile.new(
18
+ fasta: @testReference,
19
+ samtools: false
20
+ )
21
+
22
+ @fasta_samtools = Bio::DB::Fasta::FastaFile.new(
23
+ :fasta => @testReference,
24
+ samtools: true
25
+ )
26
+ end
27
+ class << self
28
+ def shutdown
29
+ File.delete("test/samples/small/test_fastadb.fasta.fai")
30
+ end
31
+ end
32
+
33
+ def test_faidx
34
+ @fasta_samtools.index()
35
+ test_fai_file = @testReference+".fai"
36
+ #test that the .fai file exists
37
+ assert_nothing_thrown do
38
+ File.open(test_fai_file, "r")
39
+ end
40
+ #test that the file is not empty
41
+ assert(File.size(test_fai_file) > 0, "From test_faidx: .fai file is empty")
42
+ end
43
+
44
+
45
+
46
+ def test_fetch_reference
47
+ #this is the first 70 nucleotides of the test seqeunce
48
+ @fasta_samtools.faidx()
49
+
50
+ test_regions = { "chr_1:1-70" => "CCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTA",
51
+ "chr_1:68-74" => "CTAACCC",
52
+ "chr.2:300-450" => "GGTGCAGTCACGGCTCGCAGTTATACTCCGGGAGAATGGAAAAGATTGTCCAAGGACCAA\
53
+ CAGGAAAAAGTGCGATCGCTGCGTAATAAAAAGAAGCAAGGAG\
54
+ GGAAACCCGAGGAATCAGAGAGGAGTGTTGACAGTGTAGCACGGGATG",
55
+ "chr_3:536-542" => "GTATACG",
56
+ "chr.2:765-770" => "TCACAT"
57
+ }
58
+
59
+ test_regions.each_pair do |region, seq_expected|
60
+ seq_fetched = @fasta_samtools.fetch_sequence(region)
61
+ assert_equal(seq_expected, seq_fetched.upcase)
62
+
63
+ seq_fetched_local = @fasta_local.fetch_sequence(region)
64
+ assert_equal(seq_expected, seq_fetched_local.upcase)
65
+ end
66
+
67
+ test_regions = {
68
+ "chr_3:772-780" => Bio::DB::Fasta::FastaDBException,
69
+ "chr_3:-1-10" => Bio::DB::Fasta::FastaDBException,
70
+ "chr_3:0-10" => Bio::DB::Fasta::FastaDBException,
71
+ "bfafdaads" => Bio::DB::Fasta::FastaDBException,
72
+ "chr.2:765-771" => Bio::DB::Fasta::FastaDBException,
73
+ "chr_2:765-770" => Bio::DB::Fasta::FastaDBException,
74
+
75
+ }
76
+ test_regions.each_pair do |region, expected_eception|
77
+ assert_raise expected_eception do
78
+ seq_fetched = @fasta_samtools.fetch_sequence(region)
79
+ end
80
+
81
+ assert_raise expected_eception do
82
+ seq_fetched_local = @fasta_local.fetch_sequence(region)
83
+ end
84
+ end
85
+ end
86
+
87
+ end
@@ -343,7 +343,7 @@ class TestBioDbSam < Test::Unit::TestCase
343
343
  bam_files = [bam_to_merge1, bam_to_merge2]
344
344
 
345
345
  merged_bam_file = @test_folder + "/maps_merged.bam"
346
- File.delete merged_bam_file if File.exists?(merged_bam_file)
346
+ File.delete merged_bam_file if File.exist?(merged_bam_file)
347
347
  # File.delete("test/samples/small/maps_merged.bam")
348
348
  @sam.merge(:out=>merged_bam_file, :bams=>bam_files, :n=>true)
349
349
  merged_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => merged_bam_file)
@@ -364,7 +364,7 @@ class TestBioDbSam < Test::Unit::TestCase
364
364
  bam_files = [bam1, bam2]
365
365
 
366
366
  cat_bam_file = @test_folder + "/maps_cated.bam"
367
- File.delete cat_bam_file if File.exists?(cat_bam_file)
367
+ File.delete cat_bam_file if File.exist?(cat_bam_file)
368
368
  @sam.merge(:out=>cat_bam_file, :bams=>bam_files)
369
369
  cated_bam = Bio::DB::Sam.new(:fasta => @testReference, :bam => cat_bam_file)
370
370
 
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.4.0
4
+ version: 2.5.1
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: 2016-05-25 00:00:00.000000000 Z
13
+ date: 2016-11-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bio-svgenes
@@ -40,120 +40,22 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 1.4.2
43
- - !ruby/object:Gem::Dependency
44
- name: open_uri_redirections
45
- requirement: !ruby/object:Gem::Requirement
46
- requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: '0'
50
- type: :runtime
51
- prerelease: false
52
- version_requirements: !ruby/object:Gem::Requirement
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: '0'
57
43
  - !ruby/object:Gem::Dependency
58
44
  name: shoulda
59
45
  requirement: !ruby/object:Gem::Requirement
60
46
  requirements:
61
- - - ">"
47
+ - - '='
62
48
  - !ruby/object:Gem::Version
63
49
  version: '2.10'
64
50
  type: :development
65
51
  prerelease: false
66
52
  version_requirements: !ruby/object:Gem::Requirement
67
53
  requirements:
68
- - - ">"
54
+ - - '='
69
55
  - !ruby/object:Gem::Version
70
56
  version: '2.10'
71
57
  - !ruby/object:Gem::Dependency
72
- name: shoulda-context
73
- requirement: !ruby/object:Gem::Requirement
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- type: :development
79
- prerelease: false
80
- version_requirements: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ">="
83
- - !ruby/object:Gem::Version
84
- version: '0'
85
- - !ruby/object:Gem::Dependency
86
- name: shoulda-matchers
87
- requirement: !ruby/object:Gem::Requirement
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: '0'
92
- type: :development
93
- prerelease: false
94
- version_requirements: !ruby/object:Gem::Requirement
95
- requirements:
96
- - - ">="
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- - !ruby/object:Gem::Dependency
100
- name: bundler
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ">"
104
- - !ruby/object:Gem::Version
105
- version: 1.0.21
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ">"
111
- - !ruby/object:Gem::Version
112
- version: 1.0.21
113
- - !ruby/object:Gem::Dependency
114
- name: jeweler
115
- requirement: !ruby/object:Gem::Requirement
116
- requirements:
117
- - - ">="
118
- - !ruby/object:Gem::Version
119
- version: '0'
120
- type: :development
121
- prerelease: false
122
- version_requirements: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - ">="
125
- - !ruby/object:Gem::Version
126
- version: '0'
127
- - !ruby/object:Gem::Dependency
128
- name: rcov
129
- requirement: !ruby/object:Gem::Requirement
130
- requirements:
131
- - - ">="
132
- - !ruby/object:Gem::Version
133
- version: '0'
134
- type: :development
135
- prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
137
- requirements:
138
- - - ">="
139
- - !ruby/object:Gem::Version
140
- version: '0'
141
- - !ruby/object:Gem::Dependency
142
- name: simplecov
143
- requirement: !ruby/object:Gem::Requirement
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- version: '0'
148
- type: :development
149
- prerelease: false
150
- version_requirements: !ruby/object:Gem::Requirement
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- version: '0'
155
- - !ruby/object:Gem::Dependency
156
- name: ruby-prof
58
+ name: test-unit
157
59
  requirement: !ruby/object:Gem::Requirement
158
60
  requirements:
159
61
  - - ">="
@@ -167,7 +69,7 @@ dependencies:
167
69
  - !ruby/object:Gem::Version
168
70
  version: '0'
169
71
  - !ruby/object:Gem::Dependency
170
- name: rdoc
72
+ name: juwelier
171
73
  requirement: !ruby/object:Gem::Requirement
172
74
  requirements:
173
75
  - - ">="
@@ -181,19 +83,19 @@ dependencies:
181
83
  - !ruby/object:Gem::Version
182
84
  version: '0'
183
85
  - !ruby/object:Gem::Dependency
184
- name: test-unit
86
+ name: rack
185
87
  requirement: !ruby/object:Gem::Requirement
186
88
  requirements:
187
- - - ">="
89
+ - - '='
188
90
  - !ruby/object:Gem::Version
189
- version: '0'
91
+ version: 1.6.4
190
92
  type: :development
191
93
  prerelease: false
192
94
  version_requirements: !ruby/object:Gem::Requirement
193
95
  requirements:
194
- - - ">="
96
+ - - '='
195
97
  - !ruby/object:Gem::Version
196
- version: '0'
98
+ version: 1.6.4
197
99
  description: "Binder of samtools for ruby, on the top of FFI. \n\n This project was
198
100
  born from the need to add support of BAM files to \n the gee_fu genome browser
199
101
  (http://github.com/danmaclean/gee_fu)."
@@ -319,9 +221,11 @@ files:
319
221
  - test/samples/small/test_chr.fasta.rsa
320
222
  - test/samples/small/test_chr.fasta.sa
321
223
  - test/samples/small/test_cov.svg
224
+ - test/samples/small/test_fastadb.fasta
322
225
  - test/samples/small/testu.bam
323
226
  - test/samples/small/testu.bed
324
227
  - test/test_bio-samtools.rb
228
+ - test/test_fastadb.rb
325
229
  - test/test_pileup.rb
326
230
  - test/test_sam.rb
327
231
  - test/test_vcf.rb
@@ -348,7 +252,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
348
252
  version: '0'
349
253
  requirements: []
350
254
  rubyforge_project:
351
- rubygems_version: 2.2.2
255
+ rubygems_version: 2.5.1
352
256
  signing_key:
353
257
  specification_version: 4
354
258
  summary: Binder of samtools for ruby, on the top of FFI.