bio-blat-tools 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0639ee061360d6a4b82882101239f781a5f2d134
4
+ data.tar.gz: afdeb224ec1d3a92830b40abe5e8c9b3b3bb4a5b
5
+ SHA512:
6
+ metadata.gz: 685a75e2e2eb3030f888be47342df23c3dc876adbb994bc17d2f1e934eac8bddd673956d56364286605b6f6df3c291e94bbc84817e7bc4542eeb74a94d615fc1
7
+ data.tar.gz: 48240661d4cd4d2ee1a8bff5e25e7f1dfc7f0d816956ff7af6fed978dbac2bd9e06d00dc9f0d4d72cbc70d27d5caad0bbdda5b1bd1c105048d5a7f67d3d3e74d
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - 2.0.3
6
+ - 2.1.3
7
+ - jruby-19mode # JRuby in 1.9 mode
8
+
9
+ # - rbx-19mode
10
+ # - 1.8.7
11
+ # - jruby-18mode # JRuby in 1.8 mode
12
+ # - rbx-18mode
13
+
14
+ # uncomment this line if your project needs to run something other than `rake`:
15
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+
9
+
10
+ group :development do
11
+ gem "shoulda", ">= 0"
12
+ gem "rdoc", "~> 3.12"
13
+ gem "simplecov", ">= 0"
14
+ gem "jeweler", "~> 2.0.1", :git => "https://github.com/technicalpickles/jeweler.git"
15
+ gem "bundler", ">= 1.0.21"
16
+ gem "bio", ">= 1.4.3"
17
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 homonecloco
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # bio-blat-tools
2
+
3
+ [![Build Status](https://secure.travis-ci.org/homonecloco/bioruby-blat-tools.png)](http://travis-ci.org/homonecloco/bioruby-blat-tools)
4
+
5
+ Full description goes here
6
+
7
+ Note: this software is under active development!
8
+
9
+ ## Installation
10
+
11
+ ```sh
12
+ gem install bio-blat-tools
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```ruby
18
+ require 'bio-blat-tools'
19
+ ```
20
+
21
+ The API doc is online. For more code examples see the test files in
22
+ the source tree.
23
+
24
+ ## Project home page
25
+
26
+ Information on the source tree, documentation, examples, issues and
27
+ how to contribute, see
28
+
29
+ http://github.com/homonecloco/bioruby-blat-tools
30
+
31
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
32
+
33
+ ## Cite
34
+
35
+ If you use this software, please cite one of
36
+
37
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
38
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
39
+
40
+ ## Biogems.info
41
+
42
+ This Biogem is published at (http://biogems.info/index.html#bio-blat-tools)
43
+
44
+ ## Copyright
45
+
46
+ Copyright (c) 2014 homonecloco. See LICENSE.txt for further details.
47
+
@@ -0,0 +1,48 @@
1
+ = bio-blat-tools
2
+
3
+ {<img
4
+ src="https://secure.travis-ci.org/homonecloco/bioruby-blat-tools.png"
5
+ />}[http://travis-ci.org/#!/homonecloco/bioruby-blat-tools]
6
+
7
+ Full description goes here
8
+
9
+ Note: this software is under active development!
10
+
11
+ == Installation
12
+
13
+ gem install bio-blat-tools
14
+
15
+ == Usage
16
+
17
+ == Developers
18
+
19
+ To use the library
20
+
21
+ require 'bio-blat-tools'
22
+
23
+ The API doc is online. For more code examples see also the test files in
24
+ the source tree.
25
+
26
+ == Project home page
27
+
28
+ Information on the source tree, documentation, issues and how to contribute, see
29
+
30
+ http://github.com/homonecloco/bioruby-blat-tools
31
+
32
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
33
+
34
+ == Cite
35
+
36
+ If you use this software, please cite one of
37
+
38
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
39
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
40
+
41
+ == Biogems.info
42
+
43
+ This Biogem is published at http://biogems.info/index.html#bio-blat-tools
44
+
45
+ == Copyright
46
+
47
+ Copyright (c) 2014 homonecloco. See LICENSE.txt for further details.
48
+
@@ -0,0 +1,52 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "bio-blat-tools"
18
+ gem.homepage = "http://github.com/homonecloco/bioruby-blat-tools"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Tools to manipulate blat files from the command line.}
21
+ gem.description = %Q{Tools to manipulate blat files from the command line. Uses the Bio::Blat object from BioRuby, but the parser has been modified to avoid reading the whole psl file, it yields just the current entry and it is up to the consumer to decide to store it or not."
22
+ s.email = "ricardo.ramirez-gonzalez@tgac.ac.uk"}
23
+ gem.email = "ricardo.ramirez-gonzalez@tgac.ac.uk"
24
+ gem.authors = ["homonecloco"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ desc "Code coverage detail"
37
+ task :simplecov do
38
+ ENV['COVERAGE'] = "true"
39
+ Rake::Task['test'].execute
40
+ end
41
+
42
+ task :default => :test
43
+
44
+ require 'rdoc/task'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "bio-blat-tools #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'bio'
4
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+ $: << File.expand_path('.')
6
+ path= File.expand_path(File.dirname(__FILE__) + '/../lib/bio-blat-tools.rb')
7
+ require path
8
+
9
+ options = {}
10
+ options[:identity] = 95
11
+ options[:covered] = 60
12
+ options[:blat_file] = "-"
13
+
14
+ OptionParser.new do |opts|
15
+
16
+ opts.banner = "Usage: best_blat_hit.rb [options]"
17
+
18
+ opts.on("-p", "--psl FILE", "PSL file") do |o|
19
+ options[:blat_file] = o
20
+ end
21
+
22
+ end.parse!
23
+
24
+ stream = ARGF
25
+ stream = IO.open(IO.sysopen(options[:blat_file])) unless options[:blat_file] == "-"
26
+
27
+ Bio::Blat::StreamedReport.each_best_hit(stream) do |hit|
28
+ puts hit.data.join("\t")
29
+ end
30
+
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'bio'
4
+ $: << File.expand_path(File.dirname(__FILE__) + '/../lib')
5
+ $: << File.expand_path('.')
6
+ path= File.expand_path(File.dirname(__FILE__) + '/../lib/bio-blat-tools.rb')
7
+ require path
8
+
9
+ options = {}
10
+ options[:identity] = 95
11
+ options[:covered] = 60
12
+ options[:blat_file] = "-"
13
+
14
+ OptionParser.new do |opts|
15
+
16
+ opts.banner = "Usage: filter_blat.rb [options]"
17
+
18
+ opts.on("-p", "--psl FILE", "PSL file") do |o|
19
+ options[:blat_file] = o
20
+ end
21
+ opts.on("-i", "--identity FLOAT", "Minimum percentage identity") do |o|
22
+ options[:identity] = o.to_f
23
+ end
24
+ opts.on("-c", "--covered FLOAT", "Minimum percentage coverage") do |o|
25
+ options[:covered] = o.to_f
26
+ end
27
+
28
+ end.parse!
29
+
30
+
31
+ blat_file = options[:blat_file]
32
+ stream = ARGF
33
+ stream = IO.open(options[:blat_file]) unless options[:blat_file] == "-"
34
+
35
+ Bio::Blat::StreamedReport.each_hit(stream) do |hit|
36
+ #puts hit.inspect
37
+ if hit.percentage_covered >= options[:covered] and hit.percent_identity >= options[:identity]
38
+ puts hit.data.join("\t")
39
+ end
40
+ end
41
+
@@ -0,0 +1,12 @@
1
+ # Please require your code below, respecting the naming conventions in the
2
+ # bioruby directory tree.
3
+ #
4
+ # For example, say you have a plugin named bio-plugin, the only uncommented
5
+ # line in this file would be
6
+ #
7
+ # require 'bio/bio-plugin/plugin'
8
+ #
9
+ # In this file only require other files. Avoid other source code.
10
+
11
+ require 'bio-blat-tools/blat-tools.rb'
12
+
@@ -0,0 +1,55 @@
1
+ require 'bio'
2
+
3
+ module Bio
4
+ class Blat
5
+ class StreamedReport < Report
6
+
7
+ def self.each_hit(text = '')
8
+ flag = false
9
+ head = []
10
+
11
+ text.each_line do |line|
12
+ if flag then
13
+ yield Hit.new(line)
14
+ else
15
+
16
+ if /^\d/ =~ line then # for headerless data
17
+ flag = true
18
+ redo
19
+ end
20
+ line = line.chomp
21
+ if /\A\-+\s*\z/ =~ line
22
+ flag = true
23
+ else
24
+ head << line
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+
31
+ def self.each_best_hit(text = '')
32
+
33
+ best_aln = Hash.new
34
+ self.each_hit(text) do |hit|
35
+ current_matches = hit.match
36
+ current_name = hit.query_id
37
+ current_identity = hit.percent_identity
38
+ current_score = hit.score
39
+ best_aln[current_name] = hit if best_aln[current_name] == nil or current_score > best_aln[current_name] .score
40
+ end
41
+ best_aln.each_value { |val| yield val }
42
+ end
43
+ end
44
+
45
+
46
+ end
47
+ end
48
+
49
+ class Bio::Blat::Report::Hit
50
+
51
+ def percentage_covered
52
+ ( match + mismatch ) * 100.0 / query_len.to_f
53
+ end
54
+
55
+ end
@@ -0,0 +1,34 @@
1
+ require 'simplecov'
2
+
3
+ module SimpleCov::Configuration
4
+ def clean_filters
5
+ @filters = []
6
+ end
7
+ end
8
+
9
+ SimpleCov.configure do
10
+ clean_filters
11
+ load_adapter 'test_frameworks'
12
+ end
13
+
14
+ ENV["COVERAGE"] && SimpleCov.start do
15
+ add_filter "/.rvm/"
16
+ end
17
+ require 'rubygems'
18
+ require 'bundler'
19
+ begin
20
+ Bundler.setup(:default, :development)
21
+ rescue Bundler::BundlerError => e
22
+ $stderr.puts e.message
23
+ $stderr.puts "Run `bundle install` to install missing gems"
24
+ exit e.status_code
25
+ end
26
+ require 'test/unit'
27
+ require 'shoulda'
28
+
29
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
30
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
31
+ require 'bio-blat-tools'
32
+
33
+ class Test::Unit::TestCase
34
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestBioBlatTools < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-blat-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - homonecloco
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: shoulda
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.0.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.0.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0.21
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0.21
83
+ - !ruby/object:Gem::Dependency
84
+ name: bio
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.4.3
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.4.3
97
+ description: |-
98
+ Tools to manipulate blat files from the command line. Uses the Bio::Blat object from BioRuby, but the parser has been modified to avoid reading the whole psl file, it yields just the current entry and it is up to the consumer to decide to store it or not."
99
+ s.email = "ricardo.ramirez-gonzalez@tgac.ac.uk"
100
+ email: ricardo.ramirez-gonzalez@tgac.ac.uk
101
+ executables:
102
+ - best_blat_hit.rb
103
+ - filter_blat.rb
104
+ extensions: []
105
+ extra_rdoc_files:
106
+ - LICENSE.txt
107
+ - README.md
108
+ - README.rdoc
109
+ files:
110
+ - ".document"
111
+ - ".travis.yml"
112
+ - Gemfile
113
+ - LICENSE.txt
114
+ - README.md
115
+ - README.rdoc
116
+ - Rakefile
117
+ - VERSION
118
+ - bin/best_blat_hit.rb
119
+ - bin/filter_blat.rb
120
+ - lib/bio-blat-tools.rb
121
+ - lib/bio-blat-tools/blat-tools.rb
122
+ - test/helper.rb
123
+ - test/test_bio-blat-tools.rb
124
+ homepage: http://github.com/homonecloco/bioruby-blat-tools
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.2.1
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Tools to manipulate blat files from the command line.
148
+ test_files: []