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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e23edcddef2395d0d46cb0d405c9931280af98ee
4
- data.tar.gz: e2887c08e5853df572e72f32008c4e3266a46849
3
+ metadata.gz: c918eeecb592ab3dfd5263d500924d5125741161
4
+ data.tar.gz: cf157144793f62bbdaade370d637962525d80405
5
5
  SHA512:
6
- metadata.gz: 590478424e3e6613786cfd4c3b114bc3b904bfd90440c6783e4f9d36c9c8595d6c30432986591d853639ec3ef24d9b1c1702036ac815e232438191afcea44519
7
- data.tar.gz: 4cc09d1c5ca6c921730b0e8626cc7ade786afb1705f84a10f1e05bb5b12aa160ea2f03fbd2438e658c1cbca3464a06c45e97f3a0a92e86f5d74a92065225aa4d
6
+ metadata.gz: 9c9207d1efb79e1f8899bdc71010d154e927395ab61e026906333a334946ff714ca7edd28ecaef52425b1881f6fd3d583804408f166918bca323b8978bde7dc5
7
+ data.tar.gz: 60f92d49a1485bb1e92914f04617a1c6d48b9ef14ce542d4998e95b2235043f235efc15d3e07e022f51eb6b634f12f6d2db09c6b9ca6694168b19623f7b1004f
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.1
1
+ 0.1.2
@@ -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
 
@@ -9,4 +9,5 @@
9
9
  # In this file only require other files. Avoid other source code.
10
10
  require 'bio-samtools'
11
11
  require 'bio-samtools-server/samtools-server.rb'
12
+ require 'bio-samtools-server/samtools-extensions.rb'
12
13
 
@@ -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
- folder = settings.folder.to_s
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("chr_1", 10,1000) do |sam|
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.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-04-27 00:00:00.000000000 Z
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