bio-samtools-wrapper 2.7.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 (125) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.travis.yml +27 -0
  4. data/Gemfile +20 -0
  5. data/LICENSE.txt +702 -0
  6. data/README.md +501 -0
  7. data/Rakefile +73 -0
  8. data/VERSION +1 -0
  9. data/bin/bam_consensus.rb +85 -0
  10. data/bio-samtools-wrapper.gemspec +181 -0
  11. data/doc/Bio/DB/Alignment.html +552 -0
  12. data/doc/Bio/DB/Pileup.html +711 -0
  13. data/doc/Bio/DB/SAM/Library.html +167 -0
  14. data/doc/Bio/DB/SAM/Tools.html +109 -0
  15. data/doc/Bio/DB/SAM.html +1853 -0
  16. data/doc/Bio/DB/Tag.html +208 -0
  17. data/doc/Bio/DB/Vcf.html +431 -0
  18. data/doc/Bio/DB.html +105 -0
  19. data/doc/Bio.html +175 -0
  20. data/doc/LICENSE_txt.html +846 -0
  21. data/doc/created.rid +9 -0
  22. data/doc/fonts/Lato-Light.ttf +0 -0
  23. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  24. data/doc/fonts/Lato-Regular.ttf +0 -0
  25. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  26. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  27. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  28. data/doc/fonts.css +167 -0
  29. data/doc/images/add.png +0 -0
  30. data/doc/images/arrow_up.png +0 -0
  31. data/doc/images/brick.png +0 -0
  32. data/doc/images/brick_link.png +0 -0
  33. data/doc/images/bug.png +0 -0
  34. data/doc/images/bullet_black.png +0 -0
  35. data/doc/images/bullet_toggle_minus.png +0 -0
  36. data/doc/images/bullet_toggle_plus.png +0 -0
  37. data/doc/images/date.png +0 -0
  38. data/doc/images/delete.png +0 -0
  39. data/doc/images/find.png +0 -0
  40. data/doc/images/loadingAnimation.gif +0 -0
  41. data/doc/images/macFFBgHack.png +0 -0
  42. data/doc/images/package.png +0 -0
  43. data/doc/images/page_green.png +0 -0
  44. data/doc/images/page_white_text.png +0 -0
  45. data/doc/images/page_white_width.png +0 -0
  46. data/doc/images/plugin.png +0 -0
  47. data/doc/images/ruby.png +0 -0
  48. data/doc/images/tag_blue.png +0 -0
  49. data/doc/images/tag_green.png +0 -0
  50. data/doc/images/transparent.png +0 -0
  51. data/doc/images/wrench.png +0 -0
  52. data/doc/images/wrench_orange.png +0 -0
  53. data/doc/images/zoom.png +0 -0
  54. data/doc/index.html +106 -0
  55. data/doc/js/darkfish.js +140 -0
  56. data/doc/js/jquery.js +18 -0
  57. data/doc/js/navigation.js +142 -0
  58. data/doc/js/search.js +109 -0
  59. data/doc/js/search_index.js +1 -0
  60. data/doc/js/searcher.js +228 -0
  61. data/doc/rdoc.css +580 -0
  62. data/doc/table_of_contents.html +305 -0
  63. data/ext/Makefile-bioruby.patch +12 -0
  64. data/ext/Makefile-suse.patch +11 -0
  65. data/ext/mkrf_conf.rb +118 -0
  66. data/lib/bio/BIOExtensions.rb +89 -0
  67. data/lib/bio/db/alignment.rb +64 -0
  68. data/lib/bio/db/fastadb.rb +320 -0
  69. data/lib/bio/db/pileup.rb +273 -0
  70. data/lib/bio/db/sam/external/COPYING +21 -0
  71. data/lib/bio/db/sam/external/VERSION +1 -0
  72. data/lib/bio/db/sam/library.rb +32 -0
  73. data/lib/bio/db/sam.rb +778 -0
  74. data/lib/bio/db/vcf.rb +105 -0
  75. data/lib/bio-samtools-wrapper.rb +9 -0
  76. data/test/.gitignore +1 -0
  77. data/test/helper.rb +18 -0
  78. data/test/sample.vcf +24 -0
  79. data/test/samples/.gitignore +1 -0
  80. data/test/samples/LCI/NC_001988.ffn +2 -0
  81. data/test/samples/LCI/test.bam +0 -0
  82. data/test/samples/LCI/test.bam.bai +0 -0
  83. data/test/samples/small/dupes.bam +0 -0
  84. data/test/samples/small/dupes.sam +274 -0
  85. data/test/samples/small/ids2.txt +1 -0
  86. data/test/samples/small/map_for_reheader.sam +8 -0
  87. data/test/samples/small/map_to_merge1.bam +0 -0
  88. data/test/samples/small/map_to_merge1.bam.bai +0 -0
  89. data/test/samples/small/map_to_merge1.sam +8 -0
  90. data/test/samples/small/map_to_merge2.bam +0 -0
  91. data/test/samples/small/map_to_merge2.bam.bai +0 -0
  92. data/test/samples/small/map_to_merge2.sam +8 -0
  93. data/test/samples/small/no_md.sam +8 -0
  94. data/test/samples/small/sorted.bam +0 -0
  95. data/test/samples/small/sorted.bam.bai +0 -0
  96. data/test/samples/small/test.sai +0 -0
  97. data/test/samples/small/test.tam +10 -0
  98. data/test/samples/small/test_chr.fasta +1000 -0
  99. data/test/samples/small/test_chr.fasta.1.bt2 +0 -0
  100. data/test/samples/small/test_chr.fasta.2.bt2 +0 -0
  101. data/test/samples/small/test_chr.fasta.3.bt2 +0 -0
  102. data/test/samples/small/test_chr.fasta.4.bt2 +0 -0
  103. data/test/samples/small/test_chr.fasta.amb +2 -0
  104. data/test/samples/small/test_chr.fasta.ann +3 -0
  105. data/test/samples/small/test_chr.fasta.bwt +0 -0
  106. data/test/samples/small/test_chr.fasta.pac +0 -0
  107. data/test/samples/small/test_chr.fasta.rbwt +0 -0
  108. data/test/samples/small/test_chr.fasta.rev.1.bt2 +0 -0
  109. data/test/samples/small/test_chr.fasta.rev.2.bt2 +0 -0
  110. data/test/samples/small/test_chr.fasta.rpac +0 -0
  111. data/test/samples/small/test_chr.fasta.rsa +0 -0
  112. data/test/samples/small/test_chr.fasta.sa +0 -0
  113. data/test/samples/small/test_cov.svg +273 -0
  114. data/test/samples/small/test_fastadb.fasta +34 -0
  115. data/test/samples/small/testu.bam +0 -0
  116. data/test/samples/small/testu.bed +2 -0
  117. data/test/test_bio-samtools-wrapper.rb +1 -0
  118. data/test/test_fastadb.rb +89 -0
  119. data/test/test_pileup.rb +90 -0
  120. data/test/test_sam.rb +421 -0
  121. data/test/test_vcf.rb +79 -0
  122. data/tutorial/tutorial.html +474 -0
  123. data/tutorial/tutorial.md +424 -0
  124. data/tutorial/tutorial.pdf +0 -0
  125. metadata +254 -0
