UCSCBin 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/LICENSE +21 -0
  2. data/README.rdoc +46 -0
  3. data/Rakefile +51 -0
  4. data/UCSCBin.gemspec +92 -0
  5. data/VERSION +1 -0
  6. data/lib/UCSCBin.rb +144 -0
  7. data/rdoc/README_rdoc.html +170 -0
  8. data/rdoc/UCSCBin.html +185 -0
  9. data/rdoc/UCSCBin/BinRange.html +454 -0
  10. data/rdoc/UCSCBin/Utils.html +242 -0
  11. data/rdoc/created.rid +1 -0
  12. data/rdoc/images/brick.png +0 -0
  13. data/rdoc/images/brick_link.png +0 -0
  14. data/rdoc/images/bug.png +0 -0
  15. data/rdoc/images/bullet_black.png +0 -0
  16. data/rdoc/images/bullet_toggle_minus.png +0 -0
  17. data/rdoc/images/bullet_toggle_plus.png +0 -0
  18. data/rdoc/images/date.png +0 -0
  19. data/rdoc/images/find.png +0 -0
  20. data/rdoc/images/loadingAnimation.gif +0 -0
  21. data/rdoc/images/macFFBgHack.png +0 -0
  22. data/rdoc/images/package.png +0 -0
  23. data/rdoc/images/page_green.png +0 -0
  24. data/rdoc/images/page_white_text.png +0 -0
  25. data/rdoc/images/page_white_width.png +0 -0
  26. data/rdoc/images/plugin.png +0 -0
  27. data/rdoc/images/ruby.png +0 -0
  28. data/rdoc/images/tag_green.png +0 -0
  29. data/rdoc/images/wrench.png +0 -0
  30. data/rdoc/images/wrench_orange.png +0 -0
  31. data/rdoc/images/zoom.png +0 -0
  32. data/rdoc/index.html +79 -0
  33. data/rdoc/js/darkfish.js +116 -0
  34. data/rdoc/js/jquery.js +32 -0
  35. data/rdoc/js/quicksearch.js +114 -0
  36. data/rdoc/js/thickbox-compressed.js +10 -0
  37. data/rdoc/lib/UCSCBin_rb.html +82 -0
  38. data/rdoc/rdoc.css +696 -0
  39. data/sample/refseqgene.rb +35 -0
  40. data/spec/UCSCBin_BinRange_spec.rb +47 -0
  41. data/spec/UCSCBin_Utils_spec.rb +49 -0
  42. data/spec/spec.opts +1 -0
  43. data/spec/spec_helper.rb +9 -0
  44. metadata +132 -0
