bio-samtools 0.6.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +4 -7
  4. data/VERSION +1 -1
  5. data/bio-samtools.gemspec +47 -105
  6. data/doc/Bio.html +68 -131
  7. data/doc/Bio/DB.html +51 -111
  8. data/doc/Bio/DB/Alignment.html +135 -363
  9. data/doc/Bio/DB/Pileup.html +183 -170
  10. data/doc/Bio/DB/SAM.html +1396 -820
  11. data/doc/Bio/DB/SAM/Library.html +73 -123
  12. data/doc/Bio/DB/SAM/Tools.html +51 -273
  13. data/doc/Bio/DB/Tag.html +78 -124
  14. data/doc/Bio/DB/Vcf.html +111 -147
  15. data/doc/LICENSE_txt.html +113 -148
  16. data/doc/created.rid +9 -10
  17. data/doc/fonts.css +167 -0
  18. data/doc/fonts/Lato-Light.ttf +0 -0
  19. data/doc/fonts/Lato-LightItalic.ttf +0 -0
  20. data/doc/fonts/Lato-Regular.ttf +0 -0
  21. data/doc/fonts/Lato-RegularItalic.ttf +0 -0
  22. data/doc/fonts/SourceCodePro-Bold.ttf +0 -0
  23. data/doc/fonts/SourceCodePro-Regular.ttf +0 -0
  24. data/doc/images/add.png +0 -0
  25. data/doc/images/arrow_up.png +0 -0
  26. data/doc/images/delete.png +0 -0
  27. data/doc/images/tag_blue.png +0 -0
  28. data/doc/index.html +48 -54
  29. data/doc/js/darkfish.js +9 -22
  30. data/doc/js/search.js +20 -5
  31. data/doc/js/search_index.js +1 -1
  32. data/doc/rdoc.css +255 -218
  33. data/doc/table_of_contents.html +256 -137
  34. data/ext/Rakefile +57 -0
  35. data/lib/bio-samtools.rb +7 -2
  36. data/lib/bio/BIOExtensions.rb +89 -0
  37. data/lib/bio/db/alignment.rb +59 -0
  38. data/lib/bio/db/fastadb.rb +255 -0
  39. data/lib/bio/db/pileup.rb +221 -172
  40. data/lib/bio/db/sam.rb +639 -589
  41. data/lib/bio/db/sam/{faidx.rb → faidx_old.rb} +0 -0
  42. data/lib/bio/db/vcf.rb +69 -68
  43. data/test/.gitignore +1 -0
  44. data/test/{test_basic.rb → old_test_basic.rb} +33 -1
  45. data/test/samples/small/dupes.bam +0 -0
  46. data/test/samples/small/dupes.sam +274 -0
  47. data/test/samples/small/map_for_reheader.sam +8 -0
  48. data/test/samples/small/map_to_merge1.bam +0 -0
  49. data/test/samples/small/map_to_merge1.bam.bai +0 -0
  50. data/test/samples/small/map_to_merge1.sam +8 -0
  51. data/test/samples/small/map_to_merge2.bam +0 -0
  52. data/test/samples/small/map_to_merge2.bam.bai +0 -0
  53. data/test/samples/small/map_to_merge2.sam +8 -0
  54. data/test/samples/small/no_md.sam +8 -0
  55. data/test/samples/small/test_chr.fasta.1.bt2 +0 -0
  56. data/test/samples/small/test_chr.fasta.2.bt2 +0 -0
  57. data/test/samples/small/test_chr.fasta.3.bt2 +0 -0
  58. data/test/samples/small/test_chr.fasta.4.bt2 +0 -0
  59. data/test/samples/small/test_chr.fasta.rev.1.bt2 +0 -0
  60. data/test/samples/small/test_chr.fasta.rev.2.bt2 +0 -0
  61. data/test/samples/small/test_cov.svg +273 -0
  62. data/test/samples/small/testu.bam.bai +0 -0
  63. data/test/svg +133 -0
  64. data/test/test_pileup.rb +84 -0
  65. data/test/test_sam.rb +331 -0
  66. data/test/test_vcf.rb +11 -0
  67. data/{doc → tutorial}/tutorial.html +0 -0
  68. data/{doc → tutorial}/tutorial.pdf +0 -0
  69. metadata +56 -114
  70. data/doc/Bio/DB/SAM/Tools/Bam1CoreT.html +0 -159
  71. data/doc/Bio/DB/SAM/Tools/Bam1T.html +0 -220
  72. data/doc/Bio/DB/SAM/Tools/BamHeaderT.html +0 -249
  73. data/doc/Bio/DB/SAM/Tools/BamPileup1T.html +0 -159
  74. data/doc/Bio/DB/SAM/Tools/SamfileT.html +0 -171
  75. data/doc/Bio/DB/SAM/Tools/SamfileTX.html +0 -159
  76. data/doc/Bio/DB/SAMException.html +0 -205
  77. data/doc/LibC.html +0 -155
  78. data/doc/Pileup.html +0 -571
  79. data/doc/Vcf.html +0 -473
  80. data/doc/basic_styles.css +0 -31
  81. data/doc/classes/Bio.html +0 -139
  82. data/doc/classes/Bio/DB.html +0 -137
  83. data/doc/classes/Bio/DB/Alignment.html +0 -441
  84. data/doc/classes/Bio/DB/Alignment.src/M000012.html +0 -19
  85. data/doc/classes/Bio/DB/Alignment.src/M000013.html +0 -27
  86. data/doc/classes/Bio/DB/Alignment.src/M000014.html +0 -45
  87. data/doc/classes/Bio/DB/Alignment.src/M000015.html +0 -40
  88. data/doc/classes/Bio/DB/SAM.html +0 -510
  89. data/doc/classes/Bio/DB/SAM/Library.html +0 -135
  90. data/doc/classes/Bio/DB/SAM/Library.src/M000006.html +0 -28
  91. data/doc/classes/Bio/DB/SAM/Tools.html +0 -278
  92. data/doc/classes/Bio/DB/SAM/Tools.src/M000007.html +0 -20
  93. data/doc/classes/Bio/DB/SAM/Tools/Bam1CoreT.html +0 -111
  94. data/doc/classes/Bio/DB/SAM/Tools/Bam1T.html +0 -150
  95. data/doc/classes/Bio/DB/SAM/Tools/Bam1T.src/M000010.html +0 -20
  96. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.html +0 -169
  97. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.src/M000008.html +0 -19
  98. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.src/M000009.html +0 -18
  99. data/doc/classes/Bio/DB/SAM/Tools/BamPileup1T.html +0 -111
  100. data/doc/classes/Bio/DB/SAM/Tools/SamfileT.html +0 -129
  101. data/doc/classes/Bio/DB/SAM/Tools/SamfileTX.html +0 -111
  102. data/doc/classes/Bio/DB/SAMException.html +0 -140
  103. data/doc/classes/Bio/DB/SAMException.src/M000016.html +0 -18
  104. data/doc/classes/Bio/DB/Sam.src/M000017.html +0 -43
  105. data/doc/classes/Bio/DB/Sam.src/M000018.html +0 -42
  106. data/doc/classes/Bio/DB/Sam.src/M000019.html +0 -18
  107. data/doc/classes/Bio/DB/Sam.src/M000020.html +0 -22
  108. data/doc/classes/Bio/DB/Sam.src/M000021.html +0 -19
  109. data/doc/classes/Bio/DB/Sam.src/M000022.html +0 -25
  110. data/doc/classes/Bio/DB/Sam.src/M000023.html +0 -28
  111. data/doc/classes/Bio/DB/Sam.src/M000024.html +0 -28
  112. data/doc/classes/Bio/DB/Sam.src/M000025.html +0 -46
  113. data/doc/classes/Bio/DB/Sam.src/M000026.html +0 -24
  114. data/doc/classes/Bio/DB/Sam.src/M000027.html +0 -19
  115. data/doc/classes/Bio/DB/Sam.src/M000028.html +0 -24
  116. data/doc/classes/Bio/DB/Sam.src/M000029.html +0 -41
  117. data/doc/classes/Bio/DB/Sam.src/M000030.html +0 -31
  118. data/doc/classes/Bio/DB/Sam.src/M000031.html +0 -86
  119. data/doc/classes/Bio/DB/Sam.src/M000032.html +0 -34
  120. data/doc/classes/Bio/DB/Tag.html +0 -160
  121. data/doc/classes/Bio/DB/Tag.src/M000011.html +0 -21
  122. data/doc/classes/LibC.html +0 -105
  123. data/doc/classes/Pileup.html +0 -374
  124. data/doc/classes/Pileup.src/M000001.html +0 -34
  125. data/doc/classes/Pileup.src/M000002.html +0 -21
  126. data/doc/classes/Pileup.src/M000003.html +0 -21
  127. data/doc/classes/Pileup.src/M000004.html +0 -21
  128. data/doc/classes/Pileup.src/M000005.html +0 -31
  129. data/doc/files/lib/bio-samtools_rb.html +0 -109
  130. data/doc/files/lib/bio/db/sam/bam_rb.html +0 -108
  131. data/doc/files/lib/bio/db/sam/faidx_rb.html +0 -108
  132. data/doc/files/lib/bio/db/sam/library_rb.html +0 -101
  133. data/doc/files/lib/bio/db/sam/pileup_rb.html +0 -178
  134. data/doc/files/lib/bio/db/sam/sam_rb.html +0 -113
  135. data/doc/files/lib/bio/db/sam_rb.html +0 -111
  136. data/doc/fr_class_index.html +0 -43
  137. data/doc/fr_file_index.html +0 -33
  138. data/doc/fr_method_index.html +0 -58
  139. data/doc/lib/bio-samtools_rb.html +0 -115
  140. data/doc/lib/bio/db/pileup_rb.html +0 -171
  141. data/doc/lib/bio/db/sam/bam_rb.html +0 -121
  142. data/doc/lib/bio/db/sam/faidx_rb.html +0 -117
  143. data/doc/lib/bio/db/sam/library_rb.html +0 -115
  144. data/doc/lib/bio/db/sam/pileup_rb.html +0 -171
  145. data/doc/lib/bio/db/sam/sam_rb.html +0 -121
  146. data/doc/lib/bio/db/sam/vcf_rb.html +0 -124
  147. data/doc/lib/bio/db/sam_rb.html +0 -115
  148. data/doc/lib/bio/db/vcf_rb.html +0 -124
  149. data/doc/rdoc-style.css +0 -208
  150. data/lib/bio/db/sam/bam.rb +0 -210
  151. data/lib/bio/db/sam/sam.rb +0 -86
  152. data/test/samples/pipe_char/test.bam +0 -0
  153. data/test/samples/pipe_char/test.bam.bai +0 -0
  154. data/test/samples/pipe_char/test.tam +0 -10
  155. data/test/samples/pipe_char/test_chr.fasta +0 -1000
  156. data/test/samples/pipe_char/test_chr.fasta.fai +0 -1
  157. data/test/samples/small/test +0 -0
  158. data/test/samples/small/test.bam +0 -0
  159. data/test/samples/small/test.fa +0 -20
  160. data/test/samples/small/test.fai +0 -0
@@ -2,181 +2,151 @@
2
2
 
3
3
  <html>
4
4
  <head>
5
- <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
5
+ <meta charset="UTF-8">
6
6
 
7
7
  <title>class Bio::DB::Sam - Pileup</title>
8
8
 
9
- <link type="text/css" media="screen" href="../../rdoc.css" rel="stylesheet">
9
+ <link href="../../fonts.css" rel="stylesheet">
10
+ <link href="../../rdoc.css" rel="stylesheet">
10
11
 
11
12
  <script type="text/javascript">
12
13
  var rdoc_rel_prefix = "../../";
13
14
  </script>
14
15
 
15
- <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
16
- <script type="text/javascript" charset="utf-8" src="../../js/navigation.js"></script>
17
- <script type="text/javascript" charset="utf-8" src="../../js/search_index.js"></script>
18
- <script type="text/javascript" charset="utf-8" src="../../js/search.js"></script>
19
- <script type="text/javascript" charset="utf-8" src="../../js/searcher.js"></script>
20
- <script type="text/javascript" charset="utf-8" src="../../js/darkfish.js"></script>
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>
21
22
 
22
23
 
23
- <body id="top" class="class">
24
- <nav id="metadata">
25
- <nav id="home-section" class="section">
26
- <h3 class="section-header">
27
- <a href="../../index.html">Home</a>
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>
28
34
  <a href="../../table_of_contents.html#classes">Classes</a>
29
35
  <a href="../../table_of_contents.html#methods">Methods</a>
30
- </h3>
31
- </nav>
32
-
36
+ </div>
37
+ </div>
33
38
 
34
- <nav id="search-section" class="section project-section" class="initially-hidden">
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
35
40
  <form action="#" method="get" accept-charset="utf-8">
36
- <h3 class="section-header">
37
- <input type="text" name="search" placeholder="Search" id="search-field"
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"
38
45
  title="Type to search, Up and Down to navigate, Enter to load">
39
- </h3>
40
- </form>
41
-
42
- <ul id="search-results" class="initially-hidden"></ul>
43
- </nav>
44
-
46
+ </div>
45
47
 
46
- <div id="file-metadata">
47
- <nav id="file-list-section" class="section">
48
- <h3 class="section-header">Defined In</h3>
49
- <ul>
50
- <li>lib/bio/db/sam.rb
51
- </ul>
52
- </nav>
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
53
 
54
-
55
54
  </div>
56
55
 
56
+
57
+
57
58
  <div id="class-metadata">
58
59
 
59
- <nav id="parent-class-section" class="section">
60
- <h3 class="section-header">Parent</h3>
60
+ <div id="parent-class-section" class="nav-section">
61
+ <h3>Parent</h3>
62
+
61
63
 
62
64
  <p class="link">Object
63
65
 
64
- </nav>
66
+ </div>
65
67
 
66
68
 
69
+
67
70
  <!-- Method Quickref -->
68
- <nav id="method-list-section" class="section">
69
- <h3 class="section-header">Methods</h3>
71
+ <div id="method-list-section" class="nav-section">
72
+ <h3>Methods</h3>
70
73
 
71
- <ul class="link-list">
74
+ <ul class="link-list" role="directory">
72
75
 
73
- <li><a href="#method-c-finalize">::finalize</a>
76
+ <li ><a href="#method-c-docs">::docs</a>
74
77
 
75
- <li><a href="#method-c-merge">::merge</a>
78
+ <li ><a href="#method-c-new">::new</a>
76
79
 
77
- <li><a href="#method-c-new">::new</a>
80
+ <li ><a href="#method-i-average_coverage">#average_coverage</a>
78
81
 
79
- <li><a href="#method-i-average_coverage">#average_coverage</a>
82
+ <li ><a href="#method-i-calmd">#calmd</a>
80
83
 
81
- <li><a href="#method-i-chromosome_coverage">#chromosome_coverage</a>
84
+ <li ><a href="#method-i-cat">#cat</a>
82
85
 
83
- <li><a href="#method-i-close">#close</a>
86
+ <li ><a href="#method-i-chromosome_coverage">#chromosome_coverage</a>
84
87
 
85
- <li><a href="#method-i-deprecated_pileup">#deprecated_pileup</a>
88
+ <li ><a href="#method-i-depth">#depth</a>
86
89
 
87
- <li><a href="#method-i-each_reference">#each_reference</a>
90
+ <li ><a href="#method-i-faidx">#faidx</a>
88
91
 
89
- <li><a href="#method-i-fetch">#fetch</a>
92
+ <li ><a href="#method-i-fetch">#fetch</a>
90
93
 
91
- <li><a href="#method-i-fetch_reference">#fetch_reference</a>
94
+ <li ><a href="#method-i-fetch_reference">#fetch_reference</a>
92
95
 
93
- <li><a href="#method-i-fetch_with_function">#fetch_with_function</a>
96
+ <li ><a href="#method-i-fetch_with_function">#fetch_with_function</a>
94
97
 
95
- <li><a href="#method-i-index_stats">#index_stats</a>
98
+ <li ><a href="#method-i-fix_mates">#fix_mates</a>
96
99
 
97
- <li><a href="#method-i-load_index">#load_index</a>
100
+ <li ><a href="#method-i-fixmate">#fixmate</a>
98
101
 
99
- <li><a href="#method-i-load_reference">#load_reference</a>
102
+ <li ><a href="#method-i-flag_stats">#flag_stats</a>
100
103
 
101
- <li><a href="#method-i-mpileup">#mpileup</a>
104
+ <li ><a href="#method-i-flagstat">#flagstat</a>
102
105
 
103
- <li><a href="#method-i-mpileup_plus">#mpileup_plus</a>
106
+ <li ><a href="#method-i-idxstats">#idxstats</a>
104
107
 
105
- <li><a href="#method-i-open">#open</a>
108
+ <li ><a href="#method-i-index">#index</a>
106
109
 
107
- <li><a href="#method-i-query_string">#query_string</a>
110
+ <li ><a href="#method-i-index_stats">#index_stats</a>
108
111
 
109
- <li><a href="#method-i-to_s">#to_s</a>
112
+ <li ><a href="#method-i-merge">#merge</a>
113
+
114
+ <li ><a href="#method-i-mpileup">#mpileup</a>
115
+
116
+ <li ><a href="#method-i-open">#open</a>
117
+
118
+ <li ><a href="#method-i-phase">#phase</a>
119
+
120
+ <li ><a href="#method-i-plot_chromosome_coverage">#plot_chromosome_coverage</a>
121
+
122
+ <li ><a href="#method-i-reheader">#reheader</a>
123
+
124
+ <li ><a href="#method-i-remove_duplicates">#remove_duplicates</a>
125
+
126
+ <li ><a href="#method-i-rmdup">#rmdup</a>
127
+
128
+ <li ><a href="#method-i-sort">#sort</a>
129
+
130
+ <li ><a href="#method-i-targetcut">#targetcut</a>
131
+
132
+ <li ><a href="#method-i-tview">#tview</a>
133
+
134
+ <li ><a href="#method-i-view">#view</a>
110
135
 
