bio-samtools 2.2.0 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a061cf6e87c05ce1f622d1607878cb68d85f92e0
4
- data.tar.gz: 90f4a519c6174d6b8787e42d6be8917f1b5721b1
3
+ metadata.gz: 95a8754491dfd5146f150c810a425914b86e95b8
4
+ data.tar.gz: 8fb156bef16dd3a4e8a1d3a06006bf88a6987fcb
5
5
  SHA512:
6
- metadata.gz: 02168c213254e2f4cbe2b16281c0f92c4dbccf6aaca92c4418457a68b835ac2a07e5cc81d68934f86441fe6fb1578ff08e149a5915262843cec67afd5ccc5e8a
7
- data.tar.gz: 02b7cb92700fc834a3425649f8c1df6694cb22b3d6bc805707695f7206d1055ebbe72293e9a577df6766341ab0dbf12fa95992eec0addc7b4f8321219c96c979
6
+ metadata.gz: 4216233167cc318ad452d3519b74a2e2a29001e078cb9ad3f27c3a29ce8e5355c372908bc090c58b0d2564d90565f15b19b055fca464ce02471b24b2db6173ce
7
+ data.tar.gz: b3a0aca0dccfde418162ad23a117053121a93f511402034de62640fb4508031fd32f3af9d5ac792a80507884c9fd723a3b5067fd918ea91c22b61f9ebb223807
data/README.md CHANGED
@@ -25,7 +25,7 @@ Or install it yourself as:
25
25
 
26
26
  $ gem install bio-samtools
27
27
 
28
- ## Usage
28
+ ## Getting started
29
29
 
30
30
  ### Creating a new SAM object
31
31
 
@@ -52,7 +52,389 @@ Alignments can be obtained one at a time by looping over a specified region usin
52
52
  #do something with the alignment...
53
53
  end
54
54
 
