bio-gngm 0.1.0

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.
Files changed (105) hide show
  1. data/.document +5 -0
  2. data/Gemfile +20 -0
  3. data/Gemfile.lock +33 -0
  4. data/LICENSE.txt +20 -0
  5. data/README.rdoc +33 -0
  6. data/Rakefile +53 -0
  7. data/VERSION +1 -0
  8. data/bio-gngm.gemspec +173 -0
  9. data/doc/Bio.html +129 -0
  10. data/doc/Bio/DB.html +128 -0
  11. data/doc/Bio/DB/Pileup.html +316 -0
  12. data/doc/Bio/DB/Vcf.html +683 -0
  13. data/doc/Bio/Util.html +135 -0
  14. data/doc/Bio/Util/Gngm.html +1655 -0
  15. data/doc/LICENSE_txt.html +111 -0
  16. data/doc/_index.html +169 -0
  17. data/doc/class_list.html +47 -0
  18. data/doc/created.rid +4 -0
  19. data/doc/css/common.css +1 -0
  20. data/doc/css/full_list.css +55 -0
  21. data/doc/css/style.css +322 -0
  22. data/doc/doc/created.rid +0 -0
  23. data/doc/file_list.html +52 -0
  24. data/doc/frames.html +13 -0
  25. data/doc/images/add.png +0 -0
  26. data/doc/images/bands.png +0 -0
  27. data/doc/images/brick.png +0 -0
  28. data/doc/images/brick_link.png +0 -0
  29. data/doc/images/bug.png +0 -0
  30. data/doc/images/bullet_black.png +0 -0
  31. data/doc/images/bullet_toggle_minus.png +0 -0
  32. data/doc/images/bullet_toggle_plus.png +0 -0
  33. data/doc/images/date.png +0 -0
  34. data/doc/images/delete.png +0 -0
  35. data/doc/images/find.png +0 -0
  36. data/doc/images/loadingAnimation.gif +0 -0
  37. data/doc/images/macFFBgHack.png +0 -0
  38. data/doc/images/package.png +0 -0
  39. data/doc/images/page_green.png +0 -0
  40. data/doc/images/page_white_text.png +0 -0
  41. data/doc/images/page_white_width.png +0 -0
  42. data/doc/images/plugin.png +0 -0
  43. data/doc/images/ruby.png +0 -0
  44. data/doc/images/signal.png +0 -0
  45. data/doc/images/tag_blue.png +0 -0
  46. data/doc/images/tag_green.png +0 -0
  47. data/doc/images/threads.png +0 -0
  48. data/doc/images/transparent.png +0 -0
  49. data/doc/images/wrench.png +0 -0
  50. data/doc/images/wrench_orange.png +0 -0
  51. data/doc/images/zoom.png +0 -0
  52. data/doc/index.html +88 -0
  53. data/doc/js/app.js +205 -0
  54. data/doc/js/darkfish.js +153 -0
  55. data/doc/js/full_list.js +167 -0
  56. data/doc/js/jquery.js +18 -0
  57. data/doc/js/navigation.js +142 -0
  58. data/doc/js/search.js +94 -0
  59. data/doc/js/search_index.js +1 -0
  60. data/doc/js/searcher.js +228 -0
  61. data/doc/lib/bio-gngm_rb.html +103 -0
  62. data/doc/lib/bio/util/bio-gngm_rb.html +96 -0
  63. data/doc/method_list.html +382 -0
  64. data/doc/rdoc.css +543 -0
  65. data/doc/table_of_contents.html +161 -0
  66. data/examples/.DS_Store +0 -0
  67. data/examples/make_histograms.rb +40 -0
  68. data/examples/make_threads.rb +42 -0
  69. data/examples/make_threads_isize.rb +41 -0
  70. data/examples/use_indels.rb +36 -0
  71. data/lib/bio-gngm.rb +12 -0
  72. data/lib/bio/util/bio-gngm.rb +1029 -0
  73. data/scripts/get_subseq.rb +16 -0
  74. data/scripts/make_histograms_laerfyve.rb +83 -0
  75. data/scripts/make_histograms_laerfyve_stitched.rb +59 -0
  76. data/scripts/make_threads_isize_laerfyfe.rb +52 -0
  77. data/scripts/make_threads_unmapped_laerfyfe.rb +72 -0
  78. data/scripts/make_threads_unmapped_laerfyfe_pseudo.rb +56 -0
  79. data/scripts/make_threads_unmapped_simulation.rb +54 -0
  80. data/scripts/make_threads_unmapped_simulation_immediate_region.rb +59 -0
  81. data/scripts/optimise_freq_window_size.rb +82 -0
  82. data/stitched_contigs.zip +0 -0
  83. data/test/data/ids2.txt +1 -0
  84. data/test/data/sorted.bam +0 -0
  85. data/test/data/test +0 -0
  86. data/test/data/test.bam +0 -0
  87. data/test/data/test.fa +20 -0
  88. data/test/data/test.fai +0 -0
  89. data/test/data/test.sai +0 -0
  90. data/test/data/test.tam +10 -0
  91. data/test/data/test_chr.fasta +1000 -0
  92. data/test/data/test_chr.fasta.amb +2 -0
  93. data/test/data/test_chr.fasta.ann +3 -0
  94. data/test/data/test_chr.fasta.bwt +0 -0
  95. data/test/data/test_chr.fasta.fai +1 -0
  96. data/test/data/test_chr.fasta.pac +0 -0
  97. data/test/data/test_chr.fasta.rbwt +0 -0
  98. data/test/data/test_chr.fasta.rpac +0 -0
  99. data/test/data/test_chr.fasta.rsa +0 -0
  100. data/test/data/test_chr.fasta.sa +0 -0
  101. data/test/data/testu.bam +0 -0
  102. data/test/data/testu.bam.bai +0 -0
  103. data/test/helper.rb +18 -0
  104. data/test/test_bio-gngm.rb +126 -0
  105. metadata +276 -0