111
136
  </ul>
112
- </nav>
113
-
114
- </div>
115
-
116
- <div id="project-metadata">
117
- <nav id="fileindex-section" class="section project-section">
118
- <h3 class="section-header">Pages</h3>
119
-
120
- <ul>
121
-
122
- <li class="file"><a href="../../LICENSE_txt.html">LICENSE</a>
123
-
124
- </ul>
125
- </nav>
126
-
127
- <nav id="classindex-section" class="section project-section">
128
- <h3 class="section-header">Class and Module Index</h3>
129
-
130
- <ul class="link-list">
131
-
132
- <li><a href="../../Bio.html">Bio</a>
133
-
134
- <li><a href="../../Bio/DB.html">Bio::DB</a>
135
-
136
- <li><a href="../../Bio/DB/Alignment.html">Bio::DB::Alignment</a>
137
-
138
- <li><a href="../../Bio/DB/Pileup.html">Bio::DB::Pileup</a>
139
-
140
- <li><a href="../../Bio/DB/SAM.html">Bio::DB::SAM</a>
141
-
142
- <li><a href="../../Bio/DB/SAM/Library.html">Bio::DB::SAM::Library</a>
143
-
144
- <li><a href="../../Bio/DB/SAM/Tools.html">Bio::DB::SAM::Tools</a>
145
-
146
- <li><a href="../../Bio/DB/SAM/Tools/Bam1CoreT.html">Bio::DB::SAM::Tools::Bam1CoreT</a>
147
-
148
- <li><a href="../../Bio/DB/SAM/Tools/Bam1T.html">Bio::DB::SAM::Tools::Bam1T</a>
149
-
150
- <li><a href="../../Bio/DB/SAM/Tools/BamHeaderT.html">Bio::DB::SAM::Tools::BamHeaderT</a>
151
-
152
- <li><a href="../../Bio/DB/SAM/Tools/BamPileup1T.html">Bio::DB::SAM::Tools::BamPileup1T</a>
153
-
154
- <li><a href="../../Bio/DB/SAM/Tools/SamfileT.html">Bio::DB::SAM::Tools::SamfileT</a>
155
-
156
- <li><a href="../../Bio/DB/SAM/Tools/SamfileTX.html">Bio::DB::SAM::Tools::SamfileTX</a>
157
-
158
- <li><a href="../../Bio/DB/SAMException.html">Bio::DB::SAMException</a>
159
-
160
- <li><a href="../../Bio/DB/Sam.html">Bio::DB::Sam</a>
161
-
162
- <li><a href="../../Bio/DB/Tag.html">Bio::DB::Tag</a>
163
-
164
- <li><a href="../../Bio/DB/Vcf.html">Bio::DB::Vcf</a>
165
-
166
- <li><a href="../../LibC.html">LibC</a>
167
-
168
- </ul>
169
- </nav>
137
+ </div>
170
138
 
171
139
  </div>
172
140
  </nav>
173
141
 
174
- <div id="documentation">
175
- <h1 class="class">class Bio::DB::Sam</h1>
142
+ <main role="main" aria-labelledby="class-Bio::DB::Sam">
143
+ <h1 id="class-Bio::DB::Sam" class="class">
144
+ class Bio::DB::Sam
145
+ </h1>
176
146
 
177
- <div id="description" class="description">
147
+ <section class="description">
178
148
 
179
- </div><!-- description -->
149
+ </section>
180
150
 
181
151
 
182
152
 
@@ -189,15 +159,16 @@
189
159
 
190
160
 
191
161
 
192
- <!-- Attributes -->
193
- <section id="attribute-method-details" class="method-section section">
194
- <h3 class="section-header">Attributes</h3>
162
+ <section class="attribute-method-details" class="method-section">
163
+ <header>
164
+ <h3>Attributes</h3>
165
+ </header>
195
166
 
196
167
 
197
- <div id="attribute-i-sam_file" class="method-detail">
168
+ <div id="attribute-i-bam" class="method-detail">
198
169
  <div class="method-heading attribute-method-heading">
199
- <span class="method-name">sam_file</span><span
200
- class="attribute-access-type">[R]</span>
170
+ <span class="method-name">bam</span><span
171
+ class="attribute-access-type">[RW]</span>
201
172
  </div>
202
173
 
203
174
  <div class="method-description">
@@ -207,941 +178,1093 @@
207
178
  </div>
208
179
  </div>
209
180
 
210
- </section><!-- attribute-method-details -->
211
-
212
-
213
- <!-- Methods -->
214
-
215
- <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
216
- <h3 class="section-header">Public Class Methods</h3>
181
+ <div id="attribute-i-bcftools" class="method-detail">
182
+ <div class="method-heading attribute-method-heading">
183
+ <span class="method-name">bcftools</span><span
184
+ class="attribute-access-type">[RW]</span>
185
+ </div>
217
186
 
218
-
219
- <div id="method-c-finalize" class="method-detail ">
187
+ <div class="method-description">
220
188
 
221
- <div class="method-heading">
222
- <span class="method-name">finalize</span><span
223
- class="method-args">(id)</span>
224
- <span class="method-click-advice">click to toggle source</span>
225
- </div>
226
189
 
190
+
191
+ </div>
192
+ </div>
193
+
194
+ <div id="attribute-i-fasta" class="method-detail">
195
+ <div class="method-heading attribute-method-heading">
196
+ <span class="method-name">fasta</span><span
197
+ class="attribute-access-type">[RW]</span>
198
+ </div>
227
199
 
228
200
  <div class="method-description">
229
-
230
- <p>Destructor method that closes the file before letting the object be garbage
231
- collected.</p>
232
-
233
-
234
-
235
- <div class="method-source-code" id="finalize-source">
236
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 104</span>
237
- <span class="ruby-keyword">def</span> <span class="ruby-constant">Sam</span>.<span class="ruby-identifier">finalize</span>(<span class="ruby-identifier">id</span>)
238
- <span class="ruby-identifier">id</span>.<span class="ruby-identifier">close</span>()
239
- <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;Finalizing #{id} at #{Time.new}&quot;</span>
240
- <span class="ruby-keyword">end</span></pre>
241
- </div><!-- finalize-source -->
242
-
201
+
202
+
203
+
204
+ </div>
205
+ </div>
206
+
207
+ <div id="attribute-i-last_command" class="method-detail">
208
+ <div class="method-heading attribute-method-heading">
209
+ <span class="method-name">last_command</span><span
210
+ class="attribute-access-type">[RW]</span>
243
211
  </div>
244
212
 
213
+ <div class="method-description">
214
+
215
+
245
216
 
217
+ </div>
218
+ </div>
219
+
220
+ <div id="attribute-i-samtools" class="method-detail">
221
+ <div class="method-heading attribute-method-heading">
222
+ <span class="method-name">samtools</span><span
223
+ class="attribute-access-type">[RW]</span>
224
+ </div>
246
225
 
226
+ <div class="method-description">
227
+
228
+
247
229
 
248
- </div><!-- finalize-method -->
230
+ </div>
231
+ </div>
232
+
233
+ </section>
234
+
249
235
 
250
236
 
251
- <div id="method-c-merge" class="method-detail ">
237
+ <section id="public-class-5Buntitled-5D-method-details" class="method-section">
238
+ <header>
239
+ <h3>Public Class Methods</h3>
240
+ </header>
241
+
242
+
243
+ <div id="method-c-docs" class="method-detail ">
252
244
 
253
245
  <div class="method-heading">
254
- <span class="method-name">merge</span><span
255
- class="method-args">(files, merged_file, headers, add_RG, by_qname)</span>
246
+ <span class="method-name">docs</span><span
247
+ class="method-args">(program, command)</span>
248
+
256
249
  <span class="method-click-advice">click to toggle source</span>
250
+
257
251
  </div>
258
252
 
259
253
 
260
254
  <div class="method-description">
261
255
 
262
- <p>Merges n BAM files. This doesn’t require to create a <a
263
- href="SAM.html">SAM</a> object</p>
264
- <dl class="rdoc-list note-list"><dt>files
265
- <dd>
266
- <p>An array with the paths to the files.</p>
267
- </dd><dt>merged_file
268
- <dd>
269
- <p>The path to the merged file</p>
270
- </dd><dt>headers
271
- <dd>
272
- <p>The BAM file containing the header</p>
273
- </dd><dt>add_RG
274
- <dd>
275
- <p>If true, the RG tag is added (infered from the filenames)</p>
276
- </dd><dt>by_qname
277
- <dd>
278
- <p>If true, the bamfiles should by ordered by query name, if false, by
279
- coordinates.</p>
280
- </dd></dl>
256
+ <ul><li>
257
+ <p>program - one of &#39;samtools&#39; &#39;bcftools&#39;</p>
258
+ </li><li>
259
+ <p>command - one of the commands relevant to the program</p>
260
+ </li></ul>
281
261
 
282
-
283
262
 
284
- <div class="method-source-code" id="merge-source">
285
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 259</span>
286
- <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-identifier">files</span>, <span class="ruby-identifier">merged_file</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">add_RG</span>, <span class="ruby-identifier">by_qname</span>)
287
- <span class="ruby-identifier">strptrs</span> = []
288
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">from_string</span>(<span class="ruby-string">&quot;merge&quot;</span>)
289
- <span class="ruby-identifier">files</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">file</span><span class="ruby-operator">|</span>
290
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">from_string</span>(<span class="ruby-identifier">file</span>)
291
- <span class="ruby-keyword">end</span>
292
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">nil</span>
293
263
 
294
- <span class="ruby-comment"># Now load all the pointers into a native memory block</span>
295
- <span class="ruby-identifier">argv</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:pointer</span>, <span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">length</span>)
296
- <span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
297
- <span class="ruby-identifier">argv</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">put_pointer</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">p</span>)
298
- <span class="ruby-keyword">end</span>
299
- <span class="ruby-comment">#void bam_merge_core(int by_qname, const char *out, const char *headers, int n, char * const *fn, int add_RG)</span>
300
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_merge_core</span>(<span class="ruby-identifier">by_qname</span>, <span class="ruby-identifier">merged_file</span>, <span class="ruby-identifier">headers</span>, <span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">length</span>, <span class="ruby-identifier">argv</span>, <span class="ruby-identifier">add_RG</span>)
264
+
265
+ <div class="method-source-code" id="docs-source">
266
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 401</span>
267
+ <span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">docs</span>(<span class="ruby-identifier">program</span>, <span class="ruby-identifier">command</span>)
268
+ <span class="ruby-keyword">return</span> <span class="ruby-string">&quot;program must be &#39;samtools&#39; or &#39;bcftools&#39;&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> [<span class="ruby-string">&#39;samtools&#39;</span>, <span class="ruby-string">&#39;bcftools&#39;</span>].<span class="ruby-identifier">include?</span> <span class="ruby-identifier">program</span>
269
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{program} #{command}&quot;</span>
270
+ <span class="ruby-node">%x#{command}`</span>
301
271
  <span class="ruby-keyword">end</span></pre>
302
- </div><!-- merge-source -->
272
+ </div>
303
273
 
304
274
  </div>
305
275
 
306
276
 
307
277
 
308
278
 
309
- </div><!-- merge-method -->
279
+ </div>
310
280
 
311
281
 
312
282
  <div id="method-c-new" class="method-detail ">
313
283
 
314
284
  <div class="method-heading">
315
285
  <span class="method-name">new</span><span
316
- class="method-args">(optsa={})</span>
286
+ class="method-args">(args)</span>
287
+
317
288
  <span class="method-click-advice">click to toggle source</span>
289
+
318
290
  </div>
319
291
 
320
292
 
321
293
  <div class="method-description">
322
294
 
323
- <p>To make a new sam object. Initialize expects a hash optsa with the
324
- following elemets:</p>
325
- <dl class="rdoc-list note-list"><dt>fasta
326
- <dd>
327
- <p>The fasta file with the reference. (nil)</p>
328
- </dd><dt>bam
329
- <dd>
330
- <p>path to a binary <a href="SAM.html">SAM</a> file (nil)</p>
331
- </dd><dt>tam
332
- <dd>
333
- <p>path to a text <a href="SAM.html">SAM</a> file (nil)</p>
334
- </dd><dt>compressed
335
- <dd>
336
- <p>If the binary file is compressed (true)</p>
337
- </dd><dt>write
338
- <dd>
339
- <p>If the file is to be writen (false). Not supported yet.</p>
340
- </dd></dl>
341
-
342
- <p><strong>NOTE:</strong> you can’t use binary and text formats
343
- simultaneusly. To make queries, the file has to be a sorted binary. This
344
- function doesn’t actually open the file, it just prepares the object to
345
- be opened in a later stage.</p>
295
+ <p>Creates a new <a href="Sam.html">Bio::DB::Sam</a> object</p>
296
+ <ul><li>
297
+ <p>fasta [String] - the path to the Fasta reference sequence</p>
298
+ </li><li>
299
+ <p>bam [String] - path to bam files</p>
300
+ </li><li>
301
+ <p>samtools [String] - path to alternative installation of samtools</p>
302
+ </li><li>
303
+ <p>bcftools [String] - path to alternative installation of bcftools</p>
304
+ </li><li>
305
+ <p>returns [Bio::DB::Sam] a new `Bio::DB::Sam` object</p>
306
+ </li></ul>
307
+
346
308
 
347
309
 
348
310
 
349
311
  <div class="method-source-code" id="new-source">
350
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 29</span>
351
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">optsa</span>={})
352
- <span class="ruby-identifier">opts</span> = { <span class="ruby-value">:fasta</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">:bam</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>,<span class="ruby-value">:tam</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">:compressed</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>, <span class="ruby-value">:write</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span> }.<span class="ruby-identifier">merge!</span>(<span class="ruby-identifier">optsa</span>)
353
-
354
-
355
-
356
- <span class="ruby-ivar">@fasta_path</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:fasta</span>]
357
- <span class="ruby-ivar">@compressed</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:compressed</span>]
358
- <span class="ruby-ivar">@write</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:write</span>]
359
- <span class="ruby-identifier">bam</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:bam</span>]
360
- <span class="ruby-identifier">tam</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:tam</span>]
361
-
362
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">bam</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">tam</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-ivar">@fasta_path</span> <span class="ruby-operator">==</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span>
363
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No alignment or reference file&quot;</span>
364
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">bam</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">tam</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span>
365
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Alignment has to be in either text or binary format, not both&quot;</span>
366
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">bam</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span>
367
- <span class="ruby-ivar">@binary</span> = <span class="ruby-keyword">true</span>
368
- <span class="ruby-ivar">@sam</span> = <span class="ruby-identifier">bam</span>
369
- <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">tam</span> <span class="ruby-operator">!=</span> <span class="ruby-keyword">nil</span> <span class="ruby-keyword">then</span>
370
- <span class="ruby-ivar">@sam</span> = <span class="ruby-identifier">tam</span>
371
- <span class="ruby-ivar">@binary</span> = <span class="ruby-keyword">false</span>
372
-
373
- <span class="ruby-keyword">end</span>
374
- <span class="ruby-ivar">@fasta_file</span> = <span class="ruby-keyword">nil</span>
375
- <span class="ruby-ivar">@sam_file</span> = <span class="ruby-keyword">nil</span>
312
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 13</span>
313
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">args</span>)
314
+ <span class="ruby-ivar">@fasta</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:fasta</span>]
315
+ <span class="ruby-ivar">@bam</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:bam</span>]
316
+ <span class="ruby-ivar">@samtools</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:samtools</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword">__FILE__</span>)),<span class="ruby-string">&#39;sam&#39;</span>,<span class="ruby-string">&#39;external&#39;</span>,<span class="ruby-string">&#39;samtools&#39;</span>)
317
+ <span class="ruby-ivar">@bcftools</span> = <span class="ruby-identifier">args</span>[<span class="ruby-value">:bcftools</span>] <span class="ruby-operator">||</span> <span class="ruby-constant">File</span>.<span class="ruby-identifier">join</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">expand_path</span>(<span class="ruby-constant">File</span>.<span class="ruby-identifier">dirname</span>(<span class="ruby-keyword">__FILE__</span>)),<span class="ruby-string">&#39;sam&#39;</span>,<span class="ruby-string">&#39;external&#39;</span>,<span class="ruby-string">&#39;bcftools&#39;</span>)
318
+
319
+ <span class="ruby-ivar">@files</span> = [<span class="ruby-ivar">@files</span>] <span class="ruby-keyword">if</span> <span class="ruby-ivar">@files</span>.<span class="ruby-identifier">instance_of?</span>(<span class="ruby-constant">String</span>)
376
320
 
377
- <span class="ruby-constant">ObjectSpace</span>.<span class="ruby-identifier">define_finalizer</span>(<span class="ruby-keyword">self</span>, <span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>.<span class="ruby-identifier">method</span>(<span class="ruby-value">:finalize</span>).<span class="ruby-identifier">to_proc</span>)
321
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-keyword">nil</span>
322
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-string">&quot;Need Fasta and at least one BAM or SAM&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-ivar">@fasta</span> <span class="ruby-keyword">or</span> <span class="ruby-keyword">not</span> <span class="ruby-ivar">@bam</span>
323
+ <span class="ruby-identifier">raise</span> <span class="ruby-constant">IOError</span>, <span class="ruby-string">&quot;File not found&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-identifier">files_ok?</span>
324
+ <span class="ruby-ivar">@bams</span> = [<span class="ruby-ivar">@bams</span>] <span class="ruby-keyword">if</span> <span class="ruby-ivar">@bams</span>.<span class="ruby-identifier">instance_of?</span> <span class="ruby-constant">String</span>
325
+
378
326
  <span class="ruby-keyword">end</span></pre>