@@ -0,0 +1,208 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Bio::DB::Tag - Pileup</title>
8
+
9
+ <link href="../../fonts.css" rel="stylesheet">
10
+ <link href="../../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../../";
14
+ </script>
15
+
16
+ <script src="../../js/jquery.js"></script>
17
+ <script src="../../js/navigation.js"></script>
18
+ <script src="../../js/search_index.js"></script>
19
+ <script src="../../js/search.js"></script>
20
+ <script src="../../js/searcher.js"></script>
21
+ <script src="../../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../../table_of_contents.html#pages">Pages</a>
34
+ <a href="../../table_of_contents.html#classes">Classes</a>
35
+ <a href="../../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
63
+
64
+ <p class="link">Object
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li ><a href="#method-i-set">#set</a>
77
+
78
+ </ul>
79
+ </div>
80
+
81
+ </div>
82
+ </nav>
83
+
84
+ <main role="main" aria-labelledby="class-Bio::DB::Tag">
85
+ <h1 id="class-Bio::DB::Tag" class="class">
86
+ class Bio::DB::Tag
87
+ </h1>
88
+
89
+ <section class="description">
90
+
91
+ <p>a class to represent the SAM OPT values, presented in SAM as
92
+ TAG:VTYPE:VALUE</p>
93
+
94
+ </section>
95
+
96
+
97
+
98
+
99
+ <section id="5Buntitled-5D" class="documentation-section">
100
+
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <section class="attribute-method-details" class="method-section">
108
+ <header>
109
+ <h3>Attributes</h3>
110
+ </header>
111
+
112
+
113
+ <div id="attribute-i-tag" class="method-detail">
114
+ <div class="method-heading attribute-method-heading">
115
+ <span class="method-name">tag</span><span
116
+ class="attribute-access-type">[RW]</span>
117
+ </div>
118
+
119
+ <div class="method-description">
120
+
121
+
122
+
123
+ </div>
124
+ </div>
125
+
126
+ <div id="attribute-i-type" class="method-detail">
127
+ <div class="method-heading attribute-method-heading">
128
+ <span class="method-name">type</span><span
129
+ class="attribute-access-type">[RW]</span>
130
+ </div>
131
+
132
+ <div class="method-description">
133
+
134
+
135
+
136
+ </div>
137
+ </div>
138
+
139
+ <div id="attribute-i-value" class="method-detail">
140
+ <div class="method-heading attribute-method-heading">
141
+ <span class="method-name">value</span><span
142
+ class="attribute-access-type">[RW]</span>
143
+ </div>
144
+
145
+ <div class="method-description">
146
+
147
+
148
+
149
+ </div>
150
+ </div>
151
+
152
+ </section>
153
+
154
+
155
+
156
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
157
+ <header>
158
+ <h3>Public Instance Methods</h3>
159
+ </header>
160
+
161
+
162
+ <div id="method-i-set" class="method-detail ">
163
+
164
+ <div class="method-heading">
165
+ <span class="method-name">set</span><span
166
+ class="method-args">(str)</span>
167
+
168
+ <span class="method-click-advice">click to toggle source</span>
169
+
170
+ </div>
171
+
172
+
173
+ <div class="method-description">
174
+
175
+
176
+
177
+
178
+
179
+
180
+ <div class="method-source-code" id="set-source">
181
+ <pre><span class="ruby-comment"># File lib/bio/db/alignment.rb, line 7</span>
182
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">set</span>(<span class="ruby-identifier">str</span>)
183
+ <span class="ruby-ivar">@tag</span> = <span class="ruby-identifier">str</span>[<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">1</span>]
184
+ <span class="ruby-ivar">@type</span> = <span class="ruby-identifier">str</span>[<span class="ruby-value">3</span>]
185
+ <span class="ruby-ivar">@value</span> = <span class="ruby-identifier">str</span>[<span class="ruby-value">5</span><span class="ruby-operator">..</span><span class="ruby-value">-1</span>]
186
+ <span class="ruby-keyword">end</span></pre>
187
+ </div>
188
+
189
+ </div>
190
+
191
+
192
+
193
+
194
+ </div>
195
+
196
+
197
+ </section>
198
+
199
+ </section>
200
+ </main>
201
+
202
+
203
+ <footer id="validator-badges" role="contentinfo">
204
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
205
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
206
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
207
+ </footer>
208
+
@@ -0,0 +1,431 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class Bio::DB::Vcf - Pileup</title>
8
+
9
+ <link href="../../fonts.css" rel="stylesheet">
10
+ <link href="../../rdoc.css" rel="stylesheet">
11
+
12
+ <script type="text/javascript">
13
+ var rdoc_rel_prefix = "../../";
14
+ </script>
15
+
16
+ <script src="../../js/jquery.js"></script>
17
+ <script src="../../js/navigation.js"></script>
18
+ <script src="../../js/search_index.js"></script>
19
+ <script src="../../js/search.js"></script>
20
+ <script src="../../js/searcher.js"></script>
21
+ <script src="../../js/darkfish.js"></script>
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="../../index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="../../table_of_contents.html#pages">Pages</a>
34
+ <a href="../../table_of_contents.html#classes">Classes</a>
35
+ <a href="../../table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
63
+
64
+ <p class="link">Object
65
+
66
+ </div>
67
+
68
+
69
+
70
+ <!-- Method Quickref -->
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
73
+
74
+ <ul class="link-list" role="directory">
75
+
76
+ <li ><a href="#method-c-new">::new</a>
77
+
78
+ <li ><a href="#method-i-int_or_raw">#int_or_raw</a>
79
+
80
+ <li ><a href="#method-i-parse_line">#parse_line</a>
81
+
82
+ </ul>
83
+ </div>
84
+
85
+ </div>
86
+ </nav>
87
+
88
+ <main role="main" aria-labelledby="class-Bio::DB::Vcf">
89
+ <h1 id="class-Bio::DB::Vcf" class="class">
90
+ class Bio::DB::Vcf
91
+ </h1>
92
+
93
+ <section class="description">
94
+
95
+ </section>
96
+
97
+
98
+
99
+
100
+ <section id="5Buntitled-5D" class="documentation-section">
101
+
102
+
103
+
104
+
105
+
106
+
107
+
108
+ <section class="attribute-method-details" class="method-section">
109
+ <header>
110
+ <h3>Attributes</h3>
111
+ </header>
112
+
113
+
114
+ <div id="attribute-i-alt" class="method-detail">
115
+ <div class="method-heading attribute-method-heading">
116
+ <span class="method-name">alt</span><span
117
+ class="attribute-access-type">[RW]</span>
118
+ </div>
119
+
120
+ <div class="method-description">
121
+
122
+
123
+
124
+ </div>
125
+ </div>
126
+
127
+ <div id="attribute-i-chrom" class="method-detail">
128
+ <div class="method-heading attribute-method-heading">
129
+ <span class="method-name">chrom</span><span
130
+ class="attribute-access-type">[RW]</span>
131
+ </div>
132
+
133
+ <div class="method-description">
134
+
135
+
136
+
137
+ </div>
138
+ </div>
139
+
140
+ <div id="attribute-i-filter" class="method-detail">
141
+ <div class="method-heading attribute-method-heading">
142
+ <span class="method-name">filter</span><span
143
+ class="attribute-access-type">[RW]</span>
144
+ </div>
145
+
146
+ <div class="method-description">
147
+
148
+
149
+
150
+ </div>
151
+ </div>
152
+
153
+ <div id="attribute-i-format" class="method-detail">
154
+ <div class="method-heading attribute-method-heading">
155
+ <span class="method-name">format</span><span
156
+ class="attribute-access-type">[RW]</span>
157
+ </div>
158
+
159
+ <div class="method-description">
160
+
161
+
162
+
163
+ </div>
164
+ </div>
165
+
166
+ <div id="attribute-i-id" class="method-detail">
167
+ <div class="method-heading attribute-method-heading">
168
+ <span class="method-name">id</span><span
169
+ class="attribute-access-type">[RW]</span>
170
+ </div>
171
+
172
+ <div class="method-description">
173
+
174
+
175
+
176
+ </div>
177
+ </div>
178
+
179
+ <div id="attribute-i-info" class="method-detail">
180
+ <div class="method-heading attribute-method-heading">
181
+ <span class="method-name">info</span><span
182
+ class="attribute-access-type">[RW]</span>
183
+ </div>
184
+
185
+ <div class="method-description">
186
+
187
+
188
+
189
+ </div>
190
+ </div>
191
+
192
+ <div id="attribute-i-pos" class="method-detail">
193
+ <div class="method-heading attribute-method-heading">
194
+ <span class="method-name">pos</span><span
195
+ class="attribute-access-type">[RW]</span>
196
+ </div>
197
+
198
+ <div class="method-description">
199
+
200
+
201
+
202
+ </div>
203
+ </div>
204
+
205
+ <div id="attribute-i-qual" class="method-detail">
206
+ <div class="method-heading attribute-method-heading">
207
+ <span class="method-name">qual</span><span
208
+ class="attribute-access-type">[RW]</span>
209
+ </div>
210
+
211
+ <div class="method-description">
212
+
213
+
214
+
215
+ </div>
216
+ </div>
217
+
218
+ <div id="attribute-i-ref" class="method-detail">
219
+ <div class="method-heading attribute-method-heading">
220
+ <span class="method-name">ref</span><span
221
+ class="attribute-access-type">[RW]</span>
222
+ </div>
223
+
224
+ <div class="method-description">
225
+
226
+
227
+
228
+ </div>
229
+ </div>
230
+
231
+ <div id="attribute-i-samples" class="method-detail">
232
+ <div class="method-heading attribute-method-heading">
233
+ <span class="method-name">samples</span><span
234
+ class="attribute-access-type">[RW]</span>
235
+ </div>
236
+
237
+ <div class="method-description">
238
+
239
+
240
+
241
+ </div>
242
+ </div>
243
+
244
+ </section>
245
+
246
+
247
+
248
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
249
+ <header>
250
+ <h3>Public Class Methods</h3>
251
+ </header>
252
+
253
+
254
+ <div id="method-c-new" class="method-detail ">
255
+
256
+ <div class="method-heading">
257
+ <span class="method-name">new</span><span
258
+ class="method-args">(line=nil, sample_names=nil)</span>
259
+
260
+ <span class="method-click-advice">click to toggle source</span>
261
+
262
+ </div>
263
+
264
+
265
+ <div class="method-description">
266
+
267
+ <p>create the vcf object, use the ordered list of sample names to label
268
+ samples if provided [&#39;A&#39;, &#39;B&#39;, &#39;C&#39;], otherwise
269
+ uses, 1,2,3 etc</p>
270
+
271
+ <pre>vcf = Bio::DB::Vcf(&quot;19 111 . A C 9.6 . . GT:HQ 0|0:10,10 0|0:10,10 0/1:3,3&quot;)</pre>
272
+
273
+
274
+
275
+
276
+ <div class="method-source-code" id="new-source">
277
+ <pre><span class="ruby-comment"># File lib/bio/db/vcf.rb, line 15</span>
278
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">line</span>=<span class="ruby-keyword">nil</span>, <span class="ruby-identifier">sample_names</span>=<span class="ruby-keyword">nil</span>)
279
+ <span class="ruby-ivar">@info</span> = {}
280
+ <span class="ruby-ivar">@samples</span> = {}
281
+ <span class="ruby-identifier">parse_line</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">sample_names</span>) <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span>
282
+ <span class="ruby-keyword">end</span></pre>
283
+ </div>
284
+
285
+ </div>
286
+
287
+
288
+
289
+
290
+ </div>
291
+
292
+
293
+ </section>
294
+
295
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
296
+ <header>
297
+ <h3>Public Instance Methods</h3>
298
+ </header>
299
+
300
+
301
+ <div id="method-i-int_or_raw" class="method-detail ">
302
+
303
+ <div class="method-heading">
304
+ <span class="method-name">int_or_raw</span><span
305
+ class="method-args">(x)</span>
306
+
307
+ <span class="method-click-advice">click to toggle source</span>
308
+
309
+ </div>
310
+
311
+
312
+ <div class="method-description">
313
+
314
+ <p>tests if the current variable is an Integer</p>
315
+ <ul><li>
316
+ <p>x - any variable</p>
317
+ </li></ul>
318
+
319
+
320
+
321
+
322
+ <div class="method-source-code" id="int_or_raw-source">
323
+ <pre><span class="ruby-comment"># File lib/bio/db/vcf.rb, line 23</span>
324
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">int_or_raw</span>(<span class="ruby-identifier">x</span>)
325
+ <span class="ruby-constant">Integer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">x</span>) <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">x</span>
326
+ <span class="ruby-keyword">end</span></pre>
327
+ </div>
328
+
329
+ </div>
330
+
331
+
332
+
333
+
334
+ </div>
335
+
336
+
337
+ <div id="method-i-parse_line" class="method-detail ">
338
+
339
+ <div class="method-heading">
340
+ <span class="method-name">parse_line</span><span
341
+ class="method-args">(line, sample_names=nil)</span>
342
+
343
+ <span class="method-click-advice">click to toggle source</span>
344
+
345
+ </div>
346
+
347
+
348
+ <div class="method-description">
349
+
350
+ <p>gets the info in the <a href="Vcf.html">Vcf</a> lines and parses it,
351
+ setting the attributes</p>
352
+
353
+
354
+
355
+
356
+ <div class="method-source-code" id="parse_line-source">
357
+ <pre><span class="ruby-comment"># File lib/bio/db/vcf.rb, line 28</span>
358
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">parse_line</span>(<span class="ruby-identifier">line</span>, <span class="ruby-identifier">sample_names</span>=<span class="ruby-keyword">nil</span>)
359
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">false</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">line</span>[<span class="ruby-value">0</span>,<span class="ruby-value">1</span>] <span class="ruby-operator">==</span> <span class="ruby-string">&#39;#&#39;</span>
360
+
361
+ <span class="ruby-identifier">f</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;\t&quot;</span>, <span class="ruby-value">-1</span>)
362
+ <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;VCF lines must have at least 8 fields&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">8</span>
363
+ <span class="ruby-ivar">@chrom</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">0</span>]
364
+ <span class="ruby-ivar">@pos</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>
365
+ <span class="ruby-ivar">@id</span> = <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">2</span>] <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">2</span>]
366
+ <span class="ruby-ivar">@ref</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">3</span>]
367
+ <span class="ruby-ivar">@alt</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">4</span>]
368
+ <span class="ruby-ivar">@qual</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">5</span>].<span class="ruby-identifier">to_f</span>
369
+ <span class="ruby-ivar">@filter</span> = <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">6</span>] <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">6</span>]
370
+
371
+ <span class="ruby-ivar">@info</span> = <span class="ruby-string">&#39;.&#39;</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">f</span>[<span class="ruby-value">7</span>] <span class="ruby-operator">?</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">:</span> {}
372
+ <span class="ruby-keyword">if</span> <span class="ruby-ivar">@info</span>
373
+ <span class="ruby-identifier">info_vec</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">7</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;;&quot;</span>)
374
+ <span class="ruby-identifier">info_vec</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span>
375
+ <span class="ruby-identifier">keyval</span> = <span class="ruby-identifier">x</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;=&quot;</span>, <span class="ruby-value">-1</span>)
376
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">keyval</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span> <span class="ruby-comment"># If it&#39;s key=value</span>
377
+ <span class="ruby-ivar">@info</span>[<span class="ruby-identifier">keyval</span>[<span class="ruby-value">0</span>]] = <span class="ruby-identifier">keyval</span>[<span class="ruby-value">1</span>]
378
+ <span class="ruby-keyword">else</span> <span class="ruby-comment"># Otherwise, it&#39;s just a flag</span>
379
+ <span class="ruby-ivar">@info</span>[<span class="ruby-identifier">x</span>] = <span class="ruby-keyword">nil</span>
380
+ <span class="ruby-keyword">end</span>
381
+ <span class="ruby-keyword">end</span>
382
+ <span class="ruby-keyword">end</span>
383
+
384
+ <span class="ruby-ivar">@samples</span> = {}
385
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">8</span> <span class="ruby-comment"># Has just upto info</span>
386
+ <span class="ruby-identifier">raise</span> <span class="ruby-string">&quot;Can&#39;t have format with no samples&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">f</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">==</span> <span class="ruby-value">9</span>
387
+
388
+ <span class="ruby-ivar">@format</span> = <span class="ruby-identifier">f</span>[<span class="ruby-value">8</span>]
389
+
390
+ <span class="ruby-identifier">sample_keys</span> = <span class="ruby-ivar">@format</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;:&quot;</span>)
391
+
392
+ <span class="ruby-identifier">num_samples</span> = <span class="ruby-identifier">f</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">-</span> <span class="ruby-value">9</span> <span class="ruby-comment"># How many fields are past the format</span>
393
+
394
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">sample_names</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-comment"># Make the sample names just [&quot;1&quot;, &quot;2&quot;, ... , &quot;num_samples}&quot;</span>
395
+ <span class="ruby-identifier">sample_names</span> = (<span class="ruby-value">1</span><span class="ruby-operator">..</span><span class="ruby-identifier">num_samples</span>).<span class="ruby-identifier">to_a</span>.<span class="ruby-identifier">map</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">i</span>.<span class="ruby-identifier">to_s</span>}
396
+ <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">sample_names</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">!=</span> <span class="ruby-identifier">num_samples</span>
397
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Unexpected number of samples (#{num_samples}) based on the provided sample names (#{sample_names.inspect})&quot;</span>
398
+ <span class="ruby-keyword">end</span>
399
+
400
+ <span class="ruby-identifier">sample_names</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">sample_name</span>, <span class="ruby-identifier">sample_index</span><span class="ruby-operator">|</span>
401
+ <span class="ruby-identifier">i</span> = <span class="ruby-identifier">sample_index</span> <span class="ruby-operator">+</span> <span class="ruby-value">9</span> <span class="ruby-comment"># index into columns (f)</span>
402
+ <span class="ruby-identifier">sample_values</span> = <span class="ruby-identifier">f</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">&quot;:&quot;</span>)
403
+ <span class="ruby-identifier">raise</span> <span class="ruby-node">&quot;Expected number of sample values to be &lt;= number of sample keys in FORMAT column Format=#{@format} but sample=#{f[i]}&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">sample_values</span>.<span class="ruby-identifier">size</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">sample_keys</span>.<span class="ruby-identifier">size</span>
404
+ <span class="ruby-ivar">@samples</span>[<span class="ruby-identifier">sample_name</span>] = {}
405
+ <span class="ruby-identifier">sample_keys</span>.<span class="ruby-identifier">each_with_index</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">key</span>, <span class="ruby-identifier">value_index</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@samples</span>[<span class="ruby-identifier">sample_name</span>][<span class="ruby-identifier">key</span>] = <span class="ruby-identifier">sample_values</span>[<span class="ruby-identifier">value_index</span>] <span class="ruby-operator">||</span> <span class="ruby-string">&quot;&quot;</span>}
406
+ <span class="ruby-keyword">end</span>
407
+
408
+ <span class="ruby-keyword">return</span> <span class="ruby-keyword">true</span>;
409
+ <span class="ruby-keyword">end</span></pre>
410
+ </div>
411
+
412
+ </div>
413
+
414
+
415
+
416
+
417
+ </div>
418
+
419
+
420
+ </section>
421
+
422
+ </section>
423
+ </main>
424
+
425
+
426
+ <footer id="validator-badges" role="contentinfo">
427
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
428
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
429
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
430
+ </footer>
431
+