@@ -0,0 +1,35 @@
1
+ #!/usr/local/bin/ruby
2
+ #
3
+ # = refseqgene.rb, an UCSCBin sample
4
+ # Author:: Hiroyuki Mishima ( missy at be.to / hmishima at nagasaki-u.ac.jp )
5
+ # Copyright:: Hiroyuki Mishima, 2010
6
+ # Licence:: the MIT/X11 licence. See the LICENCE file.
7
+ # Usage:: refseqgene chr1:12345-23456
8
+ #
9
+
10
+ DB_URL = "mysql://genome:@genome-mysql.cse.ucsc.edu/hg18"
11
+
12
+ require 'rubygems'
13
+ require 'UCSCBin'
14
+ require 'sequel'
15
+
16
+ chr, one_start, one_end = ARGV[0].chomp.split(/:|-/)
17
+
18
+ zero_start, zero_end =
19
+ UCSCBin::Utils.one_to_zero(one_start.to_i, one_end.to_i)
20
+ bins = UCSCBin::BinRange.bin_all(zero_start, zero_end)
21
+
22
+ db = Sequel.connect(DB_URL)
23
+ dset = db[:refGene].select(:name2)
24
+ dset = dset.filter(:chrom => chr)
25
+ dset = dset.filter(:bin => bins)
26
+ dset = dset.exclude do |o|
27
+ ((o.txStart < zero_start) & (o.txEnd < zero_start)) |
28
+ ((o.txStart > zero_end) & (o.txEnd > zero_end))
29
+ end
30
+
31
+ genes = dset.all.map{|hit| hit[:name2]}.uniq
32
+ genes = ["no hit"] if genes.empty?
33
+
34
+ puts "#{chr}:#{one_start}-#{one_end}\t#{genes.join("; ")}"
35
+
@@ -0,0 +1,47 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ ##
4
+ ## UCSCBin::Utils
5
+ ##
6
+
7
+ describe UCSCBin::Utils, "#zero_to_one" do
8
+ it "(0, 10) should return an array [1, 10]" do
9
+ UCSCBin::Utils.zero_to_one(0 , 10).should == [1, 10]
10
+ end
11
+
12
+ it "(-1, 10) should raise ArgumentError" do
13
+ caller = lambda{UCSCBin::Utils.zero_to_one(-1, 10)}
14
+ caller.should raise_error(ArgumentError)
15
+ end
16
+
17
+ it "(10, 1) should raise ArgumentError" do
18
+ caller = lambda{UCSCBin::Utils.zero_to_one(10, 1)}
19
+ caller.should raise_error(ArgumentError)
20
+ end
21
+
22
+ it "(0, 0) should raise ArgumentError" do
23
+ caller = lambda{UCSCBin::Utils.zero_to_one(10, 1)}
24
+ caller.should raise_error(ArgumentError)
25
+ end
26
+ end
27
+
28
+ describe UCSCBin::Utils, "#one_to_zero" do
29
+ it "(1, 10) should return an array [0, 10]" do
30
+ UCSCBin::Utils.one_to_zero(1, 10).should == [0, 10]
31
+ end
32
+
33
+ it "(-1, 10) should raise ArgumentError" do
34
+ caller = lambda{UCSCBin::Utils.one_to_zero(-1, 10)}
35
+ caller.should raise_error(ArgumentError)
36
+ end
37
+
38
+ it "(0, 10) should raise ArgumentError" do
39
+ caller = lambda{UCSCBin::Utils.one_to_zero(0, 10)}
40
+ caller.should raise_error(ArgumentError)
41
+ end
42
+
43
+ it "(10, 1) should raise ArgumentError" do
44
+ caller = lambda{UCSCBin::Utils.one_to_zero(0, 10)}
45
+ caller.should raise_error(ArgumentError)
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ ##
4
+ ## UCSCBin::BinRange
5
+ ##
6
+
7
+ describe UCSCBin::BinRange, "#bin" do
8
+ it "(20,000,000-20,000,999) should be 737" do
9
+ bin_start = 20_000_000
10
+ bin_end = 20_000_999
11
+ UCSCBin::BinRange.bin(bin_start, bin_end).should == 737
12
+ end
13
+
14
+ it "(2,000,000,000-9,000,000,100) should raise exception" do
15
+ bin_start = 2_000_000_000
16
+ bin_end = 9_000_000_100
17
+ caller = lambda{UCSCBin::BinRange.bin(bin_start, bin_end)}
18
+ caller.should raise_error(NotImplementedError)
19
+ end
20
+ end
21
+
22
+ describe UCSCBin::BinRange, "#bin_all" do
23
+ it "(20,000,000-20,000,999) should be all bins" do
24
+ bin_start = 20_000_000
25
+ bin_end = 20_000_999
26
+ UCSCBin::BinRange.bin_all(bin_start, bin_end).should == [737, 92, 11, 1 ,0]
27
+ end
28
+
29
+ it "(2,000,000,000-9,000,000,100) should raise exception" do
30
+ bin_start = 2_000_000_000
31
+ bin_end = 9_000_000_100
32
+ caller = lambda{UCSCBin::BinRange.bin_all(bin_start, bin_end)}
33
+ caller.should raise_error(NotImplementedError)
34
+ end
35
+
36
+ it "(20,000,000-20,100,999) should be an array of BINs" do
37
+ bin_start = 20_000_000
38
+ bin_end = 20_100_999
39
+ UCSCBin::BinRange.bin_all(bin_start, bin_end).should == [737,738,92, 11, 1, 0]
40
+ end
41
+
42
+ it "(20,000,000-21,000,999) should be an array of BINs" do
43
+ bin_start = 20_000_000
44
+ bin_end = 21_000_999
45
+ UCSCBin::BinRange.bin_all(bin_start, bin_end).should ==
46
+ [737, 738, 739, 740, 741, 742, 743, 744, 745, 92, 93, 11, 1, 0]
47
+ end
48
+ end
49
+
@@ -0,0 +1 @@
1
+ --color
@@ -0,0 +1,9 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'UCSCBin'
4
+ require 'spec'
5
+ require 'spec/autorun'
6
+
7
+ Spec::Runner.configure do |config|
8
+
9
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: UCSCBin
3
+ version: !ruby/object:Gem::Version
4
+ hash: -2481588639819700252
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
+ platform: ruby
12
+ authors:
13
+ - Hiroyuki MISHIMA
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-10-28 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: -1730125512753482917
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: |-
38
+ Utilities for UCSC Bioinfomatics's Genome Browser
39
+ ( http://g enome.ucsc.edu ) including calculation of a BIN index
40
+ from a genomic interval to speed-up SQL queries, and conversion
41
+ between 1-based full-closed (for humans) and 0-based half-open
42
+ (for machienes) intervals
43
+ email: missy@be.to
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - LICENSE
50
+ - README.rdoc
51
+ files:
52
+ - LICENSE
53
+ - README.rdoc
54
+ - Rakefile
55
+ - UCSCBin.gemspec
56
+ - VERSION
57
+ - lib/UCSCBin.rb
58
+ - rdoc/README_rdoc.html
59
+ - rdoc/UCSCBin.html
60
+ - rdoc/UCSCBin/BinRange.html
61
+ - rdoc/UCSCBin/Utils.html
62
+ - rdoc/created.rid
63
+ - rdoc/images/brick.png
64
+ - rdoc/images/brick_link.png
65
+ - rdoc/images/bug.png
66
+ - rdoc/images/bullet_black.png
67
+ - rdoc/images/bullet_toggle_minus.png
68
+ - rdoc/images/bullet_toggle_plus.png
69
+ - rdoc/images/date.png
70
+ - rdoc/images/find.png
71
+ - rdoc/images/loadingAnimation.gif
72
+ - rdoc/images/macFFBgHack.png
73
+ - rdoc/images/package.png
74
+ - rdoc/images/page_green.png
75
+ - rdoc/images/page_white_text.png
76
+ - rdoc/images/page_white_width.png
77
+ - rdoc/images/plugin.png
78
+ - rdoc/images/ruby.png
79
+ - rdoc/images/tag_green.png
80
+ - rdoc/images/wrench.png
81
+ - rdoc/images/wrench_orange.png
82
+ - rdoc/images/zoom.png
83
+ - rdoc/index.html
84
+ - rdoc/js/darkfish.js
85
+ - rdoc/js/jquery.js
86
+ - rdoc/js/quicksearch.js
87
+ - rdoc/js/thickbox-compressed.js
88
+ - rdoc/lib/UCSCBin_rb.html
89
+ - rdoc/rdoc.css
90
+ - sample/refseqgene.rb
91
+ - spec/UCSCBin_BinRange_spec.rb
92
+ - spec/UCSCBin_Utils_spec.rb
93
+ - spec/spec.opts
94
+ - spec/spec_helper.rb
95
+ has_rdoc: true
96
+ homepage: http://github.com/misshie/UCSCBin
97
+ licenses: []
98
+
99
+ post_install_message:
100
+ rdoc_options:
101
+ - --charset=UTF-8
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: -1944775192741746749
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: -1944775192741746749
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ requirements: []
123
+
124
+ rubyforge_project:
125
+ rubygems_version: 1.3.7
126
+ signing_key:
127
+ specification_version: 3
128
+ summary: Calculate BIN indexes on UCSC Bioinformatics's Genome Browser
129
+ test_files:
130
+ - spec/UCSCBin_Utils_spec.rb
131
+ - spec/spec_helper.rb
132
+ - spec/UCSCBin_BinRange_spec.rb