379
- </div><!-- new-source -->
327
+ </div>
380
328
 
381
329
  </div>
382
330
 
383
331
 
384
332
 
385
333
 
386
- </div><!-- new-method -->
334
+ </div>
387
335
 
388
336
 
389
- </section><!-- public-class-method-details -->
337
+ </section>
390
338
 
391
- <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
392
- <h3 class="section-header">Public Instance Methods</h3>
339
+ <section id="public-instance-5Buntitled-5D-method-details" class="method-section">
340
+ <header>
341
+ <h3>Public Instance Methods</h3>
342
+ </header>
393
343
 
394
344
 
395
345
  <div id="method-i-average_coverage" class="method-detail ">
396
346
 
397
347
  <div class="method-heading">
398
348
  <span class="method-name">average_coverage</span><span
399
- class="method-args">(chromosome, qstart, len)</span>
349
+ class="method-args">(chr,start,length)</span>
350
+
400
351
  <span class="method-click-advice">click to toggle source</span>
352
+
401
353
  </div>
402
354
 
403
355
 
404
356
  <div class="method-description">
405
357
 
406
- <p>Returns the average coverage of a region in a bam file.</p>
358
+ <p>returns the average coverage over the region queried</p>
359
+ <ul><li>
360
+ <p>chr - the reference name</p>
361
+ </li><li>
362
+ <p>start - the start position</p>
363
+ </li><li>
364
+ <p>length - the length of the region queried</p>
365
+ </li></ul>
366
+
407
367
 
408
368
 
409
369
 
410
370
  <div class="method-source-code" id="average_coverage-source">
411
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 143</span>
412
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">average_coverage</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">len</span>)
371
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 167</span>
372
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">average_coverage</span>(<span class="ruby-identifier">chr</span>,<span class="ruby-identifier">start</span>,<span class="ruby-identifier">length</span>)
373
+ <span class="ruby-identifier">arr</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">chromosome_coverage</span>(<span class="ruby-identifier">chr</span>,<span class="ruby-identifier">start</span>,<span class="ruby-identifier">length</span>)
374
+ <span class="ruby-identifier">arr</span>.<span class="ruby-identifier">inject</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">sum</span>, <span class="ruby-identifier">el</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sum</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">el</span> }.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">arr</span>.<span class="ruby-identifier">size</span>
375
+ <span class="ruby-keyword">end</span></pre>
376
+ </div>
377
+
378
+ </div>
379
+
380
+
413
381
 
414
- <span class="ruby-comment">#reference = fetch_reference(chromosome, qstart,len)</span>
415
- <span class="ruby-comment"># len = reference.length if len &gt; reference.length</span>
382
+
383
+ </div>
416
384
 
385
+
386
+ <div id="method-i-calmd" class="method-detail ">
387
+
388
+ <div class="method-heading">
389
+ <span class="method-name">calmd</span><span
390
+ class="method-args">(opts={}, &block)</span>
391
+
392
+ <span class="method-click-advice">click to toggle source</span>
393
+
394
+ </div>
395
+
417
396
 
418
- <span class="ruby-identifier">coverages</span> = <span class="ruby-identifier">chromosome_coverage</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">len</span>)
419
- <span class="ruby-identifier">total</span> = <span class="ruby-value">0</span>
420
- <span class="ruby-identifier">len</span>.<span class="ruby-identifier">times</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span> <span class="ruby-identifier">total</span>= <span class="ruby-identifier">total</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">coverages</span>[<span class="ruby-identifier">i</span>] }
421
- <span class="ruby-identifier">avg_cov</span> = <span class="ruby-identifier">total</span>.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">len</span>
422
- <span class="ruby-comment">#LibC.free reference</span>
423
- <span class="ruby-identifier">avg_cov</span>
397
+ <div class="method-description">
398
+
399
+ <p>Generate the MD tag. If the MD tag is already present, this command will
400
+ give a warning if the MD tag generated is different from the existing tag.
401
+ Output SAM by default.</p>
402
+ <ul><li>
403
+ <p>A - When used jointly with -r this option overwrites the original base
404
+ quality.</p>
405
+ </li><li>
406
+ <p>e - Convert a the read base to = if it is identical to the aligned
407
+ reference base. Indel caller does not support the = bases at the moment.</p>
408
+ </li><li>
409
+ <p>u - Output uncompressed BAM</p>
410
+ </li><li>
411
+ <p>b - Output compressed BAM</p>
412
+ </li><li>
413
+ <p>S - The input is SAM with header lines</p>
414
+ </li><li>
415
+ <p>C - [INT] Coefficient to cap mapping quality of poorly mapped reads. See
416
+ the pileup command for details. [0]</p>
417
+ </li><li>
418
+ <p>r - Compute the BQ tag (without -A) or cap base quality by BAQ (with -A).</p>
419
+ </li><li>
420
+ <p>E - Extended BAQ calculation. This option trades specificity for
421
+ sensitivity, though the effect is minor.</p>
422
+ </li></ul>
423
+
424
+
425
+
426
+
427
+ <div class="method-source-code" id="calmd-source">
428
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 492</span>
429
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">calmd</span>(<span class="ruby-identifier">opts</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
430
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&quot;calmd&quot;</span>, <span class="ruby-identifier">opts</span>, [<span class="ruby-value">:E</span>, <span class="ruby-value">:e</span>, <span class="ruby-value">:u</span>, <span class="ruby-value">:b</span>, <span class="ruby-value">:S</span>, <span class="ruby-value">:r</span>] )<span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@fasta</span>
431
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
432
+ <span class="ruby-identifier">type</span> = <span class="ruby-value">:text</span>
433
+ <span class="ruby-identifier">klass</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Alignment</span>
434
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">type</span>, <span class="ruby-keyword">true</span>, <span class="ruby-string">&quot;@&quot;</span>,<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
424
435
  <span class="ruby-keyword">end</span></pre>
425
- </div><!-- average_coverage-source -->
436
+ </div>
426
437
 
427
438
  </div>
428
439
 
429
440
 
430
441
 
431
442
 
432
- </div><!-- average_coverage-method -->
443
+ </div>
433
444
 
434
445
 
435
- <div id="method-i-chromosome_coverage" class="method-detail ">
446
+ <div id="method-i-cat" class="method-detail ">
436
447
 
437
448
  <div class="method-heading">
438
- <span class="method-name">chromosome_coverage</span><span
439
- class="method-args">(chromosome, qstart, len)</span>
449
+ <span class="method-name">cat</span><span
450
+ class="method-args">(opts={})</span>
451
+
440
452
  <span class="method-click-advice">click to toggle source</span>
453
+
441
454
  </div>
442
455
 
443
456
 
444
457
  <div class="method-description">
445
458
 
446
- <p>Returns an array with the coverage at each possition in the queried region
447
- This is a simple average coverage just calculated with the first and last
448
- possition of the alignment, ignoring the gaps.</p>
459
+ <p>Concatenate BAMs. The sequence dictionary of each input BAM must be
460
+ identical.</p>
461
+ <ul><li>
462
+ <p>h - header.sam</p>
463
+ </li><li>
464
+ <p>out -[FILE] out file name</p>
465
+ </li><li>
466
+ <p>bams -[FILES] or <a href="Sam.html">Bio::DB::Sam</a> list of input bams, or
467
+ <a href="Sam.html">Bio::DB::Sam</a> objects</p>
468
+ </li></ul>
449
469
 
450
-
451
470
 
452
- <div class="method-source-code" id="chromosome_coverage-source">
453
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 160</span>
454
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">chromosome_coverage</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">len</span>)
455
- <span class="ruby-comment"># reference = fetch_reference(chromosome, qstart,len)</span>
456
- <span class="ruby-comment"># len = reference.length if len &gt; reference.length</span>
457
- <span class="ruby-comment">#p qend.to_s + &quot;-&quot; + qstart.to_s + &quot;framesize &quot; + (qend - qstart).to_s</span>
458
- <span class="ruby-identifier">coverages</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">len</span>, <span class="ruby-value">0</span>)
459
-
460
- <span class="ruby-identifier">chr_cov_proc</span> = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">alignment</span><span class="ruby-operator">|</span>
461
- <span class="ruby-comment">#last = qstart + len</span>
462
- <span class="ruby-comment">#first = qstart</span>
463
- <span class="ruby-comment">#last = alignment.calend if last &gt; alignment.calend</span>
464
- <span class="ruby-comment">#first = alignment.pos if first &lt; alignment.pos</span>
465
- <span class="ruby-comment"># p first</span>
466
- <span class="ruby-identifier">last</span> = <span class="ruby-identifier">alignment</span>.<span class="ruby-identifier">calend</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">qstart</span>
467
- <span class="ruby-identifier">first</span> = <span class="ruby-identifier">alignment</span>.<span class="ruby-identifier">pos</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">qstart</span>
468
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">last</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">first</span>
469
- <span class="ruby-identifier">tmp</span> = <span class="ruby-identifier">last</span>
470
- <span class="ruby-identifier">last</span> = <span class="ruby-identifier">first</span>
471
- <span class="ruby-identifier">first</span> = <span class="ruby-identifier">last</span>
472
- <span class="ruby-keyword">end</span>
473
471
 
474
- <span class="ruby-comment"># STDERR.puts &quot;#{first} #{last}\n&quot;</span>
475
- <span class="ruby-identifier">first</span>.<span class="ruby-identifier">upto</span>(<span class="ruby-identifier">last</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
472
+
473
+ <div class="method-source-code" id="cat-source">
474
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 383</span>
475
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">cat</span>(<span class="ruby-identifier">opts</span>={})
476
+ <span class="ruby-identifier">out</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:out</span>]
477
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:out</span>)
476
478
 
477
- <span class="ruby-identifier">coverages</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>] = <span class="ruby-value">1</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">coverages</span>[<span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span>] <span class="ruby-keyword">if</span> <span class="ruby-identifier">i</span><span class="ruby-operator">-</span><span class="ruby-value">1</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">len</span> <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-identifier">i</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
478
- }
479
- <span class="ruby-keyword">end</span>
479
+ <span class="ruby-identifier">bam_list</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:bams</span>].<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
480
+ <span class="ruby-identifier">b</span>.<span class="ruby-identifier">bam</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">b</span>
481
+ <span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
482
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:bams</span>)
483
+ <span class="ruby-identifier">options</span> = <span class="ruby-identifier">commandify</span>(<span class="ruby-identifier">opts</span>, [<span class="ruby-value">:h</span>] )
484
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} cat #{options} -o #{out} #{bam_list}&quot;</span>
485
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">command</span>
486
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
487
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
480
488
 
481
- <span class="ruby-identifier">fetch_with_function</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">qstart</span><span class="ruby-operator">+</span><span class="ruby-identifier">len</span>, <span class="ruby-identifier">chr_cov_proc</span>)
482
- <span class="ruby-comment">#p coverages</span>
483
- <span class="ruby-identifier">coverages</span>
484
489
  <span class="ruby-keyword">end</span></pre>
485
- </div><!-- chromosome_coverage-source -->
490
+ </div>
486
491
 
487
492
  </div>
488
493
 
489
494
 
490
495
 
491
496
 
492
- </div><!-- chromosome_coverage-method -->
497
+ </div>
493
498
 
494
499
 
495
- <div id="method-i-close" class="method-detail ">
500
+ <div id="method-i-chromosome_coverage" class="method-detail ">
496
501
 
497
502
  <div class="method-heading">
498
- <span class="method-name">close</span><span
499
- class="method-args">()</span>
503
+ <span class="method-name">chromosome_coverage</span><span
504
+ class="method-args">(chr,start,length)</span>
505
+
500
506
  <span class="method-click-advice">click to toggle source</span>
507
+
501
508
  </div>
502
509
 
503
510
 
504
511
  <div class="method-description">
505
512
 
506
- <p>Closes the sam file and destroys the C pointers using the functions
507
- provided by libbam</p>
513
+ <p>returns an array of coverage for each location for which there are mapped
514
+ reads</p>
515
+ <ul><li>
516
+ <p>chr - the reference name</p>
517
+ </li><li>
518
+ <p>start - the start position</p>
519
+ </li><li>
520
+ <p>length - the length of the region queried</p>
521
+ </li></ul>
522
+
508
523
 
509
524
 
510
525
 
511
- <div class="method-source-code" id="close-source">
512
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 95</span>
513
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">close</span>()
514
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">fai_destroy</span>(<span class="ruby-ivar">@fasta_index</span>) <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">null?</span>
515
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_index_destroy</span>(<span class="ruby-ivar">@sam_index</span>) <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">null?</span>
516
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">samclose</span>(<span class="ruby-ivar">@sam_file</span>) <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam_file</span>.<span class="ruby-identifier">nil?</span>
517
- <span class="ruby-ivar">@sam_file</span> = <span class="ruby-keyword">nil</span>
518
- <span class="ruby-ivar">@fasta_index</span> = <span class="ruby-keyword">nil</span>
526
+ <div class="method-source-code" id="chromosome_coverage-source">
527
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 102</span>
528
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">chromosome_coverage</span>(<span class="ruby-identifier">chr</span>,<span class="ruby-identifier">start</span>,<span class="ruby-identifier">length</span>)
529
+ <span class="ruby-identifier">result</span> = []
530
+ <span class="ruby-identifier">region</span> = <span class="ruby-node">&quot;#{chr}:#{start}-#{start + length}&quot;</span>
531
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">mpileup</span>(<span class="ruby-value">:r</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">region</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
532
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">coverage</span>
533
+ <span class="ruby-keyword">end</span>
534
+ <span class="ruby-identifier">result</span>
519
535
  <span class="ruby-keyword">end</span></pre>
520
- </div><!-- close-source -->
536
+ </div>
521
537
 
522
538
  </div>
523
539
 
524
540
 
525
541
 
526
542
 
527
- </div><!-- close-method -->
543
+ </div>
528
544
 
529
545
 
530
- <div id="method-i-deprecated_pileup" class="method-detail ">
546
+ <div id="method-i-depth" class="method-detail ">
531
547
 
532
548
  <div class="method-heading">
533
- <span class="method-name">deprecated_pileup</span><span
534
- class="method-args">( cmd ) { |pileup| ... }</span>
549
+ <span class="method-name">depth</span><span
550
+ class="method-args">(opts={}) { |split(/\t/)| ... }</span>
551
+
535
552
  <span class="method-click-advice">click to toggle source</span>
553
+
536
554
  </div>
537
555
 
538
556
 
539
557
  <div class="method-description">
540
558
 
541
- <p>utility method that does not use the samtools API, it calls samtools
542
- directly as if on the command line and catches the output, to use this
543
- method you must have a version of samtools that supports the pileup command
544
- (&lt; 0.1.17) otherwise the command will fail. mpileup is the preferred
545
- method for getting pileups. With this method the sam object should be
546
- created as usual, but you need to pass this method a string of options for
547
- samtools you don’t need to provide the call to samtools pileup itself or
548
- -f &lt;fasta file&gt; or the bam file itself, these are taken from the sam
549
- object</p>
550
-
551
-
552
-
553
- <div class="method-source-code" id="deprecated_pileup-source">
554
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 473</span>
555
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">deprecated_pileup</span>( <span class="ruby-identifier">cmd</span> )
556
-
557
- <span class="ruby-identifier">system</span>(<span class="ruby-string">'samtools pileup &gt; /dev/null 2&gt;&amp;1'</span>)
558
- <span class="ruby-comment">##assumes samtools is in the path...</span>
559
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">$?</span>.<span class="ruby-identifier">exitstatus</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>
560
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">RuntimeError</span>, <span class="ruby-string">&quot;samtools is required on the path. A version of samtools with the pileup function is required&quot;</span>
561
- <span class="ruby-keyword">end</span>
562
-
563
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No BAMFile provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@binary</span>
564
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No FastA provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@fasta_path</span>
565
-
566
- <span class="ruby-identifier">command</span> = <span class="ruby-string">'samtools pileup '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">cmd</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; -f #{@fasta_path}&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; #{@sam}&quot;</span>
567
-
568
- <span class="ruby-identifier">pipe</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">popen</span>(<span class="ruby-identifier">command</span>)
569
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">pipe</span>.<span class="ruby-identifier">gets</span>
570
- <span class="ruby-keyword">yield</span> <span class="ruby-constant">Pileup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>)
559
+ <p>returns an array for each position with [sequence_name, position, depth]</p>
560
+ <ul><li>
561
+ <p>b - list of positions or regions in BED format</p>
562
+ </li><li>
563
+ <p>l - [INT] minQLen</p>
564
+ </li><li>
565
+ <p>q - [INT] base quality threshold</p>
566
+ </li><li>
567
+ <p>Q - [INT] mapping quality threshold</p>
568
+ </li><li>
569
+ <p>r - [chr:from-to] region</p>
570
+ </li></ul>
571
+
572
+
573
+
574
+
575
+ <div class="method-source-code" id="depth-source">
576
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 538</span>
577
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">depth</span>(<span class="ruby-identifier">opts</span>={})
578
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&quot;depth&quot;</span>, <span class="ruby-identifier">opts</span>)
579
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
580
+ <span class="ruby-comment">#puts command</span>
581
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-constant">String</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
582
+ <span class="ruby-keyword">yield</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\t/</span>)
571
583
  <span class="ruby-keyword">end</span>
572
- <span class="ruby-identifier">pipe</span>.<span class="ruby-identifier">close</span>
584
+
573
585
  <span class="ruby-keyword">end</span></pre>
574
- </div><!-- deprecated_pileup-source -->
586
+ </div>
575
587
 
576
588
  </div>
577
589
 
578
590
 
579
591
 
580
592
 
581
- </div><!-- deprecated_pileup-method -->
593
+ </div>
582
594
 
583
595
 
584
- <div id="method-i-each_reference" class="method-detail ">
596
+ <div id="method-i-faidx" class="method-detail ">
585
597
 
