bio-samtools-server 0.1.1 → 0.1.2
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/bin/bam-server.rb +4 -0
- data/lib/bio-samtools-server.rb +1 -0
- data/lib/bio-samtools-server/samtools-extensions.rb +25 -0
- data/lib/bio-samtools-server/samtools-server.rb +46 -9
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c918eeecb592ab3dfd5263d500924d5125741161
|
4
|
+
data.tar.gz: cf157144793f62bbdaade370d637962525d80405
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c9207d1efb79e1f8899bdc71010d154e927395ab61e026906333a334946ff714ca7edd28ecaef52425b1881f6fd3d583804408f166918bca323b8978bde7dc5
|
7
|
+
data.tar.gz: 60f92d49a1485bb1e92914f04617a1c6d48b9ef14ce542d4998e95b2235043f235efc15d3e07e022f51eb6b634f12f6d2db09c6b9ca6694168b19623f7b1004f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/bin/bam-server.rb
CHANGED
@@ -21,6 +21,10 @@ OptionParser.new do |opts|
|
|
21
21
|
opts.on("-f", "--bam FOLDER", "Folder containing the BAM files") do |o|
|
22
22
|
options[:folder] = o
|
23
23
|
end
|
24
|
+
|
25
|
+
opts.on("-b", "--biojs FOLDER", "Folder containing the compiled biojs module (optinal)") do |o|
|
26
|
+
options[:biojs] = o
|
27
|
+
end
|
24
28
|
|
25
29
|
end.parse!
|
26
30
|
|
data/lib/bio-samtools-server.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Bio::DB::Fasta::Region
|
2
|
+
def to_wig(opts={})
|
3
|
+
step_size = opts[:step_size] ? opts[:step_size] : 1
|
4
|
+
|
5
|
+
out = StringIO.new
|
6
|
+
out << "fixedStep chrom=#{self.entry} span=#{step_size}\n"
|
7
|
+
return out.string if self.pileup.size == 0
|
8
|
+
current_start = self.pileup[0].pos
|
9
|
+
current_acc = 0.0
|
10
|
+
current_end = current_start + step_size
|
11
|
+
|
12
|
+
self.pileup.each do |pile|
|
13
|
+
|
14
|
+
if pile.pos >= current_end
|
15
|
+
out << current_start << " " << (current_acc/step_size).to_s << "\n"
|
16
|
+
current_start = pile.pos
|
17
|
+
current_acc = 0.0
|
18
|
+
current_end = current_start + step_size
|
19
|
+
end
|
20
|
+
current_acc += pile.coverage
|
21
|
+
|
22
|
+
end
|
23
|
+
out.string
|
24
|
+
end
|
25
|
+
end
|
@@ -24,23 +24,60 @@ module Bio::WS
|
|
24
24
|
return @bam_files[bam]
|
25
25
|
end
|
26
26
|
|
27
|
-
get '/' do
|
28
|
-
|
27
|
+
get '/biojs/*' do
|
28
|
+
file=params[:splat]
|
29
|
+
biojs_path = "#{self.settings.biojs.to_s}"
|
30
|
+
File.read(File.join(biojs_path, file))
|
31
|
+
end
|
29
32
|
|
33
|
+
get '/alignment' do
|
30
34
|
bam = params[:bam]
|
31
35
|
region = params[:region]
|
32
36
|
ref = params[:ref]
|
33
|
-
|
34
|
-
# "Hello World from MyApp in separate file! #{ self.settings.folder.to_s} #{bam} #{region}"
|
35
|
-
#self.settings.folder.to_s
|
37
|
+
reg = Bio::DB::Fasta::Region.parse_region(region)
|
36
38
|
stream do |out|
|
37
|
-
get_bam(bam, ref).fetch(
|
38
|
-
# test that all the objects are Bio::DB::Alignment objects
|
39
|
-
#assert_equal(sam.class, Bio::DB::Alignment)
|
40
|
-
#assert_equal(sam.rname, "chr_1")
|
39
|
+
get_bam(bam, ref).fetch(reg.entry, reg.start, reg.end) do |sam|
|
41
40
|
out << "#{sam.sam_string}\n"
|
42
41
|
end
|
43
42
|
end
|
44
43
|
end
|
44
|
+
|
45
|
+
get '/wig' do
|
46
|
+
bam = params[:bam]
|
47
|
+
region = params[:region]
|
48
|
+
ref = params[:ref]
|
49
|
+
step_size = 1
|
50
|
+
step_size = params[:step_size].to_i if params[:step_size]
|
51
|
+
step_size = 1 if step_size < 1
|
52
|
+
reg = Bio::DB::Fasta::Region.parse_region(region)
|
53
|
+
stream do |out|
|
54
|
+
pile_region = get_bam(bam, ref).fetch_region({:region=>reg})
|
55
|
+
out << pile_region.to_wig({:step_size=>step_size})
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
get '/reference' do
|
60
|
+
bam = params[:bam]
|
61
|
+
region = params[:region]
|
62
|
+
ref = params[:ref]
|
63
|
+
reg = Bio::DB::Fasta::Region.parse_region(region)
|
64
|
+
stream do |out|
|
65
|
+
ref = get_bam(bam, ref).fetch_reference(reg.entry, reg.start, reg.end)
|
66
|
+
out << "#{ref}\n"
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
get '/list' do
|
72
|
+
bam = params[:bam]
|
73
|
+
ref = params[:ref]
|
74
|
+
stream do |out|
|
75
|
+
get_bam(bam, ref).each_region do |reg|
|
76
|
+
out << "#{reg.to_s}\n"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
|
45
82
|
end
|
46
83
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bio-samtools-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- homonecloco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bio-samtools
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- VERSION
|
143
143
|
- bin/bam-server.rb
|
144
144
|
- lib/bio-samtools-server.rb
|
145
|
+
- lib/bio-samtools-server/samtools-extensions.rb
|
145
146
|
- lib/bio-samtools-server/samtools-server.rb
|
146
147
|
- test/helper.rb
|
147
148
|
- test/test_bio-samtools-server.rb
|