bio-samtools 0.2.5 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README.rdoc +7 -20
  2. data/Rakefile +11 -0
  3. data/VERSION +1 -1
  4. data/bio-samtools.gemspec +67 -1
  5. data/doc/basic_styles.css +31 -0
  6. data/doc/classes/Bio.html +139 -0
  7. data/doc/classes/Bio/DB.html +137 -0
  8. data/doc/classes/Bio/DB/Alignment.html +441 -0
  9. data/doc/classes/Bio/DB/Alignment.src/M000012.html +19 -0
  10. data/doc/classes/Bio/DB/Alignment.src/M000013.html +27 -0
  11. data/doc/classes/Bio/DB/Alignment.src/M000014.html +45 -0
  12. data/doc/classes/Bio/DB/Alignment.src/M000015.html +40 -0
  13. data/doc/classes/Bio/DB/SAM.html +510 -0
  14. data/doc/classes/Bio/DB/SAM/Library.html +135 -0
  15. data/doc/classes/Bio/DB/SAM/Library.src/M000006.html +28 -0
  16. data/doc/classes/Bio/DB/SAM/Tools.html +278 -0
  17. data/doc/classes/Bio/DB/SAM/Tools.src/M000007.html +20 -0
  18. data/doc/classes/Bio/DB/SAM/Tools/Bam1CoreT.html +111 -0
  19. data/doc/classes/Bio/DB/SAM/Tools/Bam1T.html +150 -0
  20. data/doc/classes/Bio/DB/SAM/Tools/Bam1T.src/M000010.html +20 -0
  21. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.html +169 -0
  22. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.src/M000008.html +19 -0
  23. data/doc/classes/Bio/DB/SAM/Tools/BamHeaderT.src/M000009.html +18 -0
  24. data/doc/classes/Bio/DB/SAM/Tools/BamPileup1T.html +111 -0
  25. data/doc/classes/Bio/DB/SAM/Tools/SamfileT.html +129 -0
  26. data/doc/classes/Bio/DB/SAM/Tools/SamfileTX.html +111 -0
  27. data/doc/classes/Bio/DB/SAMException.html +140 -0
  28. data/doc/classes/Bio/DB/SAMException.src/M000016.html +18 -0
  29. data/doc/classes/Bio/DB/Sam.src/M000017.html +43 -0
  30. data/doc/classes/Bio/DB/Sam.src/M000018.html +42 -0
  31. data/doc/classes/Bio/DB/Sam.src/M000019.html +18 -0
  32. data/doc/classes/Bio/DB/Sam.src/M000020.html +22 -0
  33. data/doc/classes/Bio/DB/Sam.src/M000021.html +19 -0
  34. data/doc/classes/Bio/DB/Sam.src/M000022.html +25 -0
  35. data/doc/classes/Bio/DB/Sam.src/M000023.html +28 -0
  36. data/doc/classes/Bio/DB/Sam.src/M000024.html +28 -0
  37. data/doc/classes/Bio/DB/Sam.src/M000025.html +46 -0
  38. data/doc/classes/Bio/DB/Sam.src/M000026.html +24 -0
  39. data/doc/classes/Bio/DB/Sam.src/M000027.html +19 -0
  40. data/doc/classes/Bio/DB/Sam.src/M000028.html +24 -0
  41. data/doc/classes/Bio/DB/Sam.src/M000029.html +41 -0
  42. data/doc/classes/Bio/DB/Sam.src/M000030.html +31 -0
  43. data/doc/classes/Bio/DB/Sam.src/M000031.html +86 -0
  44. data/doc/classes/Bio/DB/Sam.src/M000032.html +34 -0
  45. data/doc/classes/Bio/DB/Tag.html +160 -0
  46. data/doc/classes/Bio/DB/Tag.src/M000011.html +21 -0
  47. data/doc/classes/LibC.html +105 -0
  48. data/doc/classes/Pileup.html +374 -0
  49. data/doc/classes/Pileup.src/M000001.html +34 -0
  50. data/doc/classes/Pileup.src/M000002.html +21 -0
  51. data/doc/classes/Pileup.src/M000003.html +21 -0
  52. data/doc/classes/Pileup.src/M000004.html +21 -0
  53. data/doc/classes/Pileup.src/M000005.html +31 -0
  54. data/doc/created.rid +1 -0
  55. data/doc/files/lib/bio-samtools_rb.html +109 -0
  56. data/doc/files/lib/bio/db/sam/bam_rb.html +108 -0
  57. data/doc/files/lib/bio/db/sam/faidx_rb.html +108 -0
  58. data/doc/files/lib/bio/db/sam/library_rb.html +101 -0
  59. data/doc/files/lib/bio/db/sam/pileup_rb.html +178 -0
  60. data/doc/files/lib/bio/db/sam/sam_rb.html +113 -0
  61. data/doc/files/lib/bio/db/sam_rb.html +111 -0
  62. data/doc/fr_class_index.html +43 -0
  63. data/doc/fr_file_index.html +33 -0
  64. data/doc/fr_method_index.html +58 -0
  65. data/doc/index.html +24 -0
  66. data/doc/rdoc-style.css +208 -0
  67. data/doc/tutorial.html +165 -0
  68. data/doc/tutorial.pdf +0 -0
  69. data/lib/bio/db/sam.rb +163 -1
  70. data/lib/bio/db/sam/pileup.rb +98 -0
  71. data/test/basictest.rb +14 -0
  72. data/test/pileup.rb +68 -0
  73. metadata +84 -18