586
598
  <div class="method-heading">
587
- <span class="method-name">each_reference</span><span
588
- class="method-args">() { |k, v| ... }</span>
599
+ <span class="method-name">faidx</span><span
600
+ class="method-args">(opts={})</span>
601
+
589
602
  <span class="method-click-advice">click to toggle source</span>
603
+
590
604
  </div>
591
605
 
592
606
 
593
607
  <div class="method-description">
594
608
 
595
- <p>yields each reference name and its length</p>
596
-
597
-
598
-
599
- <div class="method-source-code" id="each_reference-source">
600
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 535</span>
601
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">each_reference</span>
602
- <span class="ruby-identifier">refs</span> = <span class="ruby-identifier">index_stats</span>
603
- <span class="ruby-identifier">refs</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
604
- <span class="ruby-keyword">yield</span> <span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span>[<span class="ruby-value">:length</span>]
609
+ <p>Index reference sequence in the FASTA format or extract subsequence from
610
+ indexed reference sequence. If no region is specified, faidx will index the
611
+ file and create &lt;ref.fasta&gt;.fai on the disk. If regions are
612
+ speficified, the subsequences will be retrieved and printed to stdout in
613
+ the FASTA format. Options - if a subsequence is required</p>
614
+ <ul><li>
615
+ <p>chr - [STRING] the reference name of the subsequence</p>
616
+ </li><li>
617
+ <p>start - [INT] the start position for the subsequence</p>
618
+ </li><li>
619
+ <p>stop - [INT] the stop position for the subsequence</p>
620
+ </li></ul>
621
+
622
+
623
+
624
+
625
+ <div class="method-source-code" id="faidx-source">
626
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 275</span>
627
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">faidx</span>(<span class="ruby-identifier">opts</span>={})
628
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:chr</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:start</span>) <span class="ruby-keyword">and</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:stop</span>)
629
+ <span class="ruby-identifier">opts</span>={<span class="ruby-value">:as_bio</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>}
630
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">fetch_reference</span>(<span class="ruby-value">:chr</span>,<span class="ruby-value">:start</span>,<span class="ruby-value">:stop</span>,<span class="ruby-identifier">opts</span>)
631
+ <span class="ruby-keyword">else</span>
632
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} faidx #{@fasta}&quot;</span>
633
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
634
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
605
635
  <span class="ruby-keyword">end</span>
606
636
  <span class="ruby-keyword">end</span></pre>
607
- </div><!-- each_reference-source -->
637
+ </div>
608
638
 
609
639
  </div>
610
640
 
611
641
 
612
642
 
613
643
 
614
- </div><!-- each_reference-method -->
644
+ </div>
615
645
 
616
646
 
617
647
  <div id="method-i-fetch" class="method-detail ">
618
648
 
619
649
  <div class="method-heading">
620
650
  <span class="method-name">fetch</span><span
621
- class="method-args">(chromosome, qstart, qend)</span>
651
+ class="method-args">(chr, start,stop, &block)</span>
652
+
622
653
  <span class="method-click-advice">click to toggle source</span>
654
+
623
655
  </div>
624
656
 
625
657
 
626
658
  <div class="method-description">
627
659
 
628
- <p>Returns an array of Alignments on a given region.</p>
660
+ <p>fetches a subsequence and calls code block</p>
661
+ <ul><li>
662
+ <p>chr - the reference name for the subsequence</p>
663
+ </li><li>
664
+ <p>start - the start position for the subsequence</p>
665
+ </li><li>
666
+ <p>stop - the stop position for the subsequence</p>
667
+ </li><li>
668
+ <p>&amp;block - the the block of code to execute</p>
669
+ </li></ul>
670
+
629
671
 
630
672
 
631
673
 
632
674
  <div class="method-source-code" id="fetch-source">
633
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 211</span>
634
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">qend</span>)
635
- <span class="ruby-identifier">als</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
636
- <span class="ruby-identifier">fetchAlignment</span> = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">alignment</span><span class="ruby-operator">|</span>
637
- <span class="ruby-identifier">als</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">alignment</span>.<span class="ruby-identifier">clone</span>)
638
- <span class="ruby-value">0</span>
639
- <span class="ruby-keyword">end</span>
640
- <span class="ruby-identifier">fetch_with_function</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">qend</span>, <span class="ruby-identifier">fetchAlignment</span>)
641
- <span class="ruby-identifier">als</span>
675
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 87</span>
676
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch</span>(<span class="ruby-identifier">chr</span>, <span class="ruby-identifier">start</span>,<span class="ruby-identifier">stop</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
677
+ <span class="ruby-identifier">view</span>(
678
+ <span class="ruby-value">:chr</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">chr</span>,
679
+ <span class="ruby-value">:start</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">start</span>,
680
+ <span class="ruby-value">:stop</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">stop</span>,
681
+ <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
682
+ )
642
683
  <span class="ruby-keyword">end</span></pre>
643
- </div><!-- fetch-source -->
684
+ </div>
644
685
 
645
686
  </div>
646
687
 
647
688
 
689
+ <div class="aliases">
690
+ Also aliased as: <a href="Sam.html#method-i-fetch_with_function">fetch_with_function</a>
691
+ </div>
692
+
648
693
 
649
694
 
650
- </div><!-- fetch-method -->
695
+ </div>
651
696
 
652
697
 
653
698
  <div id="method-i-fetch_reference" class="method-detail ">
654
699
 
655
700
  <div class="method-heading">
656
701
  <span class="method-name">fetch_reference</span><span
657
- class="method-args">(chromosome, qstart,qend)</span>
702
+ class="method-args">(chr,start,stop, opts={:as_bio => false})</span>
703
+
658
704
  <span class="method-click-advice">click to toggle source</span>
705
+
659
706
  </div>
660
707
 
661
708
 
662
709
  <div class="method-description">
663
710
 
664
- <p>Returns the sequence for a given region.</p>
711
+ <p>fetches a subsequence from a reference genome and option returns it as a
712
+ Bio::Sequence::NA object</p>
713
+ <ul><li>
714
+ <p>chr - [STRING] the reference name for the subsequence</p>
715
+ </li><li>
716
+ <p>start - [INT] the start position for the subsequence</p>
717
+ </li><li>
718
+ <p>stop - [INT] the stop position for the subsequence</p>
719
+ </li><li>
720
+ <p>as_bio - boolean stating if the returned object should be a
721
+ Bio::Sequence::NA object</p>
722
+ </li></ul>
723
+
665
724
 
666
725
 
667
726
 
668
727
  <div class="method-source-code" id="fetch_reference-source">
669
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 193</span>
670
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_reference</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>,<span class="ruby-identifier">qend</span>)
671
- <span class="ruby-identifier">load_reference</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">null?</span>
672
- <span class="ruby-identifier">query</span> = <span class="ruby-identifier">query_string</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>,<span class="ruby-identifier">qend</span>)
673
- <span class="ruby-identifier">len</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:int</span>
674
- <span class="ruby-identifier">reference</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">fai_fetch</span>(<span class="ruby-ivar">@fasta_index</span>, <span class="ruby-identifier">query</span>, <span class="ruby-identifier">len</span>)
675
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Unable to get sequence for reference: &quot;</span><span class="ruby-operator">+</span><span class="ruby-identifier">query</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">reference</span>.<span class="ruby-identifier">nil?</span>
676
-
677
- <span class="ruby-identifier">reference</span>
728
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 258</span>
729
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_reference</span>(<span class="ruby-identifier">chr</span>,<span class="ruby-identifier">start</span>,<span class="ruby-identifier">stop</span>, <span class="ruby-identifier">opts</span>={<span class="ruby-value">:as_bio</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">false</span>})
730
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} faidx #{@fasta} #{chr}:#{start}-#{stop}&quot;</span>
731
+ <span class="ruby-comment">#puts command</span>
732
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
733
+ <span class="ruby-identifier">seq</span> = <span class="ruby-string">&quot;&quot;</span>
734
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-constant">String</span>, <span class="ruby-value">:text</span> ) {<span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">seq</span> = <span class="ruby-identifier">seq</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">line</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">line</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/^&gt;/</span>}
735
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:as_bio</span>]
736
+ <span class="ruby-identifier">seq</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Sequence</span><span class="ruby-operator">::</span><span class="ruby-constant">NA</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">seq</span>).<span class="ruby-identifier">to_fasta</span>(<span class="ruby-node">&quot;#{chr}:#{start}-#{stop}&quot;</span>)
737
+ <span class="ruby-keyword">end</span>
738
+ <span class="ruby-identifier">seq</span>
678
739
  <span class="ruby-keyword">end</span></pre>
679
- </div><!-- fetch_reference-source -->
740
+ </div>
680
741
 
681
742
  </div>
682
743
 
683
744
 
684
745
 
685
746
 
686
- </div><!-- fetch_reference-method -->
747
+ </div>
687
748
 
688
749
 
689
- <div id="method-i-fetch_with_function" class="method-detail ">
750
+ <div id="method-i-fetch_with_function" class="method-detail method-alias">
690
751
 
691
752
  <div class="method-heading">
692
753
  <span class="method-name">fetch_with_function</span><span
693
- class="method-args">(chromosome, qstart, qend, function)</span>
694
- <span class="method-click-advice">click to toggle source</span>
754
+ class="method-args">(chr, start,stop, &block)</span>
755
+
695
756
  </div>
696
757
 
697
758
 
698
759
  <div class="method-description">
699
760
 
700
- <p>Executes a function on each <a href="Alignment.html">Alignment</a> inside
701
- the queried region of the chromosome. The chromosome can be either the
702
- textual name or a FixNum with the internal index. However, you need to get
703
- the internal index with the provided API, otherwise the pointer is outside
704
- the scope of the C library. Returns the count of alignments in the region.
705
- WARNING: Accepts an index already parsed by the library. It fails when you
706
- use your own FixNum (FFI-bug?)</p>
707
-
708
-
709
-
710
- <div class="method-source-code" id="fetch_with_function-source">
711
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 226</span>
712
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">fetch_with_function</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>, <span class="ruby-identifier">qend</span>, <span class="ruby-identifier">function</span>)
713
- <span class="ruby-identifier">load_index</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">null?</span>
714
- <span class="ruby-identifier">chr</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:int</span>
715
- <span class="ruby-identifier">beg</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:int</span>
716
- <span class="ruby-identifier">last</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span> <span class="ruby-value">:int</span>
717
- <span class="ruby-identifier">query</span> = <span class="ruby-identifier">query_string</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>,<span class="ruby-identifier">qend</span>)
718
- <span class="ruby-identifier">qpointer</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">from_string</span>(<span class="ruby-identifier">query</span>)
719
- <span class="ruby-identifier">header</span> = <span class="ruby-ivar">@sam_file</span>[<span class="ruby-value">:header</span>]
720
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_parse_region</span>(<span class="ruby-identifier">header</span>,<span class="ruby-identifier">qpointer</span>, <span class="ruby-identifier">chr</span>, <span class="ruby-identifier">beg</span>, <span class="ruby-identifier">last</span>)
721
- <span class="ruby-comment">#raise SAMException.new(), &quot;invalid query: &quot; + query if(chr.read_int &lt; 0)</span>
722
- <span class="ruby-identifier">count</span> = <span class="ruby-value">0</span>;
723
-
724
- <span class="ruby-identifier">fetchAlignment</span> = <span class="ruby-constant">Proc</span>.<span class="ruby-identifier">new</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">bam_alignment</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
725
- <span class="ruby-identifier">alignment</span> = <span class="ruby-constant">Alignment</span>.<span class="ruby-identifier">new</span>
726
- <span class="ruby-identifier">alignment</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">bam_alignment</span>, <span class="ruby-identifier">header</span>)
727
- <span class="ruby-identifier">function</span>.<span class="ruby-identifier">call</span>(<span class="ruby-identifier">alignment</span>)
728
- <span class="ruby-identifier">count</span> = <span class="ruby-identifier">count</span> <span class="ruby-operator">+</span> <span class="ruby-value">1</span>
729
- <span class="ruby-value">0</span>
730
- <span class="ruby-keyword">end</span>
731
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_fetch</span>(<span class="ruby-ivar">@sam_file</span>[<span class="ruby-value">:x</span>][<span class="ruby-value">:bam</span>], <span class="ruby-ivar">@sam_index</span>,<span class="ruby-identifier">chr</span>.<span class="ruby-identifier">read_int</span>,<span class="ruby-identifier">beg</span>.<span class="ruby-identifier">read_int</span>, <span class="ruby-identifier">last</span>.<span class="ruby-identifier">read_int</span>, <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">fetchAlignment</span>)
732
- <span class="ruby-comment">#LibC.free chr</span>
733
- <span class="ruby-comment">#LibC.free beg</span>
734
- <span class="ruby-comment">#LibC.free last</span>
735
- <span class="ruby-comment">#LibC.free qpointer</span>
736
- <span class="ruby-identifier">count</span>
737
- <span class="ruby-keyword">end</span></pre>
738
- </div><!-- fetch_with_function-source -->
761
+
762
+
763
+
764
+
739
765
 
740
766
  </div>
741
767
 
742
768
 
743
769
 
744
770
 
745
- </div><!-- fetch_with_function-method -->
771
+ <div class="aliases">
772
+ Alias for: <a href="Sam.html#method-i-fetch">fetch</a>
773
+ </div>
774
+
775
+ </div>
746
776
 
747
777
 
748
- <div id="method-i-index_stats" class="method-detail ">
778
+ <div id="method-i-fix_mates" class="method-detail ">
749
779
 
750
780
  <div class="method-heading">
751
- <span class="method-name">index_stats</span><span
752
- class="method-args">()</span>
781
+ <span class="method-name">fix_mates</span><span
782
+ class="method-args">(opts={})</span>
783
+
753
784
  <span class="method-click-advice">click to toggle source</span>
785
+
754
786
  </div>
755
787
 
756
788
 
757
789
  <div class="method-description">
758
790
 
791
+ <p>Fill in mate coordinates, ISIZE and mate related flags from a name-sorted
792
+ alignment</p>
793
+ <ul><li>
794
+ <p>out_bam name of outfile</p>
795
+ </li><li>
796
+ <p>r - remove unmapped reads and secondary alignments</p>
797
+ </li></ul>
759
798
 
760
799
 
761
800
 
762
801
 
763
- <div class="method-source-code" id="index_stats-source">
764
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 494</span>
765
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">index_stats</span>
766
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No BAMFile provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@binary</span>
767
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No FastA provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@fasta_path</span>
768
- <span class="ruby-identifier">strptrs</span> = []
769
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">from_string</span>(<span class="ruby-string">&quot;idxstats&quot;</span>)
770
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">from_string</span>(<span class="ruby-ivar">@sam</span>)
771
- <span class="ruby-identifier">strptrs</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-keyword">nil</span>
772
-
773
- <span class="ruby-comment"># Now load all the pointers into a native memory block</span>
774
- <span class="ruby-identifier">argv</span> = <span class="ruby-constant">FFI</span><span class="ruby-operator">::</span><span class="ruby-constant">MemoryPointer</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:pointer</span>, <span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">length</span>)
775
- <span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">each_with_index</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span>, <span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
776
- <span class="ruby-identifier">argv</span>[<span class="ruby-identifier">i</span>].<span class="ruby-identifier">put_pointer</span>(<span class="ruby-value">0</span>, <span class="ruby-identifier">p</span>)
802
+ <div class="method-source-code" id="fix_mates-source">
803
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 298</span>
804
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">fix_mates</span>(<span class="ruby-identifier">opts</span>={})
805
+ <span class="ruby-comment">#opts.merge!({:out_index=&gt;nil})</span>
806
+ <span class="ruby-identifier">remove_reads</span> = <span class="ruby-string">&quot;&quot;</span>
807
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:r</span>]
808
+ <span class="ruby-identifier">remove_reads</span> = <span class="ruby-string">&quot;-r&quot;</span>
777
809
  <span class="ruby-keyword">end</span>
778
-
779
- <span class="ruby-identifier">index_stats</span> = {}
780
-
781
- <span class="ruby-identifier">old_stdout</span> = <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">clone</span>
782
- <span class="ruby-identifier">read_pipe</span>, <span class="ruby-identifier">write_pipe</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">pipe</span>()
783
- <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-identifier">write_pipe</span>)
784
-
785
- <span class="ruby-comment">#int bam_idxstats(int argc, char *argv[])</span>
786
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_idxstats</span>(<span class="ruby-identifier">strptrs</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>,<span class="ruby-identifier">argv</span>)
787
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">fork</span>
788
- <span class="ruby-identifier">write_pipe</span>.<span class="ruby-identifier">close</span>
789
- <span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">reopen</span>(<span class="ruby-identifier">old_stdout</span>) <span class="ruby-comment">#beware .. stdout from other processes eg tests calling this method can get mixed in...</span>
790
- <span class="ruby-keyword">begin</span>
791
-
792
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">read_pipe</span>.<span class="ruby-identifier">readline</span> <span class="ruby-comment">#TAB delimited with each line consisting of reference sequence name, sequence length, # mapped reads and # unmapped reads.</span>
793
- <span class="ruby-identifier">info</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">%r\t/</span>)
794
- <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">info</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">4</span>
795
- <span class="ruby-identifier">index_stats</span>[ <span class="ruby-identifier">info</span>[<span class="ruby-value">0</span>] ] = {<span class="ruby-value">:length</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:mapped_reads</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">2</span>].<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:unmapped_reads</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">3</span>].<span class="ruby-identifier">to_i</span> }
796
- <span class="ruby-keyword">end</span>
797
- <span class="ruby-keyword">rescue</span> <span class="ruby-constant">EOFError</span>
798
- <span class="ruby-identifier">read_pipe</span>.<span class="ruby-identifier">close</span>
799
- <span class="ruby-constant">Process</span>.<span class="ruby-identifier">wait</span>
800
- <span class="ruby-keyword">end</span>
801
- <span class="ruby-keyword">end</span> <span class="ruby-comment">#fork</span>
802
- <span class="ruby-identifier">index_stats</span>
810
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} fixmate #{remove_reads} #{@bam} #{opts[:out_bam]}&quot;</span>
811
+ <span class="ruby-comment">#puts command</span>
812
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
813
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
803
814
  <span class="ruby-keyword">end</span></pre>
