bio-samtools 2.6.0 → 2.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bio-samtools.gemspec +2 -2
- data/lib/bio/db/fastadb.rb +6 -3
- data/lib/bio/db/pileup.rb +7 -1
- data/lib/bio/db/sam.rb +10 -4
- data/test/test_fastadb.rb +7 -5
- data/test/test_sam.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94952e1666a5c9bb480bc7e2d0636e8a7e581927
|
4
|
+
data.tar.gz: e6958ffe7198152b72f47bbdda23df054e723150
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a3ded21f99ebfb2b1de0ad8d9d819d4c9de0e74719b446fbffdba394100c1970458fc020c564583f0a5eeb60d0b368db75c0b96c1362173121d24819fb7b0d7
|
7
|
+
data.tar.gz: 7cf4e0fac18c81ce20a31588f98452a34ed9d25916048c9c1fbe562129ff96c15ab880c9f4e6299f442935db72b716ff7c1fa7e109fe6ccbdc558c11bb71b719
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.6.
|
1
|
+
2.6.1
|
data/bio-samtools.gemspec
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: bio-samtools 2.6.
|
5
|
+
# stub: bio-samtools 2.6.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".freeze
|
10
|
-
s.version = "2.6.
|
10
|
+
s.version = "2.6.1"
|
11
11
|
|
12
12
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
13
13
|
s.require_paths = ["lib".freeze]
|
data/lib/bio/db/fastadb.rb
CHANGED
@@ -64,6 +64,7 @@ module Bio::DB::Fasta
|
|
64
64
|
#puts "line pffset: #{line_offset}"
|
65
65
|
#puts self.inspect
|
66
66
|
pointer = offset + (line_length * lines_for_offset) + line_offset - 1
|
67
|
+
pointer
|
67
68
|
end
|
68
69
|
|
69
70
|
def get_full_region
|
@@ -181,7 +182,7 @@ module Bio::DB::Fasta
|
|
181
182
|
|
182
183
|
#Class that holds the fasta file. It is used as a database.
|
183
184
|
class FastaFile
|
184
|
-
attr_reader :
|
185
|
+
attr_reader :fasta_path
|
185
186
|
|
186
187
|
#Initialize the fasta file. If the fai file doesn't exists, it is generated at startup
|
187
188
|
#* fasta path to the fasta file
|
@@ -190,6 +191,8 @@ module Bio::DB::Fasta
|
|
190
191
|
#puts "The arguments are: '#{fasta}':'#{samtools}'"
|
191
192
|
@fasta_path = fasta
|
192
193
|
@samtools = samtools
|
194
|
+
@index = nil
|
195
|
+
@fasta_file = nil
|
193
196
|
@samtools = File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools') if samtools == true
|
194
197
|
raise FastaDBException.new(), "No path for the refernce fasta file. " if @fasta_path.nil?
|
195
198
|
@fai_file = @fasta_path + ".fai"
|
@@ -249,7 +252,7 @@ module Bio::DB::Fasta
|
|
249
252
|
query = region.to_s
|
250
253
|
query = region.to_region.to_s if region.respond_to?(:to_region)
|
251
254
|
command = "#{@samtools} faidx #{@fasta_path} '#{query}'"
|
252
|
-
puts command if $VERBOSE
|
255
|
+
puts "Running: #{command}" if $VERBOSE
|
253
256
|
@last_command = command
|
254
257
|
seq = ""
|
255
258
|
yield_from_pipe(command, String, :text ) {|line| seq = seq + line unless line =~ /^>/}
|
@@ -295,7 +298,7 @@ module Bio::DB::Fasta
|
|
295
298
|
#is forwarded to the default stdout
|
296
299
|
def yield_from_pipe(command, klass, type=:text, skip_comments=true, comment_char="#", &block)
|
297
300
|
stdin, pipe, stderr, wait_thr = Open3.popen3(command)
|
298
|
-
pid = wait_thr[:pid] # pid of the started process.
|
301
|
+
#pid = wait_thr[:pid] # pid of the started process.
|
299
302
|
if type == :text
|
300
303
|
while (line = pipe.gets)
|
301
304
|
next if skip_comments and line[0] == comment_char
|
data/lib/bio/db/pileup.rb
CHANGED
@@ -27,13 +27,19 @@
|
|
27
27
|
module Bio
|
28
28
|
class DB
|
29
29
|
class Pileup
|
30
|
-
attr_accessor :ref_name, :pos, :ref_base, :coverage, :read_bases, :read_quals, :
|
30
|
+
attr_accessor :ref_name, :pos, :ref_base, :coverage, :read_bases, :read_quals, :consensus_quality, :snp_quality, :rms_mapq, :ar1, :ar2, :ar3, :indel_1, :indel_2
|
31
31
|
|
32
32
|
#creates the Pileup object
|
33
33
|
# pile_up_line = "seq2\t151\tG\tG\t36\t0\t99\t12\t...........A\t:9<;;7=<<<<<"
|
34
34
|
# pile = Bio::DB::Pileup.new(pile_up_line)
|
35
35
|
def initialize(pile_up_line)
|
36
36
|
cols = pile_up_line.split(/\t/)
|
37
|
+
@consensus = nil
|
38
|
+
@consensus_quality = nil
|
39
|
+
@read_quals = nil
|
40
|
+
@bases = nil
|
41
|
+
@allele_frequency = nil
|
42
|
+
@consensus_iuap = nil
|
37
43
|
if cols.length == 6 ##should only be able to get 6 lines from mpileup
|
38
44
|
@ref_name, @pos, @ref_base, @coverage, @read_bases, @read_quals = cols
|
39
45
|
elsif (10..13).include?(cols.length) ##incase anyone tries to use deprecated pileup with -c flag we get upto 13 cols...
|
data/lib/bio/db/sam.rb
CHANGED
@@ -20,10 +20,16 @@ module Bio
|
|
20
20
|
def initialize(args)
|
21
21
|
@fasta = args[:fasta]
|
22
22
|
@bam = args[:bam]
|
23
|
+
@bams = nil
|
24
|
+
@sam = nil
|
25
|
+
@files = nil
|
26
|
+
@cached_regions = nil
|
27
|
+
@stats = nil
|
23
28
|
@samtools = args[:samtools] || File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools')
|
24
29
|
@bcftools = args[:bcftools] || File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','bcftools')
|
25
30
|
|
26
31
|
@files = [@files] if @files.instance_of?(String)
|
32
|
+
|
27
33
|
|
28
34
|
@last_command = nil
|
29
35
|
raise ArgumentError, "Need Fasta and at least one BAM or SAM" if not @fasta or not @bam
|
@@ -67,7 +73,7 @@ module Bio
|
|
67
73
|
region = String.new
|
68
74
|
if opts[:chr] and opts[:start] and opts[:stop]
|
69
75
|
has_e = self.has_entry? opts[:chr]
|
70
|
-
raise SamException.new(), "[view] The sequence #{opts[:chr]} is not in the bam file" unless
|
76
|
+
raise SamException.new(), "[view] The sequence #{opts[:chr]} is not in the bam file" unless has_e
|
71
77
|
region = "#{opts[:chr]}:#{opts[:start]}-#{opts[:stop]}"
|
72
78
|
[:chr, :start, :stop].each {|o| opts.delete(o)}
|
73
79
|
end
|
@@ -712,13 +718,13 @@ module Bio
|
|
712
718
|
|
713
719
|
# checks existence of files in instance
|
714
720
|
def files_ok?
|
715
|
-
[@fasta, @sam, @bam].flatten.compact.each {|f| return false unless File.
|
721
|
+
[@fasta, @sam, @bam].flatten.compact.each {|f| return false unless File.exist? f }
|
716
722
|
true
|
717
723
|
end
|
718
724
|
|
719
725
|
#Returns true if the .bai exists. It doesn't validate if it is valid.
|
720
726
|
def indexed?
|
721
|
-
File.exists? @bam and File.
|
727
|
+
File.exists? @bam and File.exist? "#{@bam}.bai"
|
722
728
|
end
|
723
729
|
|
724
730
|
private
|
@@ -727,7 +733,7 @@ module Bio
|
|
727
733
|
def yield_from_pipe(command, klass, type=:text, skip_comments=true, comment_char="#", &block)
|
728
734
|
puts "[yield_from_pipe] #{command}" if $VERBOSE
|
729
735
|
stdin, pipe, stderr, wait_thr = Open3.popen3(command)
|
730
|
-
pid = wait_thr[:pid] # pid of the started process.
|
736
|
+
#pid = wait_thr[:pid] # pid of the started process.
|
731
737
|
if type == :text
|
732
738
|
while (line = pipe.gets)
|
733
739
|
next if skip_comments and line[0] == comment_char
|
data/test/test_fastadb.rb
CHANGED
@@ -24,7 +24,7 @@ class TestBioDbfastaDB < Test::Unit::TestCase
|
|
24
24
|
samtools: true
|
25
25
|
)
|
26
26
|
end
|
27
|
-
|
27
|
+
class << self
|
28
28
|
def shutdown
|
29
29
|
File.delete("test/samples/small/test_fastadb.fasta.fai")
|
30
30
|
end
|
@@ -43,7 +43,7 @@ class TestBioDbfastaDB < Test::Unit::TestCase
|
|
43
43
|
|
44
44
|
|
45
45
|
|
46
|
-
|
46
|
+
def test_fetch_reference
|
47
47
|
#this is the first 70 nucleotides of the test seqeunce
|
48
48
|
@fasta_samtools.faidx()
|
49
49
|
|
@@ -73,15 +73,17 @@ GGAAACCCGAGGAATCAGAGAGGAGTGTTGACAGTGTAGCACGGGATG",
|
|
73
73
|
"chr_2:765-770" => Bio::DB::Fasta::FastaDBException,
|
74
74
|
|
75
75
|
}
|
76
|
+
|
76
77
|
test_regions.each_pair do |region, expected_eception|
|
77
78
|
assert_raise expected_eception do
|
78
|
-
seq_fetched =
|
79
|
+
#seq_fetched =
|
80
|
+
@fasta_samtools.fetch_sequence(region)
|
79
81
|
end
|
80
82
|
|
81
83
|
assert_raise expected_eception do
|
82
|
-
seq_fetched_local =
|
84
|
+
#seq_fetched_local =
|
85
|
+
@fasta_local.fetch_sequence(region)
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
86
|
-
|
87
89
|
end
|
data/test/test_sam.rb
CHANGED
@@ -178,7 +178,7 @@ class TestBioDbSam < Test::Unit::TestCase
|
|
178
178
|
end
|
179
179
|
|
180
180
|
def test_index_stats
|
181
|
-
puts "Stats: #{@sam.index_stats.inspect}"
|
181
|
+
#puts "Stats: #{@sam.index_stats.inspect}"
|
182
182
|
@sam.index_stats.each_pair do |seq, stat|
|
183
183
|
assert_send([['chr_1' , '*'], :member?, seq])
|
184
184
|
end
|