bio-samtools 2.1.0 → 2.2.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: 0a798765b86732cd5e41c96a458439fbc51ec41c
4
- data.tar.gz: 43315c48fc5fbc0f182e024031970f7e122b3446
3
+ metadata.gz: a061cf6e87c05ce1f622d1607878cb68d85f92e0
4
+ data.tar.gz: 90f4a519c6174d6b8787e42d6be8917f1b5721b1
5
5
  SHA512:
6
- metadata.gz: abe3c8c927c6459c67fc9a7c79437dad67a9e42c659cd04805de5cc5f8e3b2fc0725a7cb5906e36eb99331b8c3f7e2475d69b532689428b81b40af0361d99b58
7
- data.tar.gz: eba5e3fff77e96192f8788eb0cf12d1c34cfd595d9954394d02c3780e45619aeb48065d5dbcea373e0febd6a8be2b179e020b2bbfc014cfa9e831005273908be
6
+ metadata.gz: 02168c213254e2f4cbe2b16281c0f92c4dbccf6aaca92c4418457a68b835ac2a07e5cc81d68934f86441fe6fb1578ff08e149a5915262843cec67afd5ccc5e8a
7
+ data.tar.gz: 02b7cb92700fc834a3425649f8c1df6694cb22b3d6bc805707695f7206d1055ebbe72293e9a577df6766341ab0dbf12fa95992eec0addc7b4f8321219c96c979
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bio'
4
+
5
+ require 'optparse'
6
+ require 'set'
7
+
8
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
9
+ $: << File.expand_path('.')
10
+ path= File.expand_path(File.dirname(__FILE__) + '/../lib/bio-samtools.rb')
11
+ require path
12
+
13
+
14
+ def log(msg)
15
+ time=Time.now.strftime("%Y-%m-%d %H:%M:%S.%L")
16
+ puts "#{time}: #{msg}"
17
+ end
18
+
19
+
20
+ options = {}
21
+ options[:min_cov] = 5
22
+ options[:min_percentage] = 0.5
23
+ options[:output_file] = "-"
24
+ OptionParser.new do |opts|
25
+
26
+ opts.banner = "Usage: bam_consensus.rb [options]"
27
+
28
+ opts.on("-b", "--bam_file FILE", "BAM File to call for the consensus") do |o|
29
+ options[:bam] = o
30
+ end
31
+ opts.on("-r", "--reference FASTA", "reference with the contigs") do |o|
32
+ options[:reference] = o
33
+ end
34
+ opts.on("-p", "--min_percentage FLOAT", "Minimum percentage to call for a base. When more than one base gets the percentage, an ambiguty code is produced") do |o|
35
+ options[:min_percentage] = o.to_f / 100
36
+ end
37
+
38
+ opts.on("-m", "--min_cov INT", "Minimum percentage to call for a base. When more than one base gets the percentage, an ambiguty code is produced") do |o|
39
+ options[:min_cov] = o.to_i
40
+ end
41
+
42
+ opts.on("-f", "--filter_entries FILE", "File with a list of entries to process") do |o|
43
+ options[:filter_entries] = o
44
+ end
45
+
46
+ opts.on("-o" "--output_file FILE", "Output of the program, in fasta format") do |o|
47
+ options[:output_file] = o
48
+ end
49
+
50
+ end.parse!
51
+
52
+ bam = @parental_1_sam = Bio::DB::Sam.new({:fasta=>options[:reference], :bam=>options[:bam]})
53
+ region_set = nil
54
+ if options[:filter_entries]
55
+ region_set = Set.new
56
+ File.foreach(options[:filter_entries]) do |line|
57
+ region_set << line.chomp
58
+ end
59
+ end
60
+
61
+ fasta_db = Bio::DB::Fasta::FastaFile.new(:fasta=> options[:reference])
62
+ fasta_db.load_fai_entries
63
+
64
+ output = $stdout
65
+
66
+ output = File.open(options[:output_file], "w") if options[:output_file] != "-"
67
+
68
+ fasta_db.index.entries.each do | r |
69
+ process = true
70
+ region=r.get_full_region
71
+
72
+ process = region_set.include? region.entry if region_set
73
+ if process
74
+ reg = bam.fetch_region({:region=>region, :min_cov=>options[:min_cov],:min_per=>options[:min_percentage], :A=>1})
75
+ cons = reg.consensus
76
+ org = fasta_db.fetch_sequence(region)
77
+ if cons.upcase != org.upcase
78
+ output.puts ">#{region.entry}"
79
+ tmp = cons.scan /.{1,80}/
80
+ output.puts tmp.join("\n")
81
+ end
82
+ end
83
+ end
84
+
85
+ output.close if options[:output_file] != "-"
data/bio-samtools.gemspec CHANGED
@@ -2,19 +2,20 @@
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.1.0 ruby lib
5
+ # stub: bio-samtools 2.2.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.1.0"
10
+ s.version = "2.2.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-09-03"
15
+ s.date = "2014-10-16"
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
+ s.executables = ["bam_consensus.rb"]
18
19
  s.extensions = ["ext/mkrf_conf.rb"]
19
20
  s.extra_rdoc_files = [
20
21
  "LICENSE.txt",
@@ -28,6 +29,7 @@ Gem::Specification.new do |s|
28
29
  "README.md",
29
30
  "Rakefile",
30
31
  "VERSION",
32
+ "bin/bam_consensus.rb",
31
33
  "bio-samtools.gemspec",
32
34
  "doc/Bio.html",
33
35
  "doc/Bio/DB.html",
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.1.0
4
+ version: 2.2.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-09-03 00:00:00.000000000 Z
13
+ date: 2014-10-16 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bio-svgenes
@@ -184,7 +184,8 @@ description: "Binder of samtools for ruby, on the top of FFI. \n\n This project
184
184
  born from the need to add support of BAM files to \n the gee_fu genome browser
185
185
  (http://github.com/danmaclean/gee_fu)."
186
186
  email: ilpuccio.febo@gmail.com
187
- executables: []
187
+ executables:
188
+ - bam_consensus.rb
188
189
  extensions:
189
190
  - ext/mkrf_conf.rb
190
191
  extra_rdoc_files:
@@ -198,6 +199,7 @@ files:
198
199
  - README.md
199
200
  - Rakefile
200
201
  - VERSION
202
+ - bin/bam_consensus.rb
201
203
  - bio-samtools.gemspec
202
204
  - doc/Bio.html
203
205
  - doc/Bio/DB.html