804
- </div><!-- index_stats-source -->
815
+ </div>
805
816
 
806
817
  </div>
807
818
 
808
819
 
820
+ <div class="aliases">
821
+ Also aliased as: <a href="Sam.html#method-i-fixmate">fixmate</a>
822
+ </div>
823
+
809
824
 
810
825
 
811
- </div><!-- index_stats-method -->
826
+ </div>
812
827
 
813
828
 
814
- <div id="method-i-load_index" class="method-detail ">
829
+ <div id="method-i-fixmate" class="method-detail method-alias">
815
830
 
816
831
  <div class="method-heading">
817
- <span class="method-name">load_index</span><span
818
- class="method-args">()</span>
819
- <span class="method-click-advice">click to toggle source</span>
832
+ <span class="method-name">fixmate</span><span
833
+ class="method-args">(opts={})</span>
834
+
820
835
  </div>
821
836
 
822
837
 
823
838
  <div class="method-description">
824
839
 
825
- <p>Loads the bam index to be used for fetching. If the index doesn’t exists
826
- the index is built provided that the user has writing access to the folder
827
- where the BAM file is located. If the creation of the file fails a <a
828
- href="SAMException.html">SAMException</a> is thrown. If the index
829
- doesn’t exist, loading it will take more time. It is suggested to
830
- generate the index separatedly if the bam file sits on a server where the
831
- executing user may not have writing permissions in the server.</p>
832
-
833
-
834
-
835
- <div class="method-source-code" id="load_index-source">
836
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 114</span>
837
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">load_index</span>()
838
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Indexes are only supported by BAM files, please use samtools to convert your SAM file&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@binary</span>
839
- <span class="ruby-ivar">@sam_index</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_index_load</span>(<span class="ruby-ivar">@sam</span>)
840
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">null?</span> <span class="ruby-keyword">then</span>
841
- <span class="ruby-identifier">p</span> <span class="ruby-string">&quot;Generating index for: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@sam</span>
842
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_index_build</span>(<span class="ruby-ivar">@sam</span>)
843
- <span class="ruby-ivar">@sam_index</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">bam_index_load</span>(<span class="ruby-ivar">@sam</span>)
844
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Unable to generate bam index for: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@sam</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@sam_index</span>.<span class="ruby-identifier">null?</span>
845
- <span class="ruby-keyword">end</span>
846
- <span class="ruby-keyword">end</span></pre>
847
- </div><!-- load_index-source -->
840
+
841
+
842
+
843
+
848
844
 
849
845
  </div>
850
846
 
851
847
 
852
848
 
853
849
 
854
- </div><!-- load_index-method -->
850
+ <div class="aliases">
851
+ Alias for: <a href="Sam.html#method-i-fix_mates">fix_mates</a>
852
+ </div>
853
+
854
+ </div>
855
855
 
856
856
 
857
- <div id="method-i-load_reference" class="method-detail ">
857
+ <div id="method-i-flag_stats" class="method-detail ">
858
858
 
859
859
  <div class="method-heading">
860
- <span class="method-name">load_reference</span><span
861
- class="method-args">()</span>
860
+ <span class="method-name">flag_stats</span><span
861
+ class="method-args">(opts={})</span>
862
+
862
863
  <span class="method-click-advice">click to toggle source</span>
864
+
863
865
  </div>
864
866
 
865
867
 
866
868
  <div class="method-description">
867
869
 
868
- <p>Loads the reference file to be able to query regions of it. This requires
869
- the fai index to exist in the same folder than the reference. If it
870
- doesn’t exisits, this functions attempts to generate it. If user
871
- doesn’t have writing permissions on the folder, or the creation of the
872
- fai fails for any reason, a <a href="SAMException.html">SAMException</a> is
873
- thrown.</p>
870
+ <p>generate simple stats with regard to the number and pairing of reads mapped
871
+ to a reference</p>
874
872
 
875
-
876
873
 
877
- <div class="method-source-code" id="load_reference-source">
878
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 128</span>
879
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">load_reference</span>()
880
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No path for the refernce fasta file. &quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@fasta_path</span>.<span class="ruby-identifier">nil?</span>
881
-
882
- <span class="ruby-ivar">@fasta_index</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">fai_load</span>(<span class="ruby-ivar">@fasta_path</span>)
883
-
884
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">null?</span> <span class="ruby-keyword">then</span>
885
- <span class="ruby-identifier">p</span> <span class="ruby-string">&quot;Generating index for: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@fasta_path</span>
886
- <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">fai_build</span>(<span class="ruby-ivar">@fasta_path</span>)
887
- <span class="ruby-ivar">@fasta_index</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">fai_load</span>(<span class="ruby-ivar">@fasta_path</span>)
888
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Unable to generate fasta index for: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@fasta_path</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-operator">||</span> <span class="ruby-ivar">@fasta_index</span>.<span class="ruby-identifier">null?</span>
889
- <span class="ruby-keyword">end</span>
890
874
 
875
+
876
+ <div class="method-source-code" id="flag_stats-source">
877
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 313</span>
878
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">flag_stats</span>(<span class="ruby-identifier">opts</span>={})
879
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&quot;flagstat&quot;</span>, <span class="ruby-identifier">opts</span>, [])
880
+ <span class="ruby-comment">#puts command</span>
881
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
882
+ <span class="ruby-identifier">strings</span> = []
883
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>,<span class="ruby-constant">String</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span> <span class="ruby-identifier">strings</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>}
884
+ <span class="ruby-identifier">strings</span>
891
885
  <span class="ruby-keyword">end</span></pre>
892
- </div><!-- load_reference-source -->
886
+ </div>
893
887
 
894
888
  </div>
895
889
 
896
890
 
891
+ <div class="aliases">
892
+ Also aliased as: <a href="Sam.html#method-i-flagstat">flagstat</a>
893
+ </div>
894
+
897
895
 
898
896
 
899
- </div><!-- load_reference-method -->
897
+ </div>
900
898
 
901
899
 
902
- <div id="method-i-mpileup" class="method-detail ">
900
+ <div id="method-i-flagstat" class="method-detail method-alias">
903
901
 
904
902
  <div class="method-heading">
905
- <span class="method-name">mpileup</span><span
906
- class="method-args">( opts={}) { |pileup| ... }</span>
907
- <span class="method-click-advice">click to toggle source</span>
903
+ <span class="method-name">flagstat</span><span
904
+ class="method-args">(opts={})</span>
905
+
908
906
  </div>
909
907
 
910
908
 
911
909
  <div class="method-description">
912
910
 
913
- <p>calls the mpileup function, opts is a hash of options identical to the
914
- command line options for mpileup. is an iterator that yields a <a
915
- href="Pileup.html">Pileup</a> object for each postion the command line
916
- options that generate/affect BCF/VCF are ignored ie (g,u,e,h,I,L,o,p) call
917
- the option as a symbol of the flag, eg -r for region is called :r =&gt;
918
- “some <a href="SAM.html">SAM</a> compatible region” eg bam.mpileup(:r
919
- =&gt; “chr1:1000-2000”, :q =&gt; 50) gets the bases with quality &gt;
920
- 50 on chr1 between 1000-5000</p>
911
+
912
+
921
913
 
922
914
 
923
915
 
924
- <div class="method-source-code" id="mpileup-source">
925
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 281</span>
926
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">mpileup</span>( <span class="ruby-identifier">opts</span>={})
927
-
928
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No BAMFile provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@binary</span>
929
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No FastA provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@fasta_path</span>
930
- <span class="ruby-comment">#long option form to short samtools form..</span>
931
- <span class="ruby-identifier">long_opts</span> = {
932
- <span class="ruby-value">:region</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:r</span>,
933
- <span class="ruby-value">:illumina_quals</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:six</span>,
934
- <span class="ruby-value">:count_anomalous</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:A</span>,
935
- <span class="ruby-value">:no_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:B</span>,
936
- <span class="ruby-value">:adjust_mapq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:C</span>,
937
- <span class="ruby-value">:max_per_bam_depth</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:d</span>,
938
- <span class="ruby-value">:extended_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:E</span>,
939
- <span class="ruby-value">:exclude_reads_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:G</span>,
940
- <span class="ruby-value">:list_of_positions</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:l</span>,
941
- <span class="ruby-value">:mapping_quality_cap</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:M</span>,
942
- <span class="ruby-value">:ignore_rg</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:R</span>,
943
- <span class="ruby-value">:min_mapping_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:q</span>,
944
- <span class="ruby-value">:min_base_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:Q</span>
945
- }
946
- <span class="ruby-comment">##convert any long_opts to short opts </span>
947
- <span class="ruby-identifier">temp_opts</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">dup</span>
948
- <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
949
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]
950
- <span class="ruby-identifier">temp_opts</span>[<span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]] = <span class="ruby-identifier">v</span>
951
- <span class="ruby-identifier">temp_opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
952
- <span class="ruby-keyword">end</span>
953
- <span class="ruby-keyword">end</span>
954
- <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">temp_opts</span>
955
- <span class="ruby-comment">##remove any calls to -g or -u for mpileup, bcf output is not yet supported</span>
956
- <span class="ruby-comment">##and also associated output options</span>
957
- [<span class="ruby-value">:g</span>, <span class="ruby-value">:u</span>, <span class="ruby-value">:e</span>, <span class="ruby-value">:h</span>, <span class="ruby-value">:I</span>, <span class="ruby-value">:L</span>, <span class="ruby-value">:o</span>, <span class="ruby-value">:p</span>].<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">x</span>) }
958
-
959
- <span class="ruby-identifier">sam_opts</span> = []
960
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(&quot;mpileup&quot;)</span>
961
- <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
962
- <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">k</span>] <span class="ruby-comment">##dont bother unless the values provided are true.. </span>
963
- <span class="ruby-identifier">k</span> = <span class="ruby-string">'6'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-value">:six</span>
964
- <span class="ruby-identifier">k</span> = <span class="ruby-string">'-'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>
965
- <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">k</span> <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(k)</span>
966
- <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">unless</span> [<span class="ruby-string">&quot;-R&quot;</span>, <span class="ruby-string">&quot;-B&quot;</span>, <span class="ruby-string">&quot;-E&quot;</span>, <span class="ruby-string">&quot;-6&quot;</span>, <span class="ruby-string">&quot;-A&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-comment">#these are just flags so don't pass a value... strptrs &lt;&lt; FFI::MemoryPointer.from_string(v.to_s)</span>
967
- <span class="ruby-keyword">end</span>
968
- <span class="ruby-identifier">sam_opts</span> = <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">+</span> [<span class="ruby-string">'-f'</span>, <span class="ruby-ivar">@fasta_path</span>, <span class="ruby-ivar">@sam</span>]
969
- <span class="ruby-identifier">sam_command</span> = <span class="ruby-node">&quot;#{File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools')} mpileup #{sam_opts.join(' ')} 2&gt; /dev/null&quot;</span>
970
-
971
- <span class="ruby-identifier">sam_pipe</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">popen</span>(<span class="ruby-identifier">sam_command</span>)
972
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">sam_pipe</span>.<span class="ruby-identifier">gets</span>
973
- <span class="ruby-keyword">yield</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Pileup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>)
974
- <span class="ruby-keyword">end</span>
975
- <span class="ruby-identifier">sam_pipe</span>.<span class="ruby-identifier">close</span>
976
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string('-f')</span>
977
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(@fasta_path)</span>
978
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(@sam)</span>
979
- <span class="ruby-comment">#strptrs &lt;&lt; nil</span>
980
-
981
- <span class="ruby-comment"># Now load all the pointers into a native memory block</span>
982
- <span class="ruby-comment">#argv = FFI::MemoryPointer.new(:pointer, strptrs.length)</span>
983
- <span class="ruby-comment">#strptrs.each_with_index do |p, i|</span>
984
- <span class="ruby-comment"># argv[i].put_pointer(0, p)</span>
985
- <span class="ruby-comment">#end</span>
986
-
987
- <span class="ruby-comment">#old_stdout = STDOUT.clone</span>
988
- <span class="ruby-comment">#read_pipe, write_pipe = IO.pipe()</span>
989
- <span class="ruby-comment">#STDOUT.reopen(write_pipe)</span>
990
- <span class="ruby-comment">#int bam_mpileup(int argc, char *argv[])</span>
991
- <span class="ruby-comment"># Bio::DB::SAM::Tools.bam_mpileup(strptrs.length - 1,argv)</span>
992
- <span class="ruby-comment">#if fork</span>
993
- <span class="ruby-comment"># write_pipe.close</span>
994
- <span class="ruby-comment"># STDOUT.reopen(old_stdout) #beware .. stdout from other processes eg tests calling this method can get mixed in...</span>
995
- <span class="ruby-comment"># begin</span>
996
- <span class="ruby-comment"># while line = read_pipe.readline</span>
997
- <span class="ruby-comment"># yield Pileup.new(line)</span>
998
- <span class="ruby-comment"># end</span>
999
- <span class="ruby-comment"># rescue EOFError</span>
1000
- <span class="ruby-comment"># read_pipe.close</span>
1001
- <span class="ruby-comment"># Process.wait</span>
1002
- <span class="ruby-comment"># end</span>
1003
- <span class="ruby-comment">#end</span>
1004
- <span class="ruby-keyword">end</span></pre>
1005
- </div><!-- mpileup-source -->
1006
-
1007
- </div>
1008
-
1009
-
1010
-
1011
-
1012
- </div><!-- mpileup-method -->
1013
-
1014
-
1015
- <div id="method-i-mpileup_plus" class="method-detail ">
1016
-
1017
- <div class="method-heading">
1018
- <span class="method-name">mpileup_plus</span><span
1019
- class="method-args">( opts ) { |vcf| ... }</span>
1020
- <span class="method-click-advice">click to toggle source</span>
916
+ </div>
917
+
918
+
919
+
920
+
921
+ <div class="aliases">
922
+ Alias for: <a href="Sam.html#method-i-flag_stats">flag_stats</a>
923
+ </div>
924
+
925
+ </div>
926
+
927
+
928
+ <div id="method-i-idxstats" class="method-detail method-alias">
929
+
930
+ <div class="method-heading">
931
+ <span class="method-name">idxstats</span><span
932
+ class="method-args">()</span>
933
+
934
+ </div>
935
+
936
+
937
+ <div class="method-description">
938
+
939
+
940
+
941
+
942
+
943
+
944
+ </div>
945
+
946
+
947
+
948
+
949
+ <div class="aliases">
950
+ Alias for: <a href="Sam.html#method-i-index_stats">index_stats</a>
951
+ </div>
952
+
953
+ </div>
954
+
955
+
956
+ <div id="method-i-index" class="method-detail ">
957
+
958
+ <div class="method-heading">
959
+ <span class="method-name">index</span><span
960
+ class="method-args">(opts={})</span>
961
+
962
+ <span class="method-click-advice">click to toggle source</span>
963
+
964
+ </div>
965
+
966
+
967
+ <div class="method-description">
968
+
969
+ <p>Index sorted alignment for fast random access. Index file
970
+ &lt;aln.bam&gt;.bai will be created of no out_index is provided.</p>
971
+ <ul><li>
972
+ <p>out_index - [STRING] name of index</p>
973
+ </li></ul>
974
+
975
+
976
+
977
+
978
+ <div class="method-source-code" id="index-source">
979
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 288</span>
980
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">index</span>(<span class="ruby-identifier">opts</span>={})
981
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} index #{@bam} #{opts[:out_index]}&quot;</span>
982
+ <span class="ruby-comment">#puts command</span>
983
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
984
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
985
+ <span class="ruby-keyword">end</span></pre>
986
+ </div>
987
+
988
+ </div>
989
+
990
+
991
+
992
+
993
+ </div>
994
+
995
+
996
+ <div id="method-i-index_stats" class="method-detail ">
997
+
998
+ <div class="method-heading">
999
+ <span class="method-name">index_stats</span><span
1000
+ class="method-args">()</span>
1001
+
1002
+ <span class="method-click-advice">click to toggle source</span>
1003
+
1021
1004
  </div>
1022
1005
 
1023
1006
 
1024
1007
  <div class="method-description">
1025
1008
 