@@ -0,0 +1,43 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Classes
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Classes</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Classes</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/Bio.html">Bio</a><br />
24
+ <a href="classes/Bio/DB.html">Bio::DB</a><br />
25
+ <a href="classes/Bio/DB/Alignment.html">Bio::DB::Alignment</a><br />
26
+ <a href="classes/Bio/DB/SAM.html">Bio::DB::SAM</a><br />
27
+ <a href="classes/Bio/DB/SAM/Library.html">Bio::DB::SAM::Library</a><br />
28
+ <a href="classes/Bio/DB/SAM/Tools.html">Bio::DB::SAM::Tools</a><br />
29
+ <a href="classes/Bio/DB/SAM/Tools/Bam1CoreT.html">Bio::DB::SAM::Tools::Bam1CoreT</a><br />
30
+ <a href="classes/Bio/DB/SAM/Tools/Bam1T.html">Bio::DB::SAM::Tools::Bam1T</a><br />
31
+ <a href="classes/Bio/DB/SAM/Tools/BamHeaderT.html">Bio::DB::SAM::Tools::BamHeaderT</a><br />
32
+ <a href="classes/Bio/DB/SAM/Tools/BamPileup1T.html">Bio::DB::SAM::Tools::BamPileup1T</a><br />
33
+ <a href="classes/Bio/DB/SAM/Tools/SamfileT.html">Bio::DB::SAM::Tools::SamfileT</a><br />
34
+ <a href="classes/Bio/DB/SAM/Tools/SamfileTX.html">Bio::DB::SAM::Tools::SamfileTX</a><br />
35
+ <a href="classes/Bio/DB/SAMException.html">Bio::DB::SAMException</a><br />
36
+ <a href="classes/Bio/DB/Sam.html">Bio::DB::Sam</a><br />
37
+ <a href="classes/Bio/DB/Tag.html">Bio::DB::Tag</a><br />
38
+ <a href="classes/LibC.html">LibC</a><br />
39
+ <a href="classes/Pileup.html">Pileup</a><br />
40
+ </div>
41
+ </div>
42
+ </body>
43
+ </html>
@@ -0,0 +1,33 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Files
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Files</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Files</h1>
22
+ <div id="index-entries">
23
+ <a href="files/lib/bio-samtools_rb.html">lib/bio-samtools.rb</a><br />
24
+ <a href="files/lib/bio/db/sam_rb.html">lib/bio/db/sam.rb</a><br />
25
+ <a href="files/lib/bio/db/sam/bam_rb.html">lib/bio/db/sam/bam.rb</a><br />
26
+ <a href="files/lib/bio/db/sam/faidx_rb.html">lib/bio/db/sam/faidx.rb</a><br />
27
+ <a href="files/lib/bio/db/sam/library_rb.html">lib/bio/db/sam/library.rb</a><br />
28
+ <a href="files/lib/bio/db/sam/pileup_rb.html">lib/bio/db/sam/pileup.rb</a><br />
29
+ <a href="files/lib/bio/db/sam/sam_rb.html">lib/bio/db/sam/sam.rb</a><br />
30
+ </div>
31
+ </div>
32
+ </body>
33
+ </html>
@@ -0,0 +1,58 @@
1
+
2
+ <?xml version="1.0" encoding="iso-8859-1"?>
3
+ <!DOCTYPE html
4
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
5
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
6
+
7
+ <!--
8
+
9
+ Methods
10
+
11
+ -->
12
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
13
+ <head>
14
+ <title>Methods</title>
15
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
16
+ <link rel="stylesheet" href="rdoc-style.css" type="text/css" />
17
+ <base target="docwin" />
18
+ </head>
19
+ <body>
20
+ <div id="index">
21
+ <h1 class="section-bar">Methods</h1>
22
+ <div id="index-entries">
23
+ <a href="classes/Bio/DB/Sam.html#M000024">average_coverage (Bio::DB::Sam)</a><br />
24
+ <a href="classes/Bio/DB/SAM/Tools.html#M000007">bam_sort (Bio::DB::SAM::Tools)</a><br />
25
+ <a href="classes/Bio/DB/Sam.html#M000025">chromosome_coverage (Bio::DB::Sam)</a><br />
26
+ <a href="classes/Bio/DB/Sam.html#M000020">close (Bio::DB::Sam)</a><br />
27
+ <a href="classes/Pileup.html#M000005">consensus (Pileup)</a><br />
28
+ <a href="classes/Bio/DB/Sam.html#M000032">deprecated_pileup (Bio::DB::Sam)</a><br />
29
+ <a href="classes/Bio/DB/Sam.html#M000028">fetch (Bio::DB::Sam)</a><br />
30
+ <a href="classes/Bio/DB/Sam.html#M000026">fetch_reference (Bio::DB::Sam)</a><br />
31
+ <a href="classes/Bio/DB/Sam.html#M000029">fetch_with_function (Bio::DB::Sam)</a><br />
32
+ <a href="classes/Bio/DB/SAM/Library.html#M000006">filename (Bio::DB::SAM::Library)</a><br />
33
+ <a href="classes/Bio/DB/Alignment.html#M000013">finalize (Bio::DB::Alignment)</a><br />
34
+ <a href="classes/Bio/DB/Sam.html#M000021">finalize (Bio::DB::Sam)</a><br />
35
+ <a href="classes/Bio/DB/Sam.html#M000022">load_index (Bio::DB::Sam)</a><br />
36
+ <a href="classes/Bio/DB/Sam.html#M000023">load_reference (Bio::DB::Sam)</a><br />
37
+ <a href="classes/Bio/DB/Sam.html#M000030">merge (Bio::DB::Sam)</a><br />
38
+ <a href="classes/Bio/DB/Sam.html#M000031">mpileup (Bio::DB::Sam)</a><br />
39
+ <a href="classes/Bio/DB/Sam.html#M000017">new (Bio::DB::Sam)</a><br />
40
+ <a href="classes/Pileup.html#M000001">new (Pileup)</a><br />
41
+ <a href="classes/Bio/DB/Alignment.html#M000012">new (Bio::DB::Alignment)</a><br />
42
+ <a href="classes/Bio/DB/SAMException.html#M000016">new (Bio::DB::SAMException)</a><br />
43
+ <a href="classes/Pileup.html#M000003">non_ref_count (Pileup)</a><br />
44
+ <a href="classes/Pileup.html#M000002">non_refs (Pileup)</a><br />
45
+ <a href="classes/Bio/DB/Sam.html#M000018">open (Bio::DB::Sam)</a><br />
46
+ <a href="classes/Bio/DB/SAM/Tools/Bam1T.html#M000010">qname (Bio::DB::SAM::Tools::Bam1T)</a><br />
47
+ <a href="classes/Bio/DB/Sam.html#M000027">query_string (Bio::DB::Sam)</a><br />
48
+ <a href="classes/Pileup.html#M000004">ref_count (Pileup)</a><br />
49
+ <a href="classes/Bio/DB/Alignment.html#M000015">sam= (Bio::DB::Alignment)</a><br />
50
+ <a href="classes/Bio/DB/Alignment.html#M000014">set (Bio::DB::Alignment)</a><br />
51
+ <a href="classes/Bio/DB/Tag.html#M000011">set (Bio::DB::Tag)</a><br />
52
+ <a href="classes/Bio/DB/SAM/Tools/BamHeaderT.html#M000009">text (Bio::DB::SAM::Tools::BamHeaderT)</a><br />
53
+ <a href="classes/Bio/DB/SAM/Tools/BamHeaderT.html#M000008">text= (Bio::DB::SAM::Tools::BamHeaderT)</a><br />
54
+ <a href="classes/Bio/DB/Sam.html#M000019">to_s (Bio::DB::Sam)</a><br />
55
+ </div>
56
+ </div>
57
+ </body>
58
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
5
+
6
+ <!--
7
+
8
+ Pileup
9
+
10
+ -->
11
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
12
+ <head>
13
+ <title>Pileup</title>
14
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
15
+ </head>
16
+ <frameset rows="20%, 80%">
17
+ <frameset cols="25%,35%,45%">
18
+ <frame src="fr_file_index.html" title="Files" name="Files" />
19
+ <frame src="fr_class_index.html" name="Classes" />
20
+ <frame src="fr_method_index.html" name="Methods" />
21
+ </frameset>
22
+ <frame src="files/lib/bio/db/sam/bam_rb.html" name="docwin" />
23
+ </frameset>
24
+ </html>
@@ -0,0 +1,208 @@
1
+
2
+ body {
3
+ font-family: Verdana,Arial,Helvetica,sans-serif;
4
+ font-size: 90%;
5
+ margin: 0;
6
+ margin-left: 40px;
7
+ padding: 0;
8
+ background: white;
9
+ }
10
+
11
+ h1,h2,h3,h4 { margin: 0; color: #efefef; background: transparent; }
12
+ h1 { font-size: 150%; }
13
+ h2,h3,h4 { margin-top: 1em; }
14
+
15
+ a { background: #eef; color: #039; text-decoration: none; }
16
+ a:hover { background: #039; color: #eef; }
17
+
18
+ /* Override the base stylesheet's Anchor inside a table cell */
19
+ td > a {
20
+ background: transparent;
21
+ color: #039;
22
+ text-decoration: none;
23
+ }
24
+
25
+ /* and inside a section title */
26
+ .section-title > a {
27
+ background: transparent;
28
+ color: #eee;
29
+ text-decoration: none;
30
+ }
31
+
32
+ /* === Structural elements =================================== */
33
+
34
+ div#index {
35
+ margin: 0;
36
+ margin-left: -40px;
37
+ padding: 0;
38
+ font-size: 90%;
39
+ }
40
+
41
+
42
+ div#index a {
43
+ margin-left: 0.7em;
44
+ }
45
+
46
+ div#index .section-bar {
47
+ margin-left: 0px;
48
+ padding-left: 0.7em;
49
+ background: #ccc;
50
+ font-size: small;
51
+ }
52
+
53
+
54
+ div#classHeader, div#fileHeader {
55
+ width: auto;
56
+ color: white;
57
+ padding: 0.5em 1.5em 0.5em 1.5em;
58
+ margin: 0;
59
+ margin-left: -40px;
60
+ border-bottom: 3px solid #006;
61
+ }
62
+
63
+ div#classHeader a, div#fileHeader a {
64
+ background: inherit;
65
+ color: white;
66
+ }
67
+
68
+ div#classHeader td, div#fileHeader td {
69
+ background: inherit;
70
+ color: white;
71
+ }
72
+
73
+
74
+ div#fileHeader {
75
+ background: #057;
76
+ }
77
+
78
+ div#classHeader {
79
+ background: #048;
80
+ }
81
+
82
+
83
+ .class-name-in-header {
84
+ font-size: 180%;
85
+ font-weight: bold;
86
+ }
87
+
88
+
89
+ div#bodyContent {
90
+ padding: 0 1.5em 0 1.5em;
91
+ }
92
+
93
+ div#description {
94
+ padding: 0.5em 1.5em;
95
+ background: #efefef;
96
+ border: 1px dotted #999;
97
+ }
98
+
99
+ div#description h1,h2,h3,h4,h5,h6 {
100
+ color: #125;;
101
+ background: transparent;
102
+ }
103
+
104
+ div#validator-badges {
105
+ text-align: center;
106
+ }
107
+ div#validator-badges img { border: 0; }
108
+
109
+ div#copyright {
110
+ color: #333;
111
+ background: #efefef;
112
+ font: 0.75em sans-serif;
113
+ margin-top: 5em;
114
+ margin-bottom: 0;
115
+ padding: 0.5em 2em;
116
+ }
117
+
118
+
119
+ /* === Classes =================================== */
120
+
121
+ table.header-table {
122
+ color: white;
123
+ font-size: small;
124
+ }
125
+
126
+ .type-note {
127
+ font-size: small;
128
+ color: #DEDEDE;
129
+ }
130
+
131
+ .xxsection-bar {
132
+ background: #eee;
133
+ color: #333;
134
+ padding: 3px;
135
+ }
136
+
137
+ .section-bar {
138
+ color: #333;
139
+ border-bottom: 1px solid #999;
140
+ margin-left: -20px;
141
+ }
142
+
143
+
144
+ .section-title {
145
+ background: #79a;
146
+ color: #eee;
147
+ padding: 3px;
148
+ margin-top: 2em;
149
+ margin-left: -30px;
150
+ border: 1px solid #999;
151
+ }
152
+
153
+ .top-aligned-row { vertical-align: top }
154
+ .bottom-aligned-row { vertical-align: bottom }
155
+
156
+ /* --- Context section classes ----------------------- */
157
+
158
+ .context-row { }
159
+ .context-item-name { font-family: monospace; font-weight: bold; color: black; }
160
+ .context-item-value { font-size: small; color: #448; }
161
+ .context-item-desc { color: #333; padding-left: 2em; }
162
+
163
+ /* --- Method classes -------------------------- */
164
+ .method-detail {
165
+ background: #efefef;
166
+ padding: 0;
167
+ margin-top: 0.5em;
168
+ margin-bottom: 1em;
169
+ border: 1px dotted #ccc;
170
+ }
171
+ .method-heading {
172
+ color: black;
173
+ background: #ccc;
174
+ border-bottom: 1px solid #666;
175
+ padding: 0.2em 0.5em 0 0.5em;
176
+ }
177
+ .method-signature { color: black; background: inherit; }
178
+ .method-name { font-weight: bold; }
179
+ .method-args { font-style: italic; }
180
+ .method-description { padding: 0 0.5em 0 0.5em; }
181
+
182
+ /* --- Source code sections -------------------- */
183
+
184
+ a.source-toggle { font-size: 90%; }
185
+ div.method-source-code {
186
+ background: #262626;
187
+ color: #ffdead;
188
+ margin: 1em;
189
+ padding: 0.5em;
190
+ border: 1px dashed #999;
191
+ overflow: hidden;
192
+ }
193
+
194
+ div.method-source-code pre { color: #ffdead; overflow: hidden; }
195
+
196
+ /* --- Ruby keyword styles --------------------- */
197
+
198
+ .standalone-code { background: #221111; color: #ffdead; overflow: hidden; }
199
+
200
+ .ruby-constant { color: #7fffd4; background: transparent; }
201
+ .ruby-keyword { color: #00ffff; background: transparent; }
202
+ .ruby-ivar { color: #eedd82; background: transparent; }
203
+ .ruby-operator { color: #00ffee; background: transparent; }
204
+ .ruby-identifier { color: #ffdead; background: transparent; }
205
+ .ruby-node { color: #ffa07a; background: transparent; }
206
+ .ruby-comment { color: #b22222; font-weight: bold; background: transparent; }
207
+ .ruby-regexp { color: #ffa07a; background: transparent; }
208
+ .ruby-value { color: #7fffd4; background: transparent; }
data/doc/tutorial.html ADDED
@@ -0,0 +1,165 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+
4
+ <html lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
7
+ <title>untitled</title>
8
+ <meta name="generator" content="TextMate http://macromates.com/">
9
+ <meta name="author" content="macleand">
10
+ <!-- Date: 2011-10-14 -->
11
+ <link rel="stylesheet" type="text/css" href="basic_styles.css"></link>
12
+ <link rel="stylesheet" type="text/css" href="http://drnicwilliams.com/external/CodeHighlighter/styles.css"></link>
13
+ <script src="http://drnicwilliams.com/external/CodeHighlighter/clean_tumblr_pre.js"></script>
14
+
15
+ </head>
16
+ <body>
17
+ <div id="wrap">
18
+ <div id="main">
19
+ <div id="header">
20
+ <h1>bio-samtools Basic Tutorial</h1>
21
+ </div>
22
+ <div>
23
+ <h2>Introduction</h2>
24
+ <p>bio-samtools is a Ruby binding to the popular <a href="http://samtools.sourceforge.net/">SAMtools</a> library, and provides access to individual read alignments as well as BAM files, reference sequence and pileup information. </p>
25
+ </div>
26
+ <div>
27
+ <h2>Installation</h2>
28
+ <p>Installation of bio-samtools is very straightforward, and is accomplished with the Ruby <emph>gems</emph> command. All you need is an internet connection.</p>
29
+ <h3>Prerequisites</h3>
30
+ <p>bio-samtools relies on the following other rubygems:</p>
31
+ <ul>
32
+ <li><a href="http://rubygems.org/gems/ffi">FFI</a></li>
33
+ <li><a href="http://rubygems.org/gems/bio">bio >= 1.4.1</a> </li>
34
+ </ul>
35
+ Once these are installed, bio-samtools can be installed with
36
+ <pre><code class="ruby">sudo gem install bio-samtools
37
+ </code></pre>
38
+ It should then be easy to test whether installation went well. Start interactive Ruby (IRB) in the terminal, and type <code>require 'bio-samtools'</code> if the terminal returns <code>true</code> then all is well.
39
+ <pre><code class="ruby">$ irb
40
+ >> require 'bio-samtools'
41
+ => true</code></pre>
42
+ <h2>Working with BAM files</h2><br />
43
+ <h3>Creating a new SAM object</h3>
44
+ <p>
45
+ A SAM object represents the alignments in the BAM file, and is very straightforward to create, you will need a sorted BAM file, to access the alignments and a reference sequence in FASTA format to use the reference sequence. The object can be created and opened as follows:</p>
46
+ <pre><code class="ruby">bam = Bio::DB::Sam.new(:bam=>"my_sorted.bam", :fasta=>'ref.fasta')
47
+ bam.open</code></pre>
48
+ Opening the file needs only to be done once for multiple operations on it, access to the alignments is random so you don't need to loop over the entries in the file.
49
+ </p>
50
+ <h3>Getting Reference Sequence</h3>
51
+ <p>Retrieving the reference can only be done if the reference has been loaded, which isn't done automatically in order to save memory. Reference need only be loaded once, and is accessed using reference name, start, end in 1-based co-ordinates. A standard Ruby String object is returned.</p>
52
+ <pre><code class="ruby">bam.load_reference
53
+ sequence_fragment = bam.fetch_reference("Chr1", 1, 500)</code></pre>
54
+ <h3>Getting Alignments</h3>
55
+ <p>Alignments can be obtained one at a time by looping over a specified region using the <code>fetch()</code> function.</p>
56
+ <pre><code class="ruby">bam.load_reference
57
+ bam.fetch("1",3000,4000).each do |alignment|
58
+ #do something with the alignment...
59
+ end</code></pre>
60
+ <p> A separate method <code>fetch_with_function()</code> allows you to pass a block (or a Proc object) to the function for efficient calculation. This example shows a naive conversion of the alignment object to a GFF3 object, which is stored in an array <code>gff_list</code> </p>
61
+ <pre><code class="ruby">gff_list = []
62
+ fetchAlignment = Proc.new do |a|
63
+ #what strand is this alignment on...
64
+ a.query_strand ? strand = '+' : strand = '-'
65
+ gff_list << Bio::DB::GFF3.new(
66
+ :seqid => "Chr1",
67
+ :start => a.pos - 1,
68
+ :end => a.calend,
69
+ :strand => strand,
70
+ :sequence => a.seq,
71
+ :quality => a.qual,
72
+ :feature => 'read',
73
+ :source => 'BWA',
74
+ :phase => '.',
75
+ :score => '.'
76
+ )
77
+ 0
78
+ end
79
+ bam.fetch_with_function("Chr1", 3000, 4000, fetchAlignment) #now run the fetch</code></pre>
80
+ <h4>Alignment Objects</h4>
81
+ <p>The individual alignments represent a single read and are returned as Bio::DB::Alignment objects. These have numerous methods of their own, using <code>require 'pp'</code> will allow you to check the attributes contained in each object. Here is an example alignment object. Remember <code>@</code> represents a Ruby instance variable and can be accessed as any other method. Thus the <code>@is_mapped</code> attribute of an object <code>a</code> is accessed <code>a.is_mapped</code></p>
82
+ <pre><code class="ruby">require 'pp'
83
+ pp an_alignment_object ##some Bio::DB::Alignment object
84
+ #&lt;Bio::DB::Alignment:0x101113f80
85
+ @al=#&lt;Bio::DB::SAM::Tools::Bam1T:0x101116a50&gt;,
86
+ @calend=4067,
87
+ @cigar="76M",
88
+ @failed_quality=false,
89
+ @first_in_pair=false,
90
+ @flag=163,
91
+ @is_duplicate=false,
92
+ @is_mapped=true,
93
+ @is_paired=true,
94
+ @isize=180,
95
+ @mapq=60,
96
+ @mate_strand=false,
97
+ @mate_unmapped=false,
98
+ @mpos=4096,
99
+ @mrnm="=",
100
+ @pos=3992,
101
+ @primary=true,
102
+ @qlen=76,
103
+ @qname="HWI-EAS396_0001:7:115:17904:15958#0",
104
+ @qual="IIIIIIIIIIIIHHIHGIHIDGGGG...",
105
+ @query_strand=true,
106
+ @query_unmapped=false,
107
+ @rname="1",
108
+ @second_in_pair=true,
109
+ @seq="ACAGTCCAGTCAAAGTACAAATCGAG...",
110
+ @tags=
111
+ {"MD"=>#&lt;Bio::DB::Tag:0x101114ed0 @tag="MD", @type="Z", @value="76"&gt;,
112
+ "XO"=>#&lt;Bio::DB::Tag:0x1011155d8 @tag="XO", @type="i", @value="0"&gt;,
113
+ "AM"=>#&lt;Bio::DB::Tag:0x101116280 @tag="AM", @type="i", @value="37"&gt;,
114
+ "X0"=>#&lt;Bio::DB::Tag:0x101115fb0 @tag="X0", @type="i", @value="1"&gt;,
115
+ "X1"=>#&lt;Bio::DB::Tag:0x101115c68 @tag="X1", @type="i", @value="0"&gt;,
116
+ "XG"=>#&lt;Bio::DB::Tag:0x101115240 @tag="XG", @type="i", @value="0"&gt;,
117
+ "SM"=>#&lt;Bio::DB::Tag:0x1011162f8 @tag="SM", @type="i", @value="37"&gt;,
118
+ "XT"=>#&lt;Bio::DB::Tag:0x1011162a8 @tag="XT", @type="A", @value="U"&gt;,
119
+ "NM"=>#&lt;Bio::DB::Tag:0x101116348 @tag="NM", @type="i", @value="0"&gt;,
120
+ "XM"=>#&lt;Bio::DB::Tag:0x101115948 @tag="XM", @type="i", @value="0"&gt;}&gt;</code></pre>
121
+ <h2>Getting Coverage Information</h2><br />
122
+ <h3>Per Base Coverage</h3>
123
+ <p>It is easy to get the total depth of reads at a given position, the <code>chromosome_coverage</code> function is used. This differs from the previous functions in that a start position and length (rather than end position) are passed to the function. An array of coverages is returned, the first position in the array gives the depth of coverage at the given start position in the genome, the last position in the array gives the depth of coverage at the given start position plus the length given</p>
124
+ <pre><code class="ruby">coverages = bam.chromosome_coverage("Chr1", 3000, 1000) #=> [16,16,25,25...]</code></pre>
125
+ <h3>Average Coverage In A Region</h3>
126
+ <p>Similarly, average (arithmetic mean) of coverage can be retrieved, also with start and length parameters</p>
127
+ <pre><code class="ruby">coverages = bam.average_coverage("Chr1", 3000, 1000) #=> 20.287</code></pre>
128
+
129
+ <h3>Getting Pileup Information</h3>
130
+ <p>Pileup format represents the coverage of reads over a single base in the reference. Getting a Pileup over a region is very easy. Note that this is done with <code>mpileup</code> and NOT the now deprecated SAMTools <code>pileup</code> function. Calling the <code>mpileup</code> method creates an iterator that yields a Pileup object for each base.</p>
131
+ <pre><code class="ruby">bam.mpileup do |pileup|
132
+ puts pileup.consensus #gives the consensus base from the reads for that postion
133
+ end
134
+ </code></pre>
135
+ <h4>Pileup options</h4>
136
+ <p>The <code>mpileup</code> function takes a range of parameters to allow SAMTools level filtering of reads and alignments. They are specified as key =&gt; value pairs eg</p>
137
+ <pre><code class="ruby">bam.mpileup(:r => "Chr1:1000-2000", :Q => 50) do |pileup|
138
+ ##only pileups on Chr1 between positions 1000-2000 are considered,
139
+ ##bases with Quality Score < 50 are excluded
140
+ ...
141
+ end
142
+ </code></pre>
143
+ <p>Not all the options SAMTools allows you to pass to mpileup are supported, those that cause mpileup to return BCF/VCF are ignored. Specifically these are g,u,e,h,I,L,o,p. The table below lists the SAMTools flags supported and the symbols you can use to call them in the mpileup command.
144
+ <table>
145
+ <tr><th>SAMTools option</th><th>description</th><th>short symbol</th><th>long symbol</th><th>default</th><th>example</th></tr>
146
+ <tr><td><code>r</code></td><td>limit retrieval to a region</td><td><code>:r</code></td><td><code>:region</code></td><td>all positions</td><td><code>:r => "Chr1:1000-2000"</code></tr>
147
+ <tr><td><code>6</code></td><td>assume Illumina scaled quality scores</td><td><code>:six</code></td><td><code>:illumina_quals</code></td><td>false</td><td><code>:six => true</code></tr>
148
+ <tr><td><code>A</code></td><td>count anomalous read pairs scores</td><td><code>:A</code></td><td><code>:count_anomalous</code></td><td>false</td><td><code>:A => true</code></tr>
149
+ <tr><td><code>B</code></td><td>disable BAQ computation</td><td><code>:B</code></td><td><code>:no_baq</code></td><td>false</td><td><code>:no_baq => true</code></tr>
150
+ <tr><td><code>C</code></td><td>parameter for adjusting mapQ</td><td><code>:C</code></td><td><code>:adjust_mapq</code></td><td>0</td><td><code>:C => 25</code></tr>
151
+ <tr><td><code>d</code></td><td>max per-BAM depth to avoid excessive memory usage</td><td><code>:d</code></td><td><code>:max_per_bam_depth</code></td><td>250</td><td><code>:d => 123</code></tr>
152
+ <tr><td><code>E</code></td><td>extended BAQ for higher sensitivity but lower specificity</td><td><code>:E</code></td><td><code>:extended_baq</code></td><td>false</td><td><code>:E => true</code></tr>
153
+ <tr><td><code>G</code></td><td>exclude read groups listed in FILE</td><td><code>:G</code></td><td><code>:exclude_reads_file</code></td><td>false</td><td><code>:G => 'my_file.txt'</code></tr>
154
+ <tr><td><code>l</code></td><td>list of positions (chr pos) or regions (BED)</td><td><code>:l</code></td><td><code>:list_of_positions</code></td><td>false</td><td><code>:l => 'my_posns.bed'</code></tr>
155
+ <tr><td><code>M</code></td><td>cap mapping quality at value</td><td><code>:M</code></td><td><code>:mapping_quality_cap</code></td><td>60</td><td><code>:M => 40 </code></tr>
156
+ <tr><td><code>R</code></td><td>ignore RG tags</td><td><code>:R</code></td><td><code>:ignore_rg</code></td><td>false</td><td><code>:R => true </code></tr>
157
+ <tr><td><code>q</code></td><td>skip alignments with mapping quality smaller than value</td><td><code>:q</code></td><td><code>:min_mapping_quality</code></td><td>0</td><td><code>:q => 30 </code></tr>
158
+ <tr><td><code>Q</code></td><td>skip bases with base quality smaller than value</td><td><code>:Q</code></td><td><code>:imin_base_quality</code></td><td>13</td><td><code>:Q => 30 </code></tr>
159
+ </table>
160
+ </div>
161
+ </div>
162
+ </div>
163
+
164
+ </body>
165
+ </html>