@@ -0,0 +1,2 @@
1
+ 69930 1 1
2
+ 41554 50 N
@@ -0,0 +1,3 @@
1
+ 69930 1 11
2
+ 0 chr_1 (null)
3
+ 0 69930 1
@@ -0,0 +1 @@
1
+ chr_1 69930 7 70 71
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'bio-gngm'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,126 @@
1
+ require 'helper'
2
+
3
+ class TestBioGngm < Test::Unit::TestCase
4
+
5
+ context "Classes in bio/db/sam" do
6
+ should "contain Pileup" do
7
+ assert_instance_of Bio::DB::Pileup, Bio::DB::Pileup.new("seq1\t272\tT\t24\t,.$.....,,.,.,...,,,.,..^+.\t<<<+;<<<<<<<<<<<=<;<;7<&")
8
+ end
9
+
10
+ should "contain Vcf " do
11
+ assert_instance_of Bio::DB::Vcf, Bio::DB::Vcf.new("20 14370 rs6054257 G A 29 0 NS=3;DP=14;AF=0.5;DB;H2 GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:-1,-1")
12
+ end
13
+ end
14
+
15
+ context "A Pileup instance" do
16
+ setup do
17
+ @p1 = Bio::DB::Pileup.new("seq1\t272\tT\t10\t,.$.....,,.^+.\t<<<+;<<<<<<<<<<<=<;<;7<&")
18
+ @p2 = Bio::DB::Pileup.new("seq1\t272\tT\t24\taaaaaaaaaaaa............\t<<<+;<<<<<<<<<<<=<;<;7<&")
19
+ @p3 = Bio::DB::Pileup.new("seq1\t272\tT\t24\taaaaaaaaaaaaaaaaaaaaaaaa\t<<<+;<<<<<<<<<<<=<;<;7<&")
20
+ @p4 = Bio::DB::Pileup.new("seq1\t272\tT\t9\taaaaaaaGGC\t<<<+;<<<<<<<<<<<=<;<;7<&")
21
+ end
22
+
23
+ should "calculate discordant chastity" do
24
+ assert_equal @p1.discordant_chastity, 0.0
25
+ assert_equal @p2.discordant_chastity, 0.5
26
+ assert_equal @p3.discordant_chastity, 1.0
27
+ assert_equal @p4.discordant_chastity, 0.7777777777777778
28
+ end
29
+
30
+ should "know it is a snp" do
31
+ assert @p2.is_snp?(:min_depth => 5, :min_non_ref => 5)
32
+ assert !@p1.is_snp?(:min_depth => 5, :min_non_ref => 5)
33
+ end
34
+ end
35
+
36
+ context "A Gngm object" do
37
+ setup do
38
+ @g1 = Bio::Util::Gngm.new(:file => "test/data/testu.bam",
39
+ :format => :bam,
40
+ :fasta => "test/data/test_chr.fasta",
41
+ :samtools => {:r => "chr_1:100-300"}
42
+ )
43
+ @g1.snp_positions
44
+
45
+ @g2 = Bio::Util::Gngm.new(:file => "/Users/macleand/Desktop/ngm/fli.sorted.bam",
46
+ :format => :bam,
47
+ :fasta => "/Users/macleand/Desktop/ngm/TAIR9_chr_all.fas",
48
+ :samtools => {:r => "1:100-10000"},
49
+ :histo_bin_width => 100,
50
+
51
+ )
52
+ end
53
+
54
+
55
+ should "open BAM files" do
56
+ assert_instance_of Bio::DB::Sam, @g1.file
57
+ end
58
+
59
+ should "return array of snps annotated with discordant chastity" do
60
+ assert_instance_of Array, @g1.snp_positions
61
+ assert_equal [[185, 0.3333333333333333], [203, 0.3333333333333333], [279, 0.5]], @g1.snp_positions
62
+ end
63
+
64
+ should "draw a picture of a SNP histogram" do
65
+ @g1.frequency_histogram("test_histo.png")
66
+ assert File.exists?("test_histo.png")
67
+ File.delete("test_histo.png")
68
+ end
69
+
70
+ should "get chastity threads" do
71
+ @g1.snp_positions
72
+ assert_equal [[0.3, [185, 203]],[0.4, []],[0.5, [279]], [0.6000000000000001, []], [0.7, []],[0.8, []],[0.9000000000000001, []],[1.0, []]], @g1.threads(:start => 0.3, :stop => 1, :slide => 0.1, :size => 0.1)
73
+ end
74
+
75
+ should "draw chastity threads" do
76
+ @g2.snp_positions
77
+ @g2.calculate_clusters(:k =>4, :set_seed => 1)
78
+ @g2.draw_threads("test_threads.png")
79
+ assert File.exists?("test_threads.png")
80
+ #File.delete("test_threads.png")
81
+ end
82
+
83
+
84
+ should "return lists of densities for each window from R" do
85
+ @g1.snp_positions
86
+ #puts @g1.densities[0]
87
+ assert_instance_of Array, @g1.densities
88
+ assert_instance_of Array, @g1.densities.first
89
+ assert_equal 0.24, @g1.densities[0].first
90
+ end
91
+
92
+ should "find index of window in the @densities array" do
93
+ @g2.snp_positions
94
+ assert_equal 65, @g2.find_index(1.0)
95
+ end
96
+
97
+ should "find bands ie cluster and return list of threads in that cluster together" do
98
+ @g2.snp_positions
99
+ @g2.calculate_clusters(:k => 4, :set_seed => 1) ##due to randomness of clustering, its currently hard to make sure this is exactly tested..
100
+ #setting the seed ensures consistent clustering ...
101
+ assert_equal [0.21000000000000002, 0.22, 0.8200000000000001, 0.8300000000000001, 0.8400000000000001, 0.8500000000000001, 0.8600000000000001, 0.97, 0.98, 0.99, 1.0], @g2.get_band(0.22)
102
+ end
103
+
104
+ should "draw found bands" do
105
+ @g2.snp_positions
106
+ @g2.calculate_clusters(:k => 4, :set_seed => 1)
107
+ @g2.draw_bands("test_bands.png")
108
+ assert File.exists?("test_bands.png")
109
+ #File.delete("test_bands.png")
110
+ end
111
+
112
+ should "draw_signal_plots" do
113
+ @g2.snp_positions
114
+ @g2.calculate_clusters(:k => 4, :set_seed => 1)
115
+ @g2.draw_signal("signal.png")
116
+ File.delete("signal.png")
117
+ end
118
+
119
+ should "calculate signal" do
120
+ @g2.snp_positions
121
+ @g2.calculate_clusters(:k => 4, :set_seed => 1)
122
+ assert_equal 1.157971267690456, @g2.signal.last
123
+ end
124
+ end
125
+
126
+ end
metadata ADDED
@@ -0,0 +1,276 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-gngm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan MacLean
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bio
16
+ requirement: &70226478302620 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.4.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70226478302620
25
+ - !ruby/object:Gem::Dependency
26
+ name: bio-samtools
27
+ requirement: &70226478299960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.5.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70226478299960
36
+ - !ruby/object:Gem::Dependency
37
+ name: rinruby
38
+ requirement: &70226478297240 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.0.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70226478297240
47
+ - !ruby/object:Gem::Dependency
48
+ name: shoulda
49
+ requirement: &70226478383720 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70226478383720
58
+ - !ruby/object:Gem::Dependency
59
+ name: bundler
60
+ requirement: &70226478382700 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: 1.0.0
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70226478382700
69
+ - !ruby/object:Gem::Dependency
70
+ name: jeweler
71
+ requirement: &70226478381080 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70226478381080
80
+ - !ruby/object:Gem::Dependency
81
+ name: rcov
82
+ requirement: &70226478380320 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70226478380320
91
+ - !ruby/object:Gem::Dependency
92
+ name: bio
93
+ requirement: &70226478379680 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.4.2
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *70226478379680
102
+ - !ruby/object:Gem::Dependency
103
+ name: bio-samtools
104
+ requirement: &70226478379180 !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: 0.5.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: *70226478379180
113
+ - !ruby/object:Gem::Dependency
114
+ name: rinruby
115
+ requirement: &70226478378620 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ! '>='
119
+ - !ruby/object:Gem::Version
120
+ version: 2.0.2
121
+ type: :development
122
+ prerelease: false
123
+ version_requirements: *70226478378620
124
+ - !ruby/object:Gem::Dependency
125
+ name: rdoc
126
+ requirement: &70226478378060 !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: *70226478378060
135
+ description: Identify causative mutations in a model genome from NGS reads using the
136
+ NGM method.
137
+ email: maclean.daniel@gmail.com
138
+ executables: []
139
+ extensions: []
140
+ extra_rdoc_files:
141
+ - LICENSE.txt
142
+ - README.rdoc
143
+ files:
144
+ - .document
145
+ - Gemfile
146
+ - Gemfile.lock
147
+ - LICENSE.txt
148
+ - README.rdoc
149
+ - Rakefile
150
+ - VERSION
151
+ - bio-gngm.gemspec
152
+ - doc/Bio.html
153
+ - doc/Bio/DB.html
154
+ - doc/Bio/DB/Pileup.html
155
+ - doc/Bio/DB/Vcf.html
156
+ - doc/Bio/Util.html
157
+ - doc/Bio/Util/Gngm.html
158
+ - doc/LICENSE_txt.html
159
+ - doc/_index.html
160
+ - doc/class_list.html
161
+ - doc/created.rid
162
+ - doc/css/common.css
163
+ - doc/css/full_list.css
164
+ - doc/css/style.css
165
+ - doc/doc/created.rid
166
+ - doc/file_list.html
167
+ - doc/frames.html
168
+ - doc/images/add.png
169
+ - doc/images/bands.png
170
+ - doc/images/brick.png
171
+ - doc/images/brick_link.png
172
+ - doc/images/bug.png
173
+ - doc/images/bullet_black.png
174
+ - doc/images/bullet_toggle_minus.png
175
+ - doc/images/bullet_toggle_plus.png
176
+ - doc/images/date.png
177
+ - doc/images/delete.png
178
+ - doc/images/find.png
179
+ - doc/images/loadingAnimation.gif
180
+ - doc/images/macFFBgHack.png
181
+ - doc/images/package.png
182
+ - doc/images/page_green.png
183
+ - doc/images/page_white_text.png
184
+ - doc/images/page_white_width.png
185
+ - doc/images/plugin.png
186
+ - doc/images/ruby.png
187
+ - doc/images/signal.png
188
+ - doc/images/tag_blue.png
189
+ - doc/images/tag_green.png
190
+ - doc/images/threads.png
191
+ - doc/images/transparent.png
192
+ - doc/images/wrench.png
193
+ - doc/images/wrench_orange.png
194
+ - doc/images/zoom.png
195
+ - doc/index.html
196
+ - doc/js/app.js
197
+ - doc/js/darkfish.js
198
+ - doc/js/full_list.js
199
+ - doc/js/jquery.js
200
+ - doc/js/navigation.js
201
+ - doc/js/search.js
202
+ - doc/js/search_index.js
203
+ - doc/js/searcher.js
204
+ - doc/lib/bio-gngm_rb.html
205
+ - doc/lib/bio/util/bio-gngm_rb.html
206
+ - doc/method_list.html
207
+ - doc/rdoc.css
208
+ - doc/table_of_contents.html
209
+ - examples/.DS_Store
210
+ - examples/make_histograms.rb
211
+ - examples/make_threads.rb
212
+ - examples/make_threads_isize.rb
213
+ - examples/use_indels.rb
214
+ - lib/bio-gngm.rb
215
+ - lib/bio/util/bio-gngm.rb
216
+ - scripts/get_subseq.rb
217
+ - scripts/make_histograms_laerfyve.rb
218
+ - scripts/make_histograms_laerfyve_stitched.rb
219
+ - scripts/make_threads_isize_laerfyfe.rb
220
+ - scripts/make_threads_unmapped_laerfyfe.rb
221
+ - scripts/make_threads_unmapped_laerfyfe_pseudo.rb
222
+ - scripts/make_threads_unmapped_simulation.rb
223
+ - scripts/make_threads_unmapped_simulation_immediate_region.rb
224
+ - scripts/optimise_freq_window_size.rb
225
+ - stitched_contigs.zip
226
+ - test/data/ids2.txt
227
+ - test/data/sorted.bam
228
+ - test/data/test
229
+ - test/data/test.bam
230
+ - test/data/test.fa
231
+ - test/data/test.fai
232
+ - test/data/test.sai
233
+ - test/data/test.tam
234
+ - test/data/test_chr.fasta
235
+ - test/data/test_chr.fasta.amb
236
+ - test/data/test_chr.fasta.ann
237
+ - test/data/test_chr.fasta.bwt
238
+ - test/data/test_chr.fasta.fai
239
+ - test/data/test_chr.fasta.pac
240
+ - test/data/test_chr.fasta.rbwt
241
+ - test/data/test_chr.fasta.rpac
242
+ - test/data/test_chr.fasta.rsa
243
+ - test/data/test_chr.fasta.sa
244
+ - test/data/testu.bam
245
+ - test/data/testu.bam.bai
246
+ - test/helper.rb
247
+ - test/test_bio-gngm.rb
248
+ homepage: http://github.com/danmaclean/bioruby-gngm
249
+ licenses:
250
+ - MIT
251
+ post_install_message:
252
+ rdoc_options: []
253
+ require_paths:
254
+ - lib
255
+ required_ruby_version: !ruby/object:Gem::Requirement
256
+ none: false
257
+ requirements:
258
+ - - ! '>='
259
+ - !ruby/object:Gem::Version
260
+ version: '0'
261
+ segments:
262
+ - 0
263
+ hash: 3948590901607660961
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
265
+ none: false
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
270
+ requirements: []
271
+ rubyforge_project:
272
+ rubygems_version: 1.8.10
273
+ signing_key:
274
+ specification_version: 3
275
+ summary: Next-Generation Mapping of Mutations
276
+ test_files: []