1026
- <p>experimental method that spawns a samtools mpileup | bcftools view process
1027
- and supports returning of pileup vcf</p>
1028
-
1029
- <pre>otherwise works like mpileup</pre>
1030
-
1031
-
1032
-
1033
- <div class="method-source-code" id="mpileup_plus-source">
1034
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 363</span>
1035
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">mpileup_plus</span>( <span class="ruby-identifier">opts</span> )
1036
-
1037
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No BAMFile provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam</span> <span class="ruby-keyword">and</span> <span class="ruby-ivar">@binary</span>
1038
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No FastA provided&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@fasta_path</span>
1039
- <span class="ruby-comment">#long option form to short samtools form..</span>
1040
- <span class="ruby-identifier">long_opts</span> = {
1041
- <span class="ruby-value">:region</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:r</span>,
1042
- <span class="ruby-value">:illumina_quals</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:six</span>,
1043
- <span class="ruby-value">:count_anomalous</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:A</span>,
1044
- <span class="ruby-value">:no_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:B</span>,
1045
- <span class="ruby-value">:adjust_mapq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:C</span>,
1046
- <span class="ruby-value">:max_per_bam_depth</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:d</span>,
1047
- <span class="ruby-value">:extended_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:E</span>,
1048
- <span class="ruby-value">:exclude_reads_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:G</span>,
1049
- <span class="ruby-value">:list_of_positions</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:l</span>,
1050
- <span class="ruby-value">:mapping_quality_cap</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:M</span>,
1051
- <span class="ruby-value">:ignore_rg</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:R</span>,
1052
- <span class="ruby-value">:min_mapping_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:q</span>,
1053
- <span class="ruby-value">:min_base_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:Q</span>,
1054
- <span class="ruby-comment">###following options are for the -g -u option</span>
1055
- <span class="ruby-value">:genotype_calling</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:g</span>,
1056
- <span class="ruby-value">:uncompressed_bcf</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:u</span>,
1057
- <span class="ruby-value">:extension_sequencing_probability</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:e</span>,
1058
- <span class="ruby-value">:homopolymer_error_coefficient</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:h</span>,
1059
- <span class="ruby-value">:no_indels</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:I</span>,
1060
- <span class="ruby-value">:skip_indel_over_average_depth</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:L</span>,
1061
- <span class="ruby-value">:gap_open_sequencing_error_probability</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:o</span>,
1062
- <span class="ruby-value">:platforms</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:P</span>
1063
- }
1064
-
1065
- <span class="ruby-comment">##convert any long_opts to short opts </span>
1066
- <span class="ruby-identifier">temp_opts</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">dup</span>
1067
- <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
1068
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]
1069
- <span class="ruby-identifier">temp_opts</span>[<span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]] = <span class="ruby-identifier">v</span>
1070
- <span class="ruby-identifier">temp_opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
1071
- <span class="ruby-keyword">end</span>
1072
- <span class="ruby-keyword">end</span>
1073
- <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">temp_opts</span>
1074
- <span class="ruby-comment">##remove any calls to -g or -u for mpileup, bcf output is not yet supported</span>
1075
- <span class="ruby-comment">##and also associated output options</span>
1076
- <span class="ruby-comment">#[:g, :u, :e, :h, :I, :L, :o, :p].each {|x| opts.delete(x) }</span>
1077
- <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:g</span>] <span class="ruby-comment">#so that we always get uncompressed output</span>
1078
- <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:g</span>)
1079
-
1080
- <span class="ruby-identifier">sam_opts</span> = []
1081
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(&quot;mpileup&quot;)</span>
1082
- <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
1083
- <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">opts</span>[<span class="ruby-identifier">k</span>] <span class="ruby-comment">##dont bother unless the values provided are true.. </span>
1084
- <span class="ruby-identifier">k</span> = <span class="ruby-string">'6'</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">k</span> <span class="ruby-operator">==</span> <span class="ruby-value">:six</span>
1085
- <span class="ruby-identifier">k</span> = <span class="ruby-string">'-'</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">k</span>.<span class="ruby-identifier">to_s</span>
1086
- <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">k</span> <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(k)</span>
1087
- <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">v</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-keyword">unless</span> [<span class="ruby-string">&quot;-R&quot;</span>, <span class="ruby-string">&quot;-B&quot;</span>, <span class="ruby-string">&quot;-E&quot;</span>, <span class="ruby-string">&quot;-6&quot;</span>, <span class="ruby-string">&quot;-A&quot;</span>, <span class="ruby-string">&quot;-g&quot;</span>, <span class="ruby-string">&quot;-u&quot;</span>, <span class="ruby-string">&quot;-I&quot;</span>].<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">k</span>) <span class="ruby-comment">#these are just flags so don't pass a value... strptrs &lt;&lt; FFI::MemoryPointer.from_string(v.to_s)</span>
1088
- <span class="ruby-keyword">end</span>
1089
- <span class="ruby-identifier">sam_opts</span> = <span class="ruby-identifier">sam_opts</span> <span class="ruby-operator">+</span> [<span class="ruby-string">'-f'</span>, <span class="ruby-ivar">@fasta_path</span>, <span class="ruby-ivar">@sam</span>]
1090
-
1091
- <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','samtools')} mpileup #{sam_opts.join(' ')} 2&gt; /dev/null&quot;</span>
1092
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>]
1093
- <span class="ruby-identifier">command</span> = <span class="ruby-identifier">command</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; | #{File.join(File.expand_path(File.dirname(__FILE__)),'sam','external','bcftools')} view -cg -&quot;</span>
1094
- <span class="ruby-keyword">end</span>
1095
- <span class="ruby-identifier">pipe</span> = <span class="ruby-constant">IO</span>.<span class="ruby-identifier">popen</span>(<span class="ruby-identifier">command</span>)
1096
- <span class="ruby-identifier">$stderr</span>.<span class="ruby-identifier">puts</span> <span class="ruby-identifier">command</span>
1097
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>]
1098
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">pipe</span>.<span class="ruby-identifier">gets</span>
1099
- <span class="ruby-keyword">next</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">'#'</span> <span class="ruby-comment">#skip any header or meta-lines, we dont do anything with those </span>
1100
- <span class="ruby-keyword">yield</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Vcf</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>)
1101
- <span class="ruby-keyword">end</span>
1102
- <span class="ruby-keyword">else</span>
1103
- <span class="ruby-keyword">while</span> <span class="ruby-identifier">line</span> = <span class="ruby-identifier">pipe</span>.<span class="ruby-identifier">gets</span>
1104
- <span class="ruby-keyword">yield</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Pileup</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">line</span>)
1105
- <span class="ruby-keyword">end</span>
1106
- <span class="ruby-keyword">end</span>
1107
- <span class="ruby-identifier">pipe</span>.<span class="ruby-identifier">close</span>
1108
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string('-f')</span>
1109
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(@fasta_path)</span>
1110
- <span class="ruby-comment">#strptrs &lt;&lt; FFI::MemoryPointer.from_string(@sam)</span>
1111
- <span class="ruby-comment">#strptrs &lt;&lt; nil</span>
1112
-
1113
- <span class="ruby-comment"># Now load all the pointers into a native memory block</span>
1114
- <span class="ruby-comment">#argv = FFI::MemoryPointer.new(:pointer, strptrs.length)</span>
1115
- <span class="ruby-comment">#strptrs.each_with_index do |p, i|</span>
1116
- <span class="ruby-comment"># argv[i].put_pointer(0, p)</span>
1117
- <span class="ruby-comment">#end</span>
1118
-
1119
- <span class="ruby-comment">#old_stdout = STDOUT.clone</span>
1120
- <span class="ruby-comment">#read_pipe, write_pipe = IO.pipe()</span>
1121
- <span class="ruby-comment">#STDOUT.reopen(write_pipe)</span>
1122
- <span class="ruby-comment">#int bam_mpileup(int argc, char *argv[])</span>
1123
- <span class="ruby-comment"># Bio::DB::SAM::Tools.bam_mpileup(strptrs.length - 1,argv)</span>
1124
- <span class="ruby-comment">#if fork</span>
1125
- <span class="ruby-comment"># write_pipe.close</span>
1126
- <span class="ruby-comment"># STDOUT.reopen(old_stdout) #beware .. stdout from other processes eg tests calling this method can get mixed in...</span>
1127
- <span class="ruby-comment"># begin</span>
1128
- <span class="ruby-comment"># while line = read_pipe.readline</span>
1129
- <span class="ruby-comment"># yield Pileup.new(line)</span>
1130
- <span class="ruby-comment"># end</span>
1131
- <span class="ruby-comment"># rescue EOFError</span>
1132
- <span class="ruby-comment"># read_pipe.close</span>
1133
- <span class="ruby-comment"># Process.wait</span>
1134
- <span class="ruby-comment"># end</span>
1135
- <span class="ruby-comment">#end</span>
1136
- <span class="ruby-keyword">end</span></pre>
1137
- </div><!-- mpileup_plus-source -->
1138
-
1139
- </div>
1140
-
1141
-
1142
-
1143
-
1144
- </div><!-- mpileup_plus-method -->
1009
+ <p>Retrieve and print stats in the index file. The output is TAB delimited
1010
+ with each line consisting of reference sequence name, sequence length,
1011
+ number of mapped reads and number unmapped reads.</p>
1012
+
1013
+
1014
+
1015
+
1016
+ <div class="method-source-code" id="index_stats-source">
1017
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 325</span>
1018
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">index_stats</span>
1019
+ <span class="ruby-identifier">stats</span> = {}
1020
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-node">&quot;idxstats #{@bam}&quot;</span>, {}, [])
1021
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1022
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-constant">String</span>, <span class="ruby-value">:text</span>, <span class="ruby-keyword">true</span>, <span class="ruby-node">&quot;#&quot;</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
1023
+ <span class="ruby-identifier">info</span> = <span class="ruby-identifier">line</span>.<span class="ruby-identifier">chomp</span>.<span class="ruby-identifier">split</span>(<span class="ruby-regexp">/\t/</span>)
1024
+ <span class="ruby-identifier">stats</span>[ <span class="ruby-identifier">info</span>[<span class="ruby-value">0</span>] ] = {<span class="ruby-value">:length</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:mapped_reads</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">2</span>].<span class="ruby-identifier">to_i</span>, <span class="ruby-value">:unmapped_reads</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">info</span>[<span class="ruby-value">3</span>].<span class="ruby-identifier">to_i</span> }
1025
+ <span class="ruby-keyword">end</span>
1026
+ <span class="ruby-identifier">stats</span>
1027
+ <span class="ruby-keyword">end</span></pre>
1028
+ </div>
1029
+
1030
+ </div>
1031
+
1032
+
1033
+ <div class="aliases">
1034
+ Also aliased as: <a href="Sam.html#method-i-idxstats">idxstats</a>
1035
+ </div>
1036
+
1037
+
1038
+
1039
+ </div>
1040
+
1041
+
1042
+ <div id="method-i-merge" class="method-detail ">
1043
+
1044
+ <div class="method-heading">
1045
+ <span class="method-name">merge</span><span
1046
+ class="method-args">(opts={})</span>
1047
+
1048
+ <span class="method-click-advice">click to toggle source</span>
1049
+
1050
+ </div>
1051
+
1052
+
1053
+ <div class="method-description">
1054
+
1055
+ <p>Merge multiple sorted alignments</p>
1056
+ <ul><li>
1057
+ <p>n - sort by read names</p>
1058
+ </li><li>
1059
+ <p>r - attach RG tag (inferred from file names)</p>
1060
+ </li><li>
1061
+ <p>u - uncompressed BAM output</p>
1062
+ </li><li>
1063
+ <p>f - overwrite the output BAM if exist</p>
1064
+ </li><li>
1065
+ <p>one - compress level 1</p>
1066
+ </li><li>
1067
+ <p>l - [INT] compression level, from 0 to 9 [-1]</p>
1068
+ </li><li>
1069
+ <p>at - [INT] number of BAM compression threads [0]</p>
1070
+ </li><li>
1071
+ <p>R - [STRING] merge file in the specified region STR [all]</p>
1072
+ </li><li>
1073
+ <p>h - [FILE] copy the header in FILE to &lt;out.bam&gt; [in1.bam]</p>
1074
+ </li><li>
1075
+ <p>out - [FILE] out file name</p>
1076
+ </li><li>
1077
+ <p>bams - [FILES] or <a href="Sam.html">Bio::DB::Sam</a> list of input bams,
1078
+ or <a href="Sam.html">Bio::DB::Sam</a> objects</p>
1079
+ </li></ul>
1080
+
1081
+
1082
+
1083
+
1084
+ <div class="method-source-code" id="merge-source">
1085
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 350</span>
1086
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">merge</span>(<span class="ruby-identifier">opts</span>={})
1087
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:one</span>]
1088
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;1&#39;</span>] = <span class="ruby-keyword">nil</span>
1089
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:one</span>)
1090
+ <span class="ruby-keyword">end</span>
1091
+
1092
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:at</span>]
1093
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;@&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:at</span>]
1094
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:at</span>)
1095
+ <span class="ruby-keyword">end</span>
1096
+
1097
+ <span class="ruby-identifier">out</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:out</span>]
1098
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:out</span>)
1099
+
1100
+ <span class="ruby-identifier">bam_list</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:bams</span>].<span class="ruby-identifier">collect</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">b</span><span class="ruby-operator">|</span>
1101
+ <span class="ruby-identifier">b</span>.<span class="ruby-identifier">bam</span> <span class="ruby-keyword">rescue</span> <span class="ruby-identifier">b</span>
1102
+ <span class="ruby-keyword">end</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">&#39; &#39;</span>)
1103
+
1104
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:bams</span>)
1105
+ <span class="ruby-identifier">options</span> = <span class="ruby-identifier">commandify</span>(<span class="ruby-identifier">opts</span>, [<span class="ruby-value">:n</span>, <span class="ruby-value">:r</span>, <span class="ruby-value">:u</span>, <span class="ruby-value">:f</span>, <span class="ruby-string">&#39;1&#39;</span>] )
1106
+ <span class="ruby-comment">#command = &quot;#{form_opt_string(@samtools, &quot;merge&quot;, opts, [:n, :r, :u, :f, &#39;1&#39;] )} #{out} #{bam_list}&quot;</span>
1107
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} merge #{options} #{out} #{bam_list}&quot;</span>
1108
+
1109
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1110
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">command</span>
1111
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1112
+
1113
+ <span class="ruby-keyword">end</span></pre>
1114
+ </div>
1115
+
1116
+ </div>
1117
+
1118
+
1119
+
1120
+
1121
+ </div>
1122
+
1123
+
1124
+ <div id="method-i-mpileup" class="method-detail ">
1125
+
1126
+ <div class="method-heading">
1127
+ <span class="method-name">mpileup</span><span
1128
+ class="method-args">(opts={}, &block)</span>
1129
+
1130
+ <span class="method-click-advice">click to toggle source</span>
1131
+
1132
+ </div>
1133
+
1134
+
1135
+ <div class="method-description">
1136
+
1137
+ <p>returns a <a href="Pileup.html">Bio::DB::Pileup</a> or Bio::DB::VCF object</p>
1138
+ <ul><li>
1139
+ <p>region - Only generate pileup in region [chrom:start-stop]</p>
1140
+ </li><li>
1141
+ <p>illumina_quals - Assume the quality is in the Illumina 1.3+ encoding</p>
1142
+ </li><li>
1143
+ <p>count_anomalous - Do not skip anomalous read pairs in variant calling</p>
1144
+ </li><li>
1145
+ <p>no_baq - Disable probabilistic realignment for the computation of base
1146
+ alignment quality (BAQ). BAQ is the Phred-scaled probability of a read base
1147
+ being misaligned. Applying this option greatly helps to reduce false SNPs
1148
+ caused by misalignments.</p>
1149
+ </li><li>
1150
+ <p>adjust_mapq - [INT] Coefficient for downgrading mapping quality for reads
1151
+ containing excessive mismatches. Given a read with a phred-scaled
1152
+ probability q of being generated from the mapped position, the new mapping
1153
+ quality is about sqrt((INT-q)/INT)*INT. A zero value disables this
1154
+ functionality; if enabled, the recommended value for BWA is 50. [0]</p>
1155
+ </li><li>
1156
+ <p>max_per_bam_depth - [INT] At a position, read maximally INT reads per input
1157
+ BAM. [250]</p>
1158
+ </li><li>
1159
+ <p>extended_baq - Extended BAQ computation. This option helps sensitivity
1160
+ especially for MNPs, but may hurt specificity a little bit.</p>
1161
+ </li><li>
1162
+ <p>exclude_reads_file - [FILE] exclude read groups listed in FILE [null]</p>
1163
+ </li><li>
1164
+ <p>list_of_positions - [FILE] BED or position list file containing a list of
1165
+ regions or sites where pileup or BCF should be generated [null]</p>
1166
+ </li><li>
1167
+ <p>mapping_quality_cap - [INT] cap mapping quality at INT [60]</p>
1168
+ </li><li>
1169
+ <p>ignore_rg - ignore read group tags</p>
1170
+ </li><li>
1171
+ <p>min_mapping_quality - [INT] skip alignments with mapQ smaller than INT [0]</p>
1172
+ </li><li>
1173
+ <p>min_base_quality - [INT] skip bases with baseQ/BAQ smaller than INT [13]</p>
1174
+ </li><li>
1175
+ <p>##following options are for the -g -u option</p>
1176
+ </li><li>
1177
+ <p>genotype_calling - generate BCF output (genotype likelihoods)</p>
1178
+ </li><li>
1179
+ <p>uncompressed_bcf - generate uncompress BCF output</p>
1180
+ </li><li>
1181
+ <p>extension_sequencing_probability - [INT] Phred-scaled gap extension seq
1182
+ error probability [20]</p>
1183
+ </li><li>
1184
+ <p>homopolymer_error_coefficient - [INT] coefficient for homopolymer errors
1185
+ [100]</p>
1186
+ </li><li>
1187
+ <p>no_indels - do not perform indel calling</p>
1188
+ </li><li>
1189
+ <p>skip_indel_over_average_depth - [INT] max per-sample depth for INDEL
1190
+ calling [250]</p>
1191
+ </li><li>
1192
+ <p>gap_open_sequencing_error_probability - [INT] Phred-scaled gap open
1193
+ sequencing error probability [40]</p>
1194
+ </li><li>
1195
+ <p>platforms - [STRING] comma separated list of platforms for indels [all]</p>
1196
+ </li></ul>
1197
+
1198
+
1199
+
1200
+
1201
+ <div class="method-source-code" id="mpileup-source">
1202
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 195</span>
1203
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">mpileup</span>(<span class="ruby-identifier">opts</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
1204
+ <span class="ruby-comment">#long option form to short samtools form..</span>
1205
+ <span class="ruby-identifier">long_opts</span> = {
1206
+ <span class="ruby-value">:region</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:r</span>,
1207
+ <span class="ruby-value">:illumina_quals</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:six</span>,
1208
+ <span class="ruby-value">:count_anomalous</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:A</span>,
1209
+ <span class="ruby-value">:no_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:B</span>,
1210
+ <span class="ruby-value">:adjust_mapq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:C</span>,
1211
+ <span class="ruby-value">:max_per_bam_depth</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:d</span>,
1212
+ <span class="ruby-value">:extended_baq</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:E</span>,
1213
+ <span class="ruby-value">:exclude_reads_file</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:G</span>,
1214
+ <span class="ruby-value">:list_of_positions</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:l</span>,
1215
+ <span class="ruby-value">:mapping_quality_cap</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:M</span>,
1216
+ <span class="ruby-value">:ignore_rg</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:R</span>,
1217
+ <span class="ruby-value">:min_mapping_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:q</span>,
1218
+ <span class="ruby-value">:min_base_quality</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:Q</span>,
1219
+ <span class="ruby-comment">###following options are for the -g -u option</span>
1220
+ <span class="ruby-value">:genotype_calling</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:g</span>,
1221
+ <span class="ruby-value">:uncompressed_bcf</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:u</span>,
1222
+ <span class="ruby-value">:extension_sequencing_probability</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:e</span>,
1223
+ <span class="ruby-value">:homopolymer_error_coefficient</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:h</span>,
1224
+ <span class="ruby-value">:no_indels</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:I</span>,
1225
+ <span class="ruby-value">:skip_indel_over_average_depth</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:L</span>,
1226
+ <span class="ruby-value">:gap_open_sequencing_error_probability</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:o</span>,
1227
+ <span class="ruby-value">:platforms</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:P</span>
1228
+ }
1229
+
1230
+ <span class="ruby-comment">##convert any long_opts to short opts </span>
1231
+ <span class="ruby-identifier">temp_opts</span> = <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">dup</span>
1232
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">each_pair</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>,<span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
1233
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]
1234
+ <span class="ruby-identifier">temp_opts</span>[<span class="ruby-identifier">long_opts</span>[<span class="ruby-identifier">k</span>]] = <span class="ruby-identifier">v</span>
1235
+ <span class="ruby-identifier">temp_opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">k</span>)
1236
+ <span class="ruby-keyword">end</span>
1237
+ <span class="ruby-keyword">end</span>
1238
+ <span class="ruby-identifier">opts</span> = <span class="ruby-identifier">temp_opts</span>
1239
+ <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>] = <span class="ruby-keyword">true</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:g</span>] <span class="ruby-comment">#so that we always get uncompressed output</span>
1240
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:g</span>)
1241
+
1242
+ <span class="ruby-identifier">opts</span>[<span class="ruby-value">:f</span>] = <span class="ruby-ivar">@fasta</span>
1243
+
1244
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:six</span>]
1245
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&quot;6&quot;</span>] = <span class="ruby-keyword">nil</span>
1246
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:six</span>)
1247
+ <span class="ruby-keyword">end</span>
1248
+
1249
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&quot;mpileup&quot;</span>, <span class="ruby-identifier">opts</span>, [<span class="ruby-value">:R</span>, <span class="ruby-value">:B</span>, <span class="ruby-value">:E</span>, <span class="ruby-string">&quot;6&quot;</span>, <span class="ruby-value">:A</span>, <span class="ruby-value">:g</span>, <span class="ruby-value">:u</span>, <span class="ruby-value">:I</span>] )
1250
+
1251
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>]
1252
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">command</span> <span class="ruby-operator">+</span> <span class="ruby-node">&quot; | #{@bcftools} view -cg -&quot;</span>
1253
+ <span class="ruby-keyword">end</span>
1254
+
1255
+ <span class="ruby-identifier">klass</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>] <span class="ruby-operator">?</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Vcf</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Pileup</span>
1256
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1257
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-value">:text</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
1258
+
1259
+ <span class="ruby-keyword">end</span></pre>
1260
+ </div>
1261
+
1262
+ </div>
1263
+
1264
+
1265
+
1266
+
1267
+ </div>
1145
1268
 