55
- See more detail on doc/tutorial.html or doc/tutorial.pdf for a walkthrough tutorial.
55
+ #Tutorial
56
+ ##Creating a BAM file
57
+ Often, the output from a next-generation sequence alignment tool will be a file in the [SAM format](http://samtools.github.io/hts-specs/SAMv1.pdf).
58
+
59
+ Typically, we'd create a compressed, indexed binary version of the SAM file, which would allow us to operate on it in a quicker and more efficient manner, being able to randomly access various parts of the alignment. We'd use the `view` to do this. This step would involve takeing our sam file, sorting it and indexing it.
60
+
61
+ ```ruby
62
+ #create the sam object
63
+ sam = Bio::DB::Sam.new(:bam => 'my.sam', :fasta => 'ref.fasta')
64
+
65
+ #create a bam file from the sam file
66
+ sam.view(:b=>true, :S=>true, :o=>'bam.bam')
67
+
68
+ #create a new sam object from the bam file
69
+ unsortedBam = Bio::DB::Sam.new(:bam => 'bam.bam', :fasta => 'ref.fasta')
70
+
71
+ #the bam file might not be sorted (necessary for samtools), so sort it
72
+ unsortedBam.sort(:prefix=>'sortedBam')
73
+
74
+ #create a new sam object
75
+ bam = Bio::DB::Sam.new(:bam => 'sortedBam.bam', :fasta => 'ref.fasta')
76
+ #create a new index
77
+ bam.index()
78
+
79
+ #creates index file sortedBam.bam.bai
80
+ ```
81
+
82
+
83
+ Working with BAM files
84
+ ----------------------
85
+
86
+
87
+ ### Creating a new SAM object
88
+
89
+ A SAM object represents the alignments in the BAM file. BAM files (and hence SAM objects here) are what most of SAMtools methods operate on and are very straightforward to create. You will need a sorted and indexed BAM file, to access the alignments and a reference sequence in FASTA format to use the reference sequence. Let's revisit the last few lines of code from the code above.
90
+
91
+ ```ruby
92
+ bam = Bio::DB::Sam.new(:bam => 'sortedBam.bam', :fasta => 'ref.fasta')
93
+ bam.index()
94
+ ```
95
+
96
+ Creating the new Bio::DB::Sam (named 'bam' in this case) 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.
97
+
98
+ ### Getting Reference Sequence
99
+
100
+ The reference is accessed using reference
101
+ name, start, end in 1-based co-ordinates. A standard Ruby String object is returned.
102
+ ```ruby
103
+ sequence_fragment = bam.fetch_reference("Chr1", 1, 100)
104
+ puts sequence_fragment
105
+ => cctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaacccta
106
+ ```
107
+
108
+ A reference sequence can be returned as a Bio::Sequence::NA object buy the use of :as_bio => true
109
+ ```ruby
110
+ sequence_fragment = bam.fetch_reference("Chr1", 1, 100, :as_bio => true)
111
+ ```
112
+
113
+ The printed output from this would be a fasta-formatted string
114
+ ```ruby
115
+ puts sequence_fragment
116
+
117
+ => >Chr1:1-100
118
+ => cctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaaccctaacccta
119
+ ```
120
+
121
+ ### Concatenating BAM files
122
+ BAM files may be concatenated using the `cat` command. The sequence dictionary of each input BAM must be identical, although the `cat` method does not check this.
123
+
124
+ ```ruby
125
+ #create an array of BAM files to cat
126
+ bam_files = [bam1, bam2]
127
+ cat_file = "maps_cated.bam" #the outfile
128
+ #cat the files
129
+ @sam.cat(:out=>cat_file, :bams=>bam_files)
130
+ #create a new Bio::DB::Sam object from the new cat file
131
+ cat_bam = Bio::DB::Sam.new(:fasta => "ref.fasta", :bam => cat_file)
132
+
133
+ ```
134
+
135
+ ### Removing duplicate reads
136
+ The `remove_duplicates` method removes potential PCR duplicates: if multiple read pairs have identical external coordinates it only retain the pair with highest mapping quality. It does not work for unpaired reads (e.g. two ends mapped to different chromosomes or orphan reads).
137
+ ```ruby
138
+
139
+ unduped = "dupes_rmdup.bam" #an outfile for the removed duplicates bam
140
+ #remove single-end duplicates
141
+ bam.remove_duplicates(:s=>true, :out=>unduped)
142
+ #create new Bio::DB::Sam object
143
+ unduped_bam = Bio::DB::Sam.new(:fasta => "ref.fasta", :bam => unduped)
144
+
145
+ ```
146
+
147
+ ### Alignment Objects
148
+
149
+ The individual alignments represent a single read and are returned as
150
+ Bio::DB::Alignment objects. These have numerous methods of their own,
151
+ using `require 'pp'` will allow you to check the attributes contained in
152
+ each object. Here is an example alignment object. Remember `@`
153
+ represents a Ruby instance variable and can be accessed as any other
154
+ method. Thus the `@is_mapped` attribute of an object `a` is accessed
155
+ `a.is_mapped`
156
+
157
+ ```ruby
158
+ require 'pp'
159
+ pp an_alignment_object ##some Bio::DB::Alignment object
160
+ #<Bio::DB::Alignment:0x101113f80
161
+ @al=#<Bio::DB::SAM::Tools::Bam1T:0x101116a50>,
162
+ @calend=4067,
163
+ @cigar="76M",
164
+ @failed_quality=false,
165
+ @first_in_pair=false,
166
+ @flag=163,
167
+ @is_duplicate=false,
168
+ @is_mapped=true,
169
+ @is_paired=true,
170
+ @isize=180,
171
+ @mapq=60,
172
+ @mate_strand=false,
173
+ @mate_unmapped=false,
174
+ @mpos=4096,
175
+ @mrnm="=",
176
+ @pos=3992,
177
+ @primary=true,
178
+ @qlen=76,
179
+ @qname="HWI-EAS396_0001:7:115:17904:15958#0",
180
+ @qual="IIIIIIIIIIIIHHIHGIHIDGGGG...",
181
+ @query_strand=true,
182
+ @query_unmapped=false,
183
+ @rname="1",
184
+ @second_in_pair=true,
185
+ @seq="ACAGTCCAGTCAAAGTACAAATCGAG...",
186
+ @tags=
187
+ {"MD"=>#<Bio::DB::Tag:0x101114ed0 @tag="MD", @type="Z", @value="76">,
188
+ "XO"=>#<Bio::DB::Tag:0x1011155d8 @tag="XO", @type="i", @value="0">,
189
+ "AM"=>#<Bio::DB::Tag:0x101116280 @tag="AM", @type="i", @value="37">,
190
+ "X0"=>#<Bio::DB::Tag:0x101115fb0 @tag="X0", @type="i", @value="1">,
191
+ "X1"=>#<Bio::DB::Tag:0x101115c68 @tag="X1", @type="i", @value="0">,
192
+ "XG"=>#<Bio::DB::Tag:0x101115240 @tag="XG", @type="i", @value="0">,
193
+ "SM"=>#<Bio::DB::Tag:0x1011162f8 @tag="SM", @type="i", @value="37">,
194
+ "XT"=>#<Bio::DB::Tag:0x1011162a8 @tag="XT", @type="A", @value="U">,
195
+ "NM"=>#<Bio::DB::Tag:0x101116348 @tag="NM", @type="i", @value="0">,
196
+ "XM"=>#<Bio::DB::Tag:0x101115948 @tag="XM", @type="i", @value="0">}>
197
+ ```
198
+
199
+ ### Getting Alignments
200
+
201
+ Alignments can be obtained one at a time by looping over a specified region using the `fetch()` function.
202
+
203
+ ```ruby
204
+ bam.fetch("Chr1",3000,4000).each do |alignment|
205
+ #do something with the alignment...
206
+ end
207
+ ```
208
+
209
+ A separate method `fetch_with_function()` allows you to pass a block (or
210
+ a Proc object) to the function for efficient calculation. This example takes
211
+ an alignment object and returns an array of sequences which exactly match the reference.
212
+
213
+ ```ruby
214
+ #an array to hold the matching sequences
215
+ exact_matches = []
216
+
217
+ matches = Proc.new do |a|
218
+ #get the length of each read
219
+ len = a.seq.length
220
+ #get the cigar string
221
+ cigar = a.cigar
222
+ #create a cigar string which represents a full-length match
223
+ cstr = len.to_s << "M"
224
+ if cigar == cstr
225
+ #add the current sequence to the array if it qualifies
226
+ exact_matches << a.seq
227
+ end
228
+ end
229
+
230
+ bam.fetch_with_function("Chr1", 100, 500, &matches)
231
+
232
+ puts exact_matches
233
+ ```
234
+
235
+ ###Alignment stats
236
+
237
+ The SAMtools flagstat method is implemented in bio-samtools to quickly examine the number of reads mapped to the reference. This includes the number of paired and singleton reads mapped and also the number of paired-reads that map to different chromosomes/contigs.
238
+
239
+ ```ruby
240
+ bam.flag_stats()
241
+ ```
242
+
243
+ An example output would be
244
+ ```ruby
245
+ 34672 + 0 in total (QC-passed reads + QC-failed reads)
246
+ 0 + 0 duplicates
247
+ 33196 + 0 mapped (95.74%:nan%)
248
+ 34672 + 0 paired in sequencing
249
+ 17335 + 0 read1
250
+ 17337 + 0 read2
251
+ 31392 + 0 properly paired (90.54%:nan%)
252
+ 31728 + 0 with itself and mate mapped
253
+ 1468 + 0 singletons (4.23%:nan%)
254
+ 0 + 0 with mate mapped to a different chr
255
+ 0 + 0 with mate mapped to a different chr (mapQ>=5)
256
+ ```
257
+
258
+ Getting Coverage Information
259
+ ----------------------------
260
+
261
+
262
+ ### Per Base Coverage
263
+
264
+ It is easy to get the total depth of reads at a given position, the
265
+ `chromosome_coverage` function is used. This differs from the previous
266
+ functions in that a start position and length (rather than end position)
267
+ are passed to the function. An array of coverages is returned, the first
268
+ position in the array gives the depth of coverage at the given start
269
+ position in the genome, the last position in the array gives the depth
270
+ of coverage at the given start position plus the length given
271
+
272
+ ```ruby
273
+ coverages = bam.chromosome_coverage("Chr1", 3000, 1000) #=> [16,16,25,25...]
274
+ ```
275
+
276
+ ### Average Coverage In A Region
277
+
278
+ Similarly, average (arithmetic mean) of coverage can be retrieved with the `average_coverage` method.
279
+
280
+ ```ruby
281
+ coverages = bam.average_coverage("Chr1", 3000, 1000) #=> 20.287
282
+ ```
283
+
284
+ ### Coverage from a BED file
285
+ It is possible to count the number of nucleotides mapped to a given region of a BAM file by providing a [BED formatted](http://genome.ucsc.edu/FAQ/FAQformat.html#format1) file and using the `bedcov` method. The output is the BED file with an extra column providing the number of nucleotides mapped to that region.
286
+
287
+ ```ruby
288
+ bed_file = "test.bed"
289
+ bam.bedcov(:bed=>bed_file)
290
+
291
+ => chr_1 1 30 6
292
+ => chr_1 40 45 8
293
+
294
+ ```
295
+ Alternatively, the `depth` method can be used to get per-position depth information (any unmapped positions will be ignored).
296
+ ```ruby
297
+ bed_file = "test.bed"
298
+ @sam.depth(:b=>bed_file)
299
+
300
+ => chr_1 25 1
301
+ => chr_1 26 1
302
+ => chr_1 27 1
303
+ => chr_1 28 1
304
+ => chr_1 29 1
305
+ => chr_1 30 1
306
+ => chr_1 41 1
307
+ => chr_1 42 1
308
+ => chr_1 43 2
309
+ => chr_1 44 2
310
+ => chr_1 45 2
311
+ ```
312
+ ##Getting Pileup Information
313
+
314
+ Pileup format represents the coverage of reads over a single base in the
315
+ reference. Getting a Pileup over a region is very easy. Note that this
316
+ is done with `mpileup` and NOT the now deprecated SAMtools `pileup`
317
+ function. Calling the `mpileup` method creates an iterator that yields a
318
+ Pileup object for each base.
319
+
320
+ ```ruby
321
+ bam.mpileup do |pileup|
322
+ puts pileup.consensus #gives the consensus base from the reads for that position
323
+ end
324
+ ```
325
+
326
+ ###Caching pileups
327
+ A pileup can be cached, so if you want to execute several operations on the same set of regions, mpilup won't be executed several times. Whenever you finish using a region, call mpileup_clear_cache to free the cache. The argument 'Region' is required, as it will be the key for the underlying hash. We assume that the options (other than the region) are constant. If they are not, the cache mechanism may not be consistent.
328
+
329
+ ```ruby
330
+ #create an mpileup
331
+ reg = Bio::DB::Fasta::Region.new
332
+ reg.entry = "Chr1"
333
+ reg.start = 1
334
+ reg.end = 334
335
+
336
+ bam.mpileup_cached(:r=>reg,:g => false, :min_cov => 1, :min_per =>0.2) do |pileup|
337
+ puts pileup.consensus
338
+ end
339
+ bam.mpileup_clear_cache(reg)
340
+ ```
341
+
342
+
343
+ #### Pileup options
344
+
345
+ The `mpileup` function takes a range of parameters to allow SAMtools
346
+ level filtering of reads and alignments. They are specified as key =\>
347
+ value pairs eg
348
+
349
+ ```ruby
350
+ bam.mpileup(:r => "Chr1:1000-2000", :Q => 50) do |pileup|
351
+ ##only pileups on Chr1 between positions 1000-2000 are considered,
352
+ ##bases with Quality Score < 50 are excluded
353
+ ...
354
+ end
355
+ ```
356
+
357
+ Not all the options SAMtools allows you to pass to mpileup will return a
358
+ Pileup object, The table below lists the SAMtools flags supported and the symbols you can use to call them in
359
+ the mpileup command.
360
+
361
+ <table><tr><th>SAMtools options</th><th>description</th><th>short symbol</th><th>long symbol</th><th>default</th><th>example</th></tr>
362
+ <tr><td>r</td><td>limit retrieval to a region</td><td>:r</td><td>:region</td><td>all positions</td><td>:r => "Chr1:1000-2000"</td></tr>
363
+ <tr><td>6</td><td>assume Illumina scaled quality scores</td><td>:six</td><td>:illumina_quals</td><td>false</td><td>:six => true</td></tr>
364
+ <tr><td>A</td><td>count anomalous read pairs scores</td><td>:A</td><td>:count_anomalous</td><td>false</td><td>:A => true</td></tr>
365
+ <tr><td>B</td><td>disable BAQ computation</td><td>:B</td><td>:no_baq</td><td>false</td><td>:no_baq => true</td></tr>
366
+ <tr><td>C</td><td>parameter for adjusting mapQ</td><td>:C</td><td>:adjust_mapq</td><td>0</td><td>:C => 25</td></tr>
367
+ <tr><td>d</td><td>max per-BAM depth to avoid excessive memory usage</td><td>:d</td><td>:max_per_bam_depth</td><td>250</td><td>:d => 123</td></tr>
368
+ <tr><td>E</td><td>extended BAQ for higher sensitivity but lower specificity</td><td>:E</td><td>:extended_baq</td><td>false</td><td>:E => true</td></tr>
369
+ <tr><td>G</td><td>exclude read groups listed in FILE</td><td>:G</td><td>:exclude_reads_file</td><td>false</td><td>:G => my_file.txt</td></tr>
370
+ <tr><td>l</td><td>list of positions (chr pos) or regions (BED)</td><td>:l</td><td>:list_of_positions</td><td>false</td><td>:l => my_posns.bed</td></tr>
371
+ <tr><td>M</td><td>cap mapping quality at value</td><td>:M</td><td>:mapping_quality_cap</td><td>60</td><td>:M => 40 </td></tr>
372
+ <tr><td>R</td><td>ignore RG tags</td><td>:R</td><td>:ignore_rg</td><td>false</td><td>:R => true </td></tr>
373
+ <tr><td>q</td><td>skip alignments with mapping quality smaller than value</td><td>:q</td><td>:min_mapping_quality</td><td>0</td><td>:q => 30 </td></tr>
374
+ <tr><td>Q</td><td>skip bases with base quality smaller than value</td><td>:Q</td><td>:imin_base_quality</td><td>13</td><td>:Q => 30</td></tr>
375
+ </table>
376
+
377
+
378
+ ##Coverage Plots
379
+ You can create images that represent read coverage over binned regions of the reference sequence. The output format is svg. A number of parameters can be changed to alter the style of the plot. In the examples below the bin size and fill_color have been used to create plots with different colours and bar widths.
380
+
381
+ The following lines of code...
382
+
383
+ ```ruby
384
+ bam.plot_coverage("Chr1", 201, 2000, :bin=>20, :svg => "out2.svg", :fill_color => '#F1A1B1')
385
+ bam.plot_coverage("Chr1", 201, 2000, :bin=>50, :svg => "out.svg", :fill_color => '#99CCFF')
386
+ bam.plot_coverage("Chr1", 201, 1000, :bin=>250, :svg => "out3.svg", :fill_color => '#33AD5C', :stroke => '#33AD5C')
387
+ ```
388
+
389
+ ![Coverage plot 1](http://ethering.github.io/bio-samtools/images/out2.svg)
390
+ ![Coverage plot 2](http://ethering.github.io/bio-samtools/images/out.svg)
391
+ ![Coverage plot 2](http://ethering.github.io/bio-samtools/images/out3.svg)
392
+
393
+ The `plot_coverage` method will also return the raw svg code, for further use. Simply leave out a file name and assign the method to a variable.
394
+
395
+ ```ruby
396
+ svg = bam.plot_coverage("Chr1", 201, 2000, :bin=>50, :fill_color => '#99CCFF')
397
+
398
+ ```
399
+
400
+
401
+ #VCF methods
402
+ For enhanced snp calling, we've included a VCF class which reflects each non-metadata line of a VCF file.
403
+ The VCF class returns the eight fixed fields present in VCF files, namely chromosome, position, ID, reference base, alt bases, alt quality score, filter and info along with the genotype fields, format and samples. This information allows the comparison of variants and their genotypes across any number of samples.
404
+ The following code takes a number of VCF objects and examines them for homozygous alt (1/1) SNPs
405
+
406
+ ```ruby
407
+ vcfs = []
408
+ vcfs << vcf1 = Bio::DB::Vcf.new("20 14370 rs6054257 G A 29 0 NS=3;DP=14;AF=0.5;DB;H2 GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:-1,-1") #from a 3.3 vcf file
409
+ vcfs << vcf2 = Bio::DB::Vcf.new("19 111 . A C 9.6 . . GT:HQ 0|0:10,10 0/0:10,10 0/1:3,3") #from a 4.0 vcf file
410
+ vcfs << vcf3 = Bio::DB::Vcf.new("20 14380 rs6054257 G A 29 PASS NS=3;DP=14;AF=0.5;DB;H2 GT:GQ:DP:HQ 0|0:48:1:51,51 1|0:48:8:51,51 1/1:43:5:.,") #from a 4.0 vcf file
411
+
412
+ vcfs.each do |vcf|
413
+ vcf.samples.each do |sample|
414
+ genotype = sample[1]['GT']
415
+ if genotype == '1/1' or genotype == '1|1'
416
+ print vcf.chrom, " "
417
+ puts vcf.pos
418
+ end
419
+ end
420
+ end
421
+
422
+ => 20 14370
423
+ => 20 14380
424
+ ```
425
+
426
+ ##Other methods not covered
427
+ The SAMtools methods faidx, fixmate, tview, reheader, calmd, targetcut and phase are all included in the current bio-samtools release.
428
+
429
+ Tests
430
+ -----
431
+
432
+ The easiest way to run the built-in unit tests is to change to the
433
+ bio-samtools source directory and running 'rake test'
434
+
435
+ Each test file tests different aspects of the code.
436
+
437
+
56
438
 
57
439
  ## Dependencies
58
440
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.3.0
data/bio-samtools.gemspec CHANGED
@@ -2,17 +2,17 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: bio-samtools 2.2.0 ruby lib
5
+ # stub: bio-samtools 2.3.0 ruby lib
6
6
  # stub: ext/mkrf_conf.rb
7
7
 
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "bio-samtools"
10
- s.version = "2.2.0"
10
+ s.version = "2.3.0"
11
11
 
12
12
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
13
13
  s.require_paths = ["lib"]
14
14
  s.authors = ["Ricardo Ramirez-Gonzalez", "Dan MacLean", "Raoul J.P. Bonnal"]
15
- s.date = "2014-10-16"
15
+ s.date = "2015-02-18"
16
16
  s.description = "Binder of samtools for ruby, on the top of FFI. \n\n This project was born from the need to add support of BAM files to \n the gee_fu genome browser (http://github.com/danmaclean/gee_fu)."
17
17
  s.email = "ilpuccio.febo@gmail.com"
18
18
  s.executables = ["bam_consensus.rb"]
@@ -145,7 +145,7 @@ Gem::Specification.new do |s|
145
145
  ]
146
146
  s.homepage = "http://github.com/helios/bioruby-samtools"
147
147
  s.licenses = ["MIT"]
148
- s.rubygems_version = "2.2.1"
148
+ s.rubygems_version = "2.2.2"
149
149
  s.summary = "Binder of samtools for ruby, on the top of FFI."
150
150
 
151
151
  if s.respond_to? :specification_version then
data/ext/Rakefile CHANGED
@@ -24,24 +24,24 @@ task :compile do
24
24
  when /linux/
25
25
  #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e"
26
26
  sh "make"
27
- cp("libbam.a","/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
27
+ cp("libbam.a","/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
28
28
  #sh "CFLAGS='-g -Wall -O2 -fPIC' make -e libbam.so.1-local"
29
29
  sh "make libbam.so.1-local"
30
- cp("samtools", "/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
31
- cp("libbam.so.1","/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
30
+ cp("samtools", "/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
31
+ cp("libbam.so.1","/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
32
32
  when /darwin/
33
33
  sh "make"
34
- cp("libbam.a","/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
34
+ cp("libbam.a","/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
35
35
  sh "make libbam.1.dylib-local"
36
- cp("libbam.1.dylib","/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
36
+ cp("libbam.1.dylib","/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
37
37
  sh "make"
38
- cp('samtools', "/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
38
+ cp('samtools', "/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
39
39
  when /mswin|mingw/ then raise NotImplementedError, "BWA library is not available for Windows platform"
40
40
  end #case
41
41
  end #cd
42
42
  cd("samtools-0.1.19/bcftools") do
43
43
  sh "make"
44
- cp('bcftools', "/Users/ramirezr/Documents/public_code/bioruby-samtools/ext/../lib/bio/db/sam/external")
44
+ cp('bcftools', "/home/ramirezr/Documents/public_code/helios/bioruby-samtools/ext/../lib/bio/db/sam/external")
45
45
  end
46
46
  end
47
47
 
data/lib/bio/db/vcf.rb CHANGED
@@ -23,7 +23,30 @@ module Bio
23
23
  def int_or_raw(x)
24
24
  Integer.new(x) rescue x
25
25
  end
26
-
26
+
27
+ #returns vcf format line
28
+ def to_s
29
+ if !@chrom.nil?
30
+ str = [@chrom, @pos, @id, @ref, @alt, @qual.to_i, @filter, ""].join("\t")
31
+ #@format, @samples]
32
+ infos=[]
33
+ info.each do|key,val|
34
+ infos << "#{key}=#{val}"
35
+ end
36
+ str << infos.join(";")
37
+ str << "\t#{@format}\t"
38
+ samples.each do |key, val|
39
+ array=[]
40
+ val.each do |keys, vals|
41
+ array << "#{vals}"
42
+ end
43
+ str << array.join(":")
44
+ str << "\t"
45
+ end
46
+ end
47
+ str
48
+ end
49
+
27
50
  #gets the info in the Vcf lines and parses it, setting the attributes
28
51
  def parse_line(line, sample_names=nil)
29
52
  return false if line[0,1] == '#'
@@ -1,2 +1,2 @@
1
1
  chr_1 1 30
2
- chr_1 40 45
2
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bio-samtools
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Ramirez-Gonzalez
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-16 00:00:00.000000000 Z
13
+ date: 2015-02-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bio-svgenes
@@ -332,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
332
332
  version: '0'
333
333
  requirements: []
334
334
  rubyforge_project:
335
- rubygems_version: 2.2.1
335
+ rubygems_version: 2.2.2
336
336
  signing_key:
337
337
  specification_version: 4
338
338
  summary: Binder of samtools for ruby, on the top of FFI.