1146
1269
 
1147
1270
  <div id="method-i-open" class="method-detail ">
@@ -1149,129 +1272,582 @@ and supports returning of pileup vcf</p>
1149
1272
  <div class="method-heading">
1150
1273
  <span class="method-name">open</span><span
1151
1274
  class="method-args">()</span>
1275
+
1152
1276
  <span class="method-click-advice">click to toggle source</span>
1277
+
1153
1278
  </div>
1154
1279
 
1155
1280
 
1156
1281
  <div class="method-description">
1157
1282
 
1158
- <p>Function that actually opens the sam file Throws a <a
1159
- href="SAMException.html">SAMException</a> if the file can’t be open.</p>
1283
+ <p>backward compatibility method, returns true if file exists otherwise,
1284
+ complains and quits.</p>
1285
+
1160
1286
 
1161
1287
 
1162
1288
 
1163
1289
  <div class="method-source-code" id="open-source">
1164
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 60</span>
1165
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">open</span>()
1166
-
1167
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Writing not supported yet&quot;</span> <span class="ruby-keyword">if</span> <span class="ruby-ivar">@write</span>
1168
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;No SAM file specified&quot;</span> <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@sam</span>
1169
-
1170
- <span class="ruby-identifier">opts</span> = <span class="ruby-ivar">@write</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;w&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;r&quot;</span>
1171
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@binary</span> <span class="ruby-keyword">then</span>
1172
- <span class="ruby-identifier">opts</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot;b&quot;</span>
1173
- <span class="ruby-keyword">if</span> <span class="ruby-ivar">@write</span> <span class="ruby-keyword">then</span>
1174
- <span class="ruby-keyword">unless</span> <span class="ruby-ivar">@compressed</span> <span class="ruby-keyword">then</span>
1175
- <span class="ruby-identifier">opts</span> <span class="ruby-operator">+=</span> <span class="ruby-string">&quot;u&quot;</span>
1176
- <span class="ruby-keyword">end</span>
1177
- <span class="ruby-keyword">end</span>
1290
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 29</span>
1291
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">open</span>
1292
+ <span class="ruby-identifier">files_ok?</span>
1293
+ <span class="ruby-keyword">end</span></pre>
1294
+ </div>
1295
+
1296
+ </div>
1297
+
1298
+
1299
+
1300
+
1301
+ </div>
1302
+
1303
+
1304
+ <div id="method-i-phase" class="method-detail ">
1305
+
1306
+ <div class="method-heading">
1307
+ <span class="method-name">phase</span><span
1308
+ class="method-args">(opts={})</span>
1309
+
1310
+ <span class="method-click-advice">click to toggle source</span>
1311
+
1312
+ </div>
1313
+
1314
+
1315
+ <div class="method-description">
1316
+
1317
+ <p>Call and phase heterozygous SNPs</p>
1318
+ <ul><li>
1319
+ <p>A - Drop reads with ambiguous phase.</p>
1320
+ </li><li>
1321
+ <p>b - [STR] Prefix of BAM output. When this option is in use, phase-0 reads
1322
+ will be saved in file STR.0.bam and phase-1 reads in STR.1.bam. Phase
1323
+ unknown reads will be randomly allocated to one of the two files. Chimeric
1324
+ reads with switch errors will be saved in STR.chimeric.bam. [null]</p>
1325
+ </li><li>
1326
+ <p>F - Do not attempt to fix chimeric reads.</p>
1327
+ </li><li>
1328
+ <p>k - [INT] Maximum length for local phasing. [13]</p>
1329
+ </li><li>
1330
+ <p>q - [INT] Minimum Phred-scaled LOD to call a heterozygote. [40]</p>
1331
+ </li><li>
1332
+ <p>Q - [INT] Minimum base quality to be used in het calling. [13]</p>
1333
+ </li></ul>
1334
+
1335
+
1336
+
1337
+
1338
+ <div class="method-source-code" id="phase-source">
1339
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 525</span>
1340
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">phase</span>(<span class="ruby-identifier">opts</span>={})
1341
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{form_opt_string(@samtools, &quot;phase&quot;, opts, [:A, :F] )}&quot;</span>
1342
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1343
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1344
+ <span class="ruby-keyword">end</span></pre>
1345
+ </div>
1346
+
1347
+ </div>
1348
+
1349
+
1350
+
1351
+
1352
+ </div>
1353
+
1354
+
1355
+ <div id="method-i-plot_chromosome_coverage" class="method-detail ">
1356
+
1357
+ <div class="method-heading">
1358
+ <span class="method-name">plot_chromosome_coverage</span><span
1359
+ class="method-args">(chr,start,length, opts={})</span>
1360
+
1361
+ <span class="method-click-advice">click to toggle source</span>
1362
+
1363
+ </div>
1364
+
1365
+
1366
+ <div class="method-description">
1367
+
1368
+ <p>returns an array of coverage for each location for which there are mapped
1369
+ reads</p>
1370
+ <ul><li>
1371
+ <p>chr - the reference name</p>
1372
+ </li><li>
1373
+ <p>start - the start position</p>
1374
+ </li><li>
1375
+ <p>length - the length of the region queried</p>
1376
+ </li></ul>
1377
+
1378
+ <p>OPTIONS</p>
1379
+ <ul><li>
1380
+ <p>bin - the amount of bins to split the histogram into. A mean score for each
1381
+ bin will be plotted. [default 30 bins]</p>
1382
+ </li><li>
1383
+ <p>svg - a file to write the svg image to [default a String object containing
1384
+ the SVG]</p>
1385
+ </li></ul>
1386
+
1387
+
1388
+
1389
+
1390
+ <div class="method-source-code" id="plot_chromosome_coverage-source">
1391
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 119</span>
1392
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">plot_chromosome_coverage</span>(<span class="ruby-identifier">chr</span>,<span class="ruby-identifier">start</span>,<span class="ruby-identifier">length</span>, <span class="ruby-identifier">opts</span>={})
1393
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:bin</span>]
1394
+ <span class="ruby-identifier">bin</span> = <span class="ruby-identifier">length</span><span class="ruby-operator">/</span><span class="ruby-identifier">opts</span>[<span class="ruby-value">:bin</span>]
1395
+ <span class="ruby-keyword">else</span>
1396
+ <span class="ruby-identifier">bin</span> = <span class="ruby-identifier">length</span><span class="ruby-operator">/</span><span class="ruby-value">30</span>
1178
1397
  <span class="ruby-keyword">end</span>
1179
- <span class="ruby-identifier">valid</span> = [<span class="ruby-string">&quot;r&quot;</span>, <span class="ruby-string">&quot;w&quot;</span>, <span class="ruby-string">&quot;wh&quot;</span>, <span class="ruby-string">&quot;rb&quot;</span>, <span class="ruby-string">&quot;wb&quot;</span> , <span class="ruby-string">&quot;wbu&quot;</span>]
1180
- <span class="ruby-keyword">unless</span> <span class="ruby-identifier">valid</span>.<span class="ruby-identifier">include?</span>(<span class="ruby-identifier">opts</span>) <span class="ruby-keyword">then</span>
1181
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;Invalid options for samopen: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">opts</span>
1398
+ <span class="ruby-identifier">result</span> = []
1399
+ <span class="ruby-identifier">region</span> = <span class="ruby-node">&quot;#{chr}:#{start}-#{start + length}&quot;</span>
1400
+ <span class="ruby-keyword">self</span>.<span class="ruby-identifier">mpileup</span>(<span class="ruby-value">:r</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">region</span>) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span>
1401
+ <span class="ruby-identifier">result</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">coverage</span>
1182
1402
  <span class="ruby-keyword">end</span>
1403
+ <span class="ruby-identifier">p</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">Page</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1000</span>,
1404
+ <span class="ruby-value">:height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">200</span>,
1405
+ <span class="ruby-value">:number_of_intervals</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">10</span>,
1406
+ <span class="ruby-value">:font_size</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">14</span>
1407
+ )
1408
+ <span class="ruby-identifier">data_track</span> = <span class="ruby-identifier">p</span>.<span class="ruby-identifier">add_track</span>(<span class="ruby-value">:glyph</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">:histogram</span>,
1409
+ <span class="ruby-value">:stroke_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;black&#39;</span>,
1410
+ <span class="ruby-value">:fill_color</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;gold&#39;</span>,
1411
+ <span class="ruby-value">:track_height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">150</span>,
1412
+ <span class="ruby-value">:name</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;read coverage&#39;</span>,
1413
+ <span class="ruby-value">:label</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword">true</span>,
1414
+ <span class="ruby-value">:stroke_width</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&#39;1&#39;</span>,
1415
+ <span class="ruby-value">:x_round</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span>,
1416
+ <span class="ruby-value">:y_round</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value">1</span> )
1417
+ <span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>;
1418
+ <span class="ruby-identifier">result</span>.<span class="ruby-identifier">each_slice</span>(<span class="ruby-identifier">bin</span>) {<span class="ruby-operator">|</span><span class="ruby-identifier">slice</span><span class="ruby-operator">|</span>
1419
+ <span class="ruby-comment">#result.each_with_index {|val, index|</span>
1420
+ <span class="ruby-identifier">data_feature</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">Graphics</span><span class="ruby-operator">::</span><span class="ruby-constant">MiniFeature</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:start</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">start</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">index</span>,
1421
+ <span class="ruby-value">:end</span> =<span class="ruby-operator">&gt;</span> (<span class="ruby-identifier">start</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">bin</span>),
1422
+ <span class="ruby-value">:segment_height</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">slice</span>.<span class="ruby-identifier">inject</span>{<span class="ruby-operator">|</span><span class="ruby-identifier">sum</span>,<span class="ruby-identifier">x</span><span class="ruby-operator">|</span> <span class="ruby-identifier">sum</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">x</span> }.<span class="ruby-identifier">to_f</span> <span class="ruby-operator">/</span> <span class="ruby-identifier">slice</span>.<span class="ruby-identifier">size</span>)
1423
+ <span class="ruby-identifier">data_track</span>.<span class="ruby-identifier">add</span>(<span class="ruby-identifier">data_feature</span>)
1424
+ <span class="ruby-identifier">index</span><span class="ruby-operator">+=</span><span class="ruby-identifier">bin</span>
1425
+ }
1426
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:svg</span>]
1427
+ <span class="ruby-identifier">svg</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:svg</span>].<span class="ruby-identifier">to_s</span>
1428
+ <span class="ruby-identifier">p</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">svg</span>)
1429
+ <span class="ruby-keyword">else</span>
1430
+ <span class="ruby-keyword">return</span> <span class="ruby-identifier">p</span>.<span class="ruby-identifier">get_markup</span>
1431
+ <span class="ruby-keyword">end</span>
1432
+
1433
+
1434
+ <span class="ruby-keyword">end</span></pre>
1435
+ </div>
1436
+
1437
+ </div>
1438
+
1439
+
1440
+
1441
+
1442
+ </div>
1443
+
1444
+
1445
+ <div id="method-i-reheader" class="method-detail ">
1446
+
1447
+ <div class="method-heading">
1448
+ <span class="method-name">reheader</span><span
1449
+ class="method-args">(header_sam, opts={})</span>
1450
+
1451
+ <span class="method-click-advice">click to toggle source</span>
1452
+
1453
+ </div>
1454
+
1183
1455
 
1184
- <span class="ruby-identifier">samFile</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span>.<span class="ruby-identifier">samopen</span>(<span class="ruby-ivar">@sam</span>, <span class="ruby-identifier">opts</span>, <span class="ruby-keyword">nil</span>)
1185
- <span class="ruby-keyword">if</span> <span class="ruby-identifier">samFile</span>.<span class="ruby-identifier">null?</span> <span class="ruby-keyword">then</span>
1186
- <span class="ruby-ivar">@sam_file</span> = <span class="ruby-keyword">nil</span>
1187
- <span class="ruby-identifier">raise</span> <span class="ruby-constant">SAMException</span>.<span class="ruby-identifier">new</span>(), <span class="ruby-string">&quot;File not opened: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@sam</span>
1456
+ <div class="method-description">
1457
+
1458
+ <p>Replace the header of the current bam file with the header in header_sam</p>
1459
+ <ul><li>
1460
+ <p>header_sam - the sam file from which the new header will be taken</p>
1461
+ </li><li>
1462
+ <p>out - [FILE] output bam file</p>
1463
+ </li></ul>
1464
+
1465
+
1466
+
1467
+
1468
+ <div class="method-source-code" id="reheader-source">
1469
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 471</span>
1470
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">reheader</span>(<span class="ruby-identifier">header_sam</span>, <span class="ruby-identifier">opts</span>={})
1471
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:out</span>)
1472
+ <span class="ruby-identifier">out</span>=<span class="ruby-identifier">opts</span>[<span class="ruby-value">:out</span>]
1473
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} reheader #{header_sam} #{@bam} &gt; #{out}&quot;</span>
1474
+ <span class="ruby-keyword">else</span>
1475
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{@samtools} reheader #{header_sam} #{@bam}&quot;</span>
1188
1476
  <span class="ruby-keyword">end</span>
1189
- <span class="ruby-ivar">@sam_file</span> = <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">SAM</span><span class="ruby-operator">::</span><span class="ruby-constant">Tools</span><span class="ruby-operator">::</span><span class="ruby-constant">SamfileT</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">samFile</span>)
1477
+ <span class="ruby-identifier">puts</span> <span class="ruby-identifier">command</span>
1478
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1479
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1480
+ <span class="ruby-keyword">end</span></pre>
1481
+ </div>
1482
+
1483
+ </div>
1190
1484
 
1485
+
1486
+
1487
+
1488
+ </div>
1489
+
1490
+
1491
+ <div id="method-i-remove_duplicates" class="method-detail ">
1492
+
1493
+ <div class="method-heading">
1494
+ <span class="method-name">remove_duplicates</span><span
1495
+ class="method-args">(opts={})</span>
1496
+
1497
+ <span class="method-click-advice">click to toggle source</span>
1498
+
1499
+ </div>
1500
+
1501
+
1502
+ <div class="method-description">
1503
+
1504
+ <p>Remove potential PCR duplicates: if multiple read pairs have identical
1505
+ external coordinates, only retain the pair with highest mapping quality.</p>
1506
+ <ul><li>
1507
+ <p>s - rmdup for SE reads</p>
1508
+ </li><li>
1509
+ <p>S - treat PE reads as SE in rmdup (force -s)</p>
1510
+ </li><li>
1511
+ <p>out - [FILE] output bam</p>
1512
+ </li></ul>
1513
+
1514
+
1515
+
1516
+
1517
+ <div class="method-source-code" id="remove_duplicates-source">
1518
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 411</span>
1519
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">remove_duplicates</span>(<span class="ruby-identifier">opts</span>={})
1520
+ <span class="ruby-identifier">out</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:out</span>]
1521
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:out</span>)
1522
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{form_opt_string(@samtools, &quot;rmdup&quot;, opts, [:s, :S])} #{out} #{@bam}&quot;</span>
1523
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1524
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1191
1525
  <span class="ruby-keyword">end</span></pre>
1192
- </div><!-- open-source -->
1526
+ </div>
1193
1527
 
1194
1528
  </div>
1195
1529
 
1196
1530
 
1531
+ <div class="aliases">
1532
+ Also aliased as: <a href="Sam.html#method-i-rmdup">rmdup</a>
1533
+ </div>
1534
+
1197
1535
 
1198
1536
 
1199
- </div><!-- open-method -->
1537
+ </div>
1200
1538
 
1201
1539
 
1202
- <div id="method-i-query_string" class="method-detail ">
1540
+ <div id="method-i-rmdup" class="method-detail method-alias">
1203
1541
 
1204
1542
  <div class="method-heading">
1205
- <span class="method-name">query_string</span><span
1206
- class="method-args">(chromosome, qstart,qend)</span>
1543
+ <span class="method-name">rmdup</span><span
1544
+ class="method-args">(opts={})</span>
1545
+
1546
+ </div>
1547
+
1548
+
1549
+ <div class="method-description">
1550
+
1551
+
1552
+
1553
+
1554
+
1555
+
1556
+ </div>
1557
+
1558
+
1559
+
1560
+
1561
+ <div class="aliases">
1562
+ Alias for: <a href="Sam.html#method-i-remove_duplicates">remove_duplicates</a>
1563
+ </div>
1564
+
1565
+ </div>
1566
+
1567
+
1568
+ <div id="method-i-sort" class="method-detail ">
1569
+
1570
+ <div class="method-heading">
1571
+ <span class="method-name">sort</span><span
1572
+ class="method-args">(opts={})</span>
1573
+
1207
1574
  <span class="method-click-advice">click to toggle source</span>
1575
+
1208
1576
  </div>
1209
1577
 
1210
1578
 
1211
1579
  <div class="method-description">
1212
1580
 
1213
- <p>Generates a query sting to be used by the region parser in samtools. In
1214
- principle, you shouldn’t need to use this function.</p>
1581
+ <p>Sort alignments by leftmost coordinates</p>
1582
+ <ul><li>
1583
+ <p>n - sort by read name</p>
1584
+ </li><li>
1585
+ <p>f - use &lt;out.prefix&gt; as full file name instead of prefix</p>
1586
+ </li><li>
1587
+ <p>o - final output to stdout returns bio::db::alignment</p>
1588
+ </li><li>
1589
+ <p>l - [INT] compression level, from 0 to 9 [-1]</p>
1590
+ </li><li>
1591
+ <p>at - [INT] number of sorting and compression threads [1]</p>
1592
+ </li><li>
1593
+ <p>m - [INT] max memory per thread; suffix K/M/G recognized [768M]</p>
1594
+ </li><li>
1595
+ <p>prefix - [STRING] prefix for output bamfile</p>
1596
+ </li></ul>
1597
+
1598
+
1599
+
1600
+
1601
+ <div class="method-source-code" id="sort-source">
1602
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 429</span>
1603
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">sort</span>(<span class="ruby-identifier">opts</span>={})
1604
+ <span class="ruby-keyword">if</span> <span class="ruby-operator">!</span><span class="ruby-identifier">opts</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-value">:prefix</span>)
1605
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">merge!</span>({<span class="ruby-value">:prefix</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-string">&quot;sorted&quot;</span>})
1606
+ <span class="ruby-keyword">end</span>
1607
+ <span class="ruby-identifier">prefix</span> = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:prefix</span>]
1608
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:prefix</span>)
1609
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&quot;sort&quot;</span>, <span class="ruby-identifier">opts</span>, [<span class="ruby-value">:n</span>, <span class="ruby-value">:f</span>, <span class="ruby-value">:o</span>])
1610
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">command</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">prefix</span>
1611
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1612
+ <span class="ruby-comment">#puts command</span>
1613
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:o</span>]
1614
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Alignment</span>)
1615
+ <span class="ruby-keyword">else</span>
1616
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1617
+ <span class="ruby-keyword">end</span>
1618
+ <span class="ruby-keyword">end</span></pre>
1619
+ </div>
1215
1620
 
1621
+ </div>
1216
1622
 
1623
+
1624
+
1625
+
1626
+ </div>
1627
+
1628
+
1629
+ <div id="method-i-targetcut" class="method-detail ">
1630
+
1631
+ <div class="method-heading">
1632
+ <span class="method-name">targetcut</span><span
1633
+ class="method-args">(opts={})</span>
1634
+
1635
+ <span class="method-click-advice">click to toggle source</span>
1217
1636
 
1218
- <div class="method-source-code" id="query_string-source">
1219
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 205</span>
1220
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">query_string</span>(<span class="ruby-identifier">chromosome</span>, <span class="ruby-identifier">qstart</span>,<span class="ruby-identifier">qend</span>)
1221
- <span class="ruby-identifier">query</span> = <span class="ruby-identifier">chromosome</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;:&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">qstart</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot;-&quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">qend</span>.<span class="ruby-identifier">to_s</span>
1222
- <span class="ruby-identifier">query</span>
1637
+ </div>
1638
+
1639
+
1640
+ <div class="method-description">
1641
+
1642
+ <p>Identifies target regions by examining the continuity of read depth,
1643
+ computes haploid consensus sequences of targets and outputs a SAM with each
1644
+ sequence corresponding to a target. When option -f is in use, BAQ will be
1645
+ applied.</p>
1646
+ <ul><li>
1647
+ <p>Q - [INT] Minimum base quality for a base to be considered [13]</p>
1648
+ </li><li>
1649
+ <p>i - in penalty</p>
1650
+ </li><li>
1651
+ <p>0 - em0</p>
1652
+ </li><li>
1653
+ <p>1 - em1</p>
1654
+ </li><li>
1655
+ <p>2 - em2</p>
1656
+ </li><li>
1657
+ <p>f - reference</p>
1658
+ </li></ul>
1659
+
1660
+
1661
+
1662
+
1663
+ <div class="method-source-code" id="targetcut-source">
1664
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 507</span>
1665
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">targetcut</span>(<span class="ruby-identifier">opts</span>={})
1666
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:f</span>]
1667
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;f&#39;</span>] = <span class="ruby-ivar">@fasta</span>
1668
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:s</span>)
1669
+ <span class="ruby-keyword">end</span>
1670
+
1671
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{form_opt_string(@samtools, &quot;targetcut&quot;, opts, [] )}&quot;</span>
1672
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1673
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1223
1674
  <span class="ruby-keyword">end</span></pre>
1224
- </div><!-- query_string-source -->
1675
+ </div>
1225
1676
 
1226
1677
  </div>
1227
1678
 
1228
1679
 
1229
1680
 
1230
1681
 
1231
- </div><!-- query_string-method -->
1682
+ </div>
1232
1683
 
1233
1684
 
1234
- <div id="method-i-to_s" class="method-detail ">
1685
+ <div id="method-i-tview" class="method-detail ">
1235
1686
 
1236
1687
  <div class="method-heading">
1237
- <span class="method-name">to_s</span><span
1238
- class="method-args">()</span>
1688
+ <span class="method-name">tview</span><span
1689
+ class="method-args">(opts={})</span>
1690
+
1239
1691
  <span class="method-click-advice">click to toggle source</span>
1692
+
1240
1693
  </div>
1241
1694
 
1242
1695
 
1243
1696
  <div class="method-description">
1244
1697
 
1245
- <p>Prints a description of the sam file in a text format containg if it is
1246
- binary or text, the path and the fasta file of the reference</p>
1698
+ <p>used to generate a text alignment viewer</p>
1699
+ <ul><li>
1700
+ <p>d - display, output as (H)tml or (C)urses or (T)ext</p>
1701
+ </li><li>
1702
+ <p>p - [chr:pos] go directly to this position</p>
1703
+ </li><li>
1704
+ <p>s - [STR] display only reads from this sample or group</p>
1705
+ </li></ul>
1706
+
1247
1707
 
1248
1708
 
1249
1709
 
1250
- <div class="method-source-code" id="to_s-source">
1251
- <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 90</span>
1252
- <span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>()
1253
- (<span class="ruby-ivar">@binary</span> <span class="ruby-operator">?</span> <span class="ruby-string">&quot;Binary&quot;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&quot;Text&quot;</span>) <span class="ruby-operator">+</span> <span class="ruby-string">&quot; file: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@sam</span> <span class="ruby-operator">+</span> <span class="ruby-string">&quot; with fasta: &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-ivar">@fasta_path</span>
1710
+ <div class="method-source-code" id="tview-source">
1711
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 450</span>
1712
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">tview</span>(<span class="ruby-identifier">opts</span>={})
1713
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:d</span>]
1714
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;d&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:d</span>]
1715
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:d</span>)
1716
+ <span class="ruby-keyword">end</span>
1717
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:p</span>]
1718
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;p&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:p</span>]
1719
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:p</span>)
1720
+ <span class="ruby-keyword">end</span>
1721
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:s</span>]
1722
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;s&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:s</span>]
1723
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:s</span>)
1724
+ <span class="ruby-keyword">end</span>
1725
+ <span class="ruby-identifier">command</span> = <span class="ruby-node">&quot;#{form_opt_string(@samtools, &quot;tview&quot;, opts)}&quot;</span>
1726
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1727
+ <span class="ruby-identifier">system</span>(<span class="ruby-identifier">command</span>)
1254
1728
  <span class="ruby-keyword">end</span></pre>
1255
- </div><!-- to_s-source -->
1729
+ </div>
1256
1730
 
1257
1731
  </div>
1258
1732
 
1259
1733
 
1260
1734
 
1261
1735
 
1262
- </div><!-- to_s-method -->
1736
+ </div>
1263
1737
 
1264
1738
 
1265
- </section><!-- public-instance-method-details -->
1739
+ <div id="method-i-view" class="method-detail ">
1740
+
1741
+ <div class="method-heading">
1742
+ <span class="method-name">view</span><span
1743
+ class="method-args">(opts={},&block)</span>
1744
+
1745
+ <span class="method-click-advice">click to toggle source</span>
1746
+
1747
+ </div>
1748
+
1749
+
1750
+ <div class="method-description">
1751
+
1752
+ <p>runs the samtools view command</p>
1753
+ <ul><li>
1754
+ <p>b - output BAM</p>
1755
+ </li><li>
1756
+ <p>h - print header for the SAM output</p>
1757
+ </li><li>
1758
+ <p>H - print header only (no alignments)</p>
1759
+ </li><li>
1760
+ <p>S - input is SAM</p>
1761
+ </li><li>
1762
+ <p>u - uncompressed BAM output (force -b)</p>
1763
+ </li><li>
1764
+ <p>one - fast compression (force -b)</p>
1765
+ </li><li>
1766
+ <p>x - output FLAG in HEX (samtools-C specific)</p>
1767
+ </li><li>
1768
+ <p>X - output FLAG in string (samtools-C specific)</p>
1769
+ </li><li>
1770
+ <p>c - print only the count of matching records</p>
1771
+ </li><li>
1772
+ <p>B - collapse the backward CIGAR operation</p>
1773
+ </li><li>
1774
+ <p>at - INT number of BAM compression threads [0]</p>
1775
+ </li><li>
1776
+ <p>L - FILE output alignments overlapping the input BED FILE [null]</p>
1777
+ </li><li>
1778
+ <p>t - FILE list of reference names and lengths (force -S) [null]</p>
1779
+ </li><li>
1780
+ <p>T - FILE reference sequence file (force -S) [null]</p>
1781
+ </li><li>
1782
+ <p>o - FILE output file name [stdout]</p>
1783
+ </li><li>
1784
+ <p>R - FILE list of read groups to be outputted [null]</p>
1785
+ </li><li>
1786
+ <p>f - INT required flag 0 for unset [0]</p>
1787
+ </li><li>
1788
+ <p>F - INT filtering flag 0 for unset [0]</p>
1789
+ </li><li>
1790
+ <p>q - INT minimum mapping quality [0]</p>
1791
+ </li><li>
1792
+ <p>l - STR only output reads in library STR [null]</p>
1793
+ </li><li>
1794
+ <p>r - STR only output reads in read group STR [null]</p>
1795
+ </li><li>
1796
+ <p>s - FLOAT fraction of templates to subsample; integer part as seed [-1]</p>
1797
+ </li><li>
1798
+ <p>chr - name of reference sequence to get alignments from</p>
1799
+ </li><li>
1800
+ <p>start - start position on reference sequence</p>
1801
+ </li><li>
1802
+ <p>stop - end postion on reference sequence</p>
1803
+ </li></ul>
1804
+
1805
+
1806
+
1807
+
1808
+ <div class="method-source-code" id="view-source">
1809
+ <pre><span class="ruby-comment"># File lib/bio/db/sam.rb, line 59</span>
1810
+ <span class="ruby-keyword">def</span> <span class="ruby-identifier">view</span>(<span class="ruby-identifier">opts</span>={},<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
1811
+ <span class="ruby-identifier">region</span> = <span class="ruby-constant">String</span>.<span class="ruby-identifier">new</span>
1812
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:chr</span>] <span class="ruby-keyword">and</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:start</span>] <span class="ruby-keyword">and</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:stop</span>]
1813
+ <span class="ruby-identifier">region</span> = <span class="ruby-node">&quot;#{opts[:chr]}:#{opts[:start]}-#{opts[:stop]}&quot;</span>
1814
+ [<span class="ruby-value">:chr</span>, <span class="ruby-value">:start</span>, <span class="ruby-value">:stop</span>].<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">o</span><span class="ruby-operator">|</span> <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-identifier">o</span>)}
1815
+ <span class="ruby-keyword">end</span>
1816
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:at</span>]
1817
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;@&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:at</span>]
1818
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:at</span>)
1819
+ <span class="ruby-keyword">end</span>
1266
1820
 
1267
- </section><!-- 5Buntitled-5D -->
1821
+ <span class="ruby-keyword">if</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:one</span>]
1822
+ <span class="ruby-identifier">opts</span>[<span class="ruby-string">&#39;1&#39;</span>] = <span class="ruby-identifier">opts</span>[<span class="ruby-value">:one</span>]
1823
+ <span class="ruby-identifier">opts</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value">:one</span>)
1824
+ <span class="ruby-keyword">end</span>
1825
+
1826
+ <span class="ruby-identifier">command</span> = <span class="ruby-identifier">form_opt_string</span>(<span class="ruby-ivar">@samtools</span>, <span class="ruby-string">&#39;view&#39;</span>, <span class="ruby-identifier">opts</span>, [<span class="ruby-value">:b</span>, <span class="ruby-value">:h</span>, <span class="ruby-value">:H</span>, <span class="ruby-value">:S</span>, <span class="ruby-value">:u</span>, <span class="ruby-string">&#39;1&#39;</span>, <span class="ruby-value">:x</span>, <span class="ruby-value">:X</span>, <span class="ruby-value">:c</span>, <span class="ruby-value">:B</span>]) <span class="ruby-operator">+</span> <span class="ruby-string">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">region</span>
1827
+ <span class="ruby-ivar">@last_command</span> = <span class="ruby-identifier">command</span>
1828
+ <span class="ruby-identifier">type</span> = (<span class="ruby-identifier">opts</span>[<span class="ruby-value">:u</span>] <span class="ruby-keyword">or</span> <span class="ruby-identifier">opts</span>[<span class="ruby-value">:b</span>]) <span class="ruby-operator">?</span> <span class="ruby-value">:binary</span> <span class="ruby-operator">:</span> <span class="ruby-value">:text</span>
1829
+ <span class="ruby-identifier">klass</span> = (<span class="ruby-identifier">type</span> <span class="ruby-operator">==</span> <span class="ruby-value">:binary</span>) <span class="ruby-operator">?</span> <span class="ruby-constant">String</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Bio</span><span class="ruby-operator">::</span><span class="ruby-constant">DB</span><span class="ruby-operator">::</span><span class="ruby-constant">Alignment</span>
1830
+ <span class="ruby-identifier">yield_from_pipe</span>(<span class="ruby-identifier">command</span>, <span class="ruby-identifier">klass</span>, <span class="ruby-identifier">type</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
1831
+ <span class="ruby-keyword">end</span></pre>
1832
+ </div>
1833
+
1834
+ </div>
1835
+
1836
+
1268
1837
 
1269
- </div><!-- documentation -->
1838
+
1839
+ </div>
1840
+
1841
+
1842
+ </section>
1843
+
1844
+ </section>
1845
+ </main>
1270
1846
 
1271
1847
 
1272
- <footer id="validator-badges">
1273
- <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
1274
- <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
1275
- <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
1848
+ <footer id="validator-badges" role="contentinfo">
1849
+ <p><a href="http://validator.w3.org/check/referer">Validate</a>
1850
+ <p>Generated by <a href="http://rdoc.rubyforge.org">RDoc</a> 4.1.1.
1851
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
1276
1852
  </footer>
1277
1853