bio-ucsc-api 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. data/ChangeLog.md +3 -0
  2. data/Gemfile +6 -6
  3. data/Gemfile.lock +59 -30
  4. data/README.md +17 -13
  5. data/VERSION +1 -1
  6. data/bio-ucsc-api.gemspec +40 -45
  7. data/lib/bio-ucsc.rb +4 -3
  8. data/lib/bio-ucsc/drosim1.rb +1 -1
  9. data/lib/bio-ucsc/galgal4.rb +65 -0
  10. data/lib/bio-ucsc/hgfixed.rb +0 -1
  11. data/lib/bio-ucsc/rn5.rb +66 -0
  12. data/lib/bio-ucsc/rn5/chaincanfam2.rb +82 -0
  13. data/lib/bio-ucsc/{galgal3/chainmm9link.rb → rn5/chaincanfam2link.rb} +7 -9
  14. data/lib/bio-ucsc/{galgal3 → rn5}/chaincavpor3.rb +3 -6
  15. data/lib/bio-ucsc/rn5/chaincavpor3link.rb +81 -0
  16. data/lib/bio-ucsc/{galgal3 → rn5}/chaindanrer4.rb +3 -6
  17. data/lib/bio-ucsc/rn5/chaindanrer4link.rb +81 -0
  18. data/lib/bio-ucsc/rn5/chainequcab1.rb +81 -0
  19. data/lib/bio-ucsc/rn5/chainequcab1link.rb +81 -0
  20. data/lib/bio-ucsc/rn5/chaingalgal3.rb +81 -0
  21. data/lib/bio-ucsc/rn5/chaingalgal3link.rb +81 -0
  22. data/lib/bio-ucsc/{galgal3 → rn5}/chainmm9.rb +3 -6
  23. data/lib/bio-ucsc/rn5/chainmm9link.rb +81 -0
  24. data/lib/bio-ucsc/rn5/chainmondom4.rb +81 -0
  25. data/lib/bio-ucsc/rn5/chainmondom4link.rb +81 -0
  26. data/lib/bio-ucsc/{galgal3/chainfr2link.rb → rn5/chainpantro2.rb} +5 -8
  27. data/lib/bio-ucsc/{galgal3/chainrn4.rb → rn5/chainpantro2link.rb} +6 -8
  28. data/lib/bio-ucsc/rn5/chainrhemac2.rb +81 -0
  29. data/lib/bio-ucsc/rn5/chainrhemac2link.rb +81 -0
  30. data/lib/bio-ucsc/{galgal3 → rn5}/est.rb +2 -5
  31. data/lib/bio-ucsc/{galgal3 → rn5}/gap.rb +2 -5
  32. data/lib/bio-ucsc/{galgal3 → rn5}/gold.rb +2 -5
  33. data/lib/bio-ucsc/{galgal3 → rn5}/intronest.rb +2 -5
  34. data/lib/bio-ucsc/{galgal3 → rn5}/mrna.rb +2 -5
  35. data/lib/bio-ucsc/{galgal3 → rn5}/rmsk.rb +2 -5
  36. data/lib/bio-ucsc/taegut1/chaingalgal3.rb +1 -1
  37. data/lib/bio-ucsc/taegut1/chaingalgal3link.rb +1 -1
  38. data/lib/bio-ucsc/visigene.rb +0 -1
  39. metadata +55 -60
  40. data/lib/bio-ucsc/galgal3.rb +0 -56
  41. data/lib/bio-ucsc/galgal3/chainanocar1.rb +0 -84
  42. data/lib/bio-ucsc/galgal3/chainanocar1link.rb +0 -84
  43. data/lib/bio-ucsc/galgal3/chainbraflo1.rb +0 -84
  44. data/lib/bio-ucsc/galgal3/chainbraflo1link.rb +0 -84
  45. data/lib/bio-ucsc/galgal3/chaincavpor3link.rb +0 -84
  46. data/lib/bio-ucsc/galgal3/chaindanrer4link.rb +0 -84
  47. data/lib/bio-ucsc/galgal3/chainfr2.rb +0 -84
  48. data/lib/bio-ucsc/galgal3/chaingasacu1.rb +0 -84
  49. data/lib/bio-ucsc/galgal3/chaingasacu1link.rb +0 -84
  50. data/lib/bio-ucsc/galgal3/chainornana1.rb +0 -84
  51. data/lib/bio-ucsc/galgal3/chainornana1link.rb +0 -84
  52. data/lib/bio-ucsc/galgal3/chainpetmar1.rb +0 -84
  53. data/lib/bio-ucsc/galgal3/chainpetmar1link.rb +0 -84
  54. data/lib/bio-ucsc/galgal3/chainrn4link.rb +0 -84
  55. data/lib/bio-ucsc/galgal3/chaintaegut1.rb +0 -84
  56. data/lib/bio-ucsc/galgal3/chaintaegut1link.rb +0 -84
  57. data/lib/bio-ucsc/galgal3/chainxentro2.rb +0 -84
  58. data/lib/bio-ucsc/galgal3/chainxentro2link.rb +0 -84
@@ -6,7 +6,6 @@
6
6
  # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
7
  #
8
8
 
9
- require "#{::File.dirname(__FILE__)}/db_connector"
10
9
  require "#{::File.dirname(__FILE__)}/table_class_detector"
11
10
 
12
11
  module Bio
@@ -0,0 +1,66 @@
1
+ #
2
+ # = AUTOMATIC Table Definition of the Rat Rn5 assembly
3
+ # Copyright:: Copyright (C) 2011, 2012, 2013
4
+ # MISHIMA, Hiroyuki
5
+ # <missy at be.to / hmishima at nagasaki-u.ac.jp>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+
9
+ require "#{::File.dirname(__FILE__)}/table_class_detector"
10
+
11
+ module Bio
12
+ module Ucsc
13
+ module Rn5
14
+ CHROMS =
15
+ %w(chrM chr1 chr2 chr3 chr4 chr5 chr6 chr7 chr8 chr9 chr10
16
+ chr11 chr12 chr13 chr14 chr15 chr16 chr17 chr18 chr19 chr20
17
+ chrX)
18
+ extend TableClassDetector
19
+
20
+ def self.default
21
+ DBConnection.default
22
+ end
23
+
24
+ def self.connect(param = Hash.new)
25
+ DBConnection.db_adapter = param[:db_adapter] if param[:db_adapter]
26
+ DBConnection.db_host = param[:db_host] if param[:db_host]
27
+ DBConnection.db_username = param[:db_username] if param[:db_username]
28
+ DBConnection.password = param[:password] if param[:password]
29
+ DBConnection.connect
30
+ end
31
+
32
+ class DBConnection < ActiveRecord::Base
33
+ include SafeAttributes
34
+ self.inheritance_column = 'dummy_not_to_use'
35
+
36
+ @@db_adapter ||= 'mysql'
37
+ @@db_host ||= 'genome-mysql.cse.ucsc.edu'
38
+ @@db_username ||= 'genome'
39
+ @@db_password ||= ''
40
+ @@db_name ||= 'rn5'
41
+
42
+ cattr_accessor :db_adapter, :db_host, :db_username, :db_password
43
+
44
+ self.abstract_class = true
45
+
46
+ def self.default
47
+ @@db_adapter = 'mysql'
48
+ @@db_host = 'genome-mysql.cse.ucsc.edu'
49
+ @@db_username = 'genome'
50
+ @@db_password = ''
51
+ end
52
+
53
+ def self.connect
54
+ establish_connection({ :adapter => @@db_adapter,
55
+ :host => @@db_host,
56
+ :database => @@db_name,
57
+ :username => @@db_username,
58
+ :password => @@db_password, })
59
+ end
60
+ end # class DBConnection
61
+
62
+ base = "#{::File.dirname(__FILE__)}/rn4"
63
+ #
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,82 @@
1
+ # = chaincanfam2.rb
2
+ # Copyright::
3
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
4
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
5
+ #
6
+ # In the hg18 database, this table is actually separated
7
+ # into "chr1_*", "chr2_*", etc. This class dynamically
8
+ # define *::Chr1_*, *::Chr2_*, etc. The
9
+ # Rmsk.find_by_interval calls an appropreate class automatically.
10
+
11
+ module Bio
12
+ module Ucsc
13
+ module Rn4
14
+
15
+ class ChainCanFam2
16
+ KLASS = "ChainCanFam2"
17
+ KLASS_S = "chainCanFam2"
18
+
19
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
20
+ class_eval %!
21
+ class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
22
+ self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
23
+ self.primary_key = nil
24
+ self.inheritance_column = nil
25
+
26
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
27
+ find_first_or_all_by_interval(interval, :first, opt)
28
+ end
29
+
30
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
31
+ find_first_or_all_by_interval(interval, :all, opt)
32
+ end
33
+
34
+ def self.find_first_or_all_by_interval(interval, first_all, opt); interval = Bio::Ucsc::Gi.wrap(interval)
35
+ zstart = interval.zero_start
36
+ zend = interval.zero_end
37
+ if opt[:partial] == true
38
+ where = <<-SQL
39
+ tName = :chrom
40
+ AND bin in (:bins)
41
+ AND ((tStart BETWEEN :zstart AND :zend)
42
+ OR (tEnd BETWEEN :zstart AND :zend)
43
+ OR (tStart <= :zstart AND tEnd >= :zend))
44
+ SQL
45
+ else
46
+ where = <<-SQL
47
+ tName = :chrom
48
+ AND bin in (:bins)
49
+ AND ((tStart BETWEEN :zstart AND :zend)
50
+ AND (tEnd BETWEEN :zstart AND :zend))
51
+ SQL
52
+ end
53
+ cond = {
54
+ :chrom => interval.chrom,
55
+ :bins => Bio::Ucsc::UcscBin.bin_all(zstart, zend),
56
+ :zstart => zstart,
57
+ :zend => zend,
58
+ }
59
+ self.find(first_all,
60
+ { :select => "*",
61
+ :conditions => [where, cond], })
62
+ end
63
+ end
64
+ !
65
+ end # each chromosome
66
+
67
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
68
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
69
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
70
+ chr_klass.__send__(:find_by_interval, interval, opt)
71
+ end
72
+
73
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
74
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
75
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
76
+ chr_klass.__send__(:find_all_by_interval, interval, opt)
77
+ end
78
+ end # class
79
+
80
+ end # module Hg18
81
+ end # module Ucsc
82
+ end # module Bio
@@ -1,3 +1,4 @@
1
+ # = chainbraflo1link.rb
1
2
  # Copyright::
2
3
  # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
3
4
  # License:: The Ruby licence (Ryby's / GPLv2 dual)
@@ -9,16 +10,13 @@
9
10
 
10
11
  module Bio
11
12
  module Ucsc
12
- module GalGal3
13
+ module Rn4
13
14
 
14
- class ChainMm9Link
15
- include DBConnector
16
- DBConnection.database "galGal3"
15
+ class ChainCanFam2Link
16
+ KLASS = "ChainCanFam2Link"
17
+ KLASS_S = "chainCanFam2Link"
17
18
 
18
- KLASS = "ChainMm9Link"
19
- KLASS_S = KLASS[0..0].downcase + KLASS[1..-1]
20
-
21
- Bio::Ucsc::GalGal3::CHROMS.each do |chr|
19
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
22
20
  class_eval %!
23
21
  class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
24
22
  self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
@@ -73,7 +71,7 @@ AND (tEnd BETWEEN :zstart AND :zend))
73
71
  end
74
72
 
75
73
  def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
76
- chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
74
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
77
75
  chr_klass = self.const_get("#{chrom}_#{KLASS}")
78
76
  chr_klass.__send__(:find_all_by_interval, interval, opt)
79
77
  end
@@ -9,16 +9,13 @@
9
9
 
10
10
  module Bio
11
11
  module Ucsc
12
- module GalGal3
12
+ module Rn4
13
13
 
14
14
  class ChainCavPor3
15
- include DBConnector
16
- DBConnection.database "galGal3"
17
-
18
15
  KLASS = "ChainCavPor3"
19
- KLASS_S = KLASS[0..0].downcase + KLASS[1..-1]
16
+ KLASS_S = "chainCavPor3"
20
17
 
21
- Bio::Ucsc::GalGal3::CHROMS.each do |chr|
18
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
22
19
  class_eval %!
23
20
  class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
24
21
  self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
@@ -0,0 +1,81 @@
1
+ # Copyright::
2
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
3
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
4
+ #
5
+ # In the hg18 database, this table is actually separated
6
+ # into "chr1_*", "chr2_*", etc. This class dynamically
7
+ # define *::Chr1_*, *::Chr2_*, etc. The
8
+ # Rmsk.find_by_interval calls an appropreate class automatically.
9
+
10
+ module Bio
11
+ module Ucsc
12
+ module Rn4
13
+
14
+ class ChainCavPor3Link
15
+ KLASS = "ChainCavPor3Link"
16
+ KLASS_S = "chainCavPor3Link"
17
+
18
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
19
+ class_eval %!
20
+ class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
21
+ self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
22
+ self.primary_key = nil
23
+ self.inheritance_column = nil
24
+
25
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
26
+ find_first_or_all_by_interval(interval, :first, opt)
27
+ end
28
+
29
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
30
+ find_first_or_all_by_interval(interval, :all, opt)
31
+ end
32
+
33
+ def self.find_first_or_all_by_interval(interval, first_all, opt); interval = Bio::Ucsc::Gi.wrap(interval)
34
+ zstart = interval.zero_start
35
+ zend = interval.zero_end
36
+ if opt[:partial] == true
37
+ where = <<-SQL
38
+ tName = :chrom
39
+ AND bin in (:bins)
40
+ AND ((tStart BETWEEN :zstart AND :zend)
41
+ OR (tEnd BETWEEN :zstart AND :zend)
42
+ OR (tStart <= :zstart AND tEnd >= :zend))
43
+ SQL
44
+ else
45
+ where = <<-SQL
46
+ tName = :chrom
47
+ AND bin in (:bins)
48
+ AND ((tStart BETWEEN :zstart AND :zend)
49
+ AND (tEnd BETWEEN :zstart AND :zend))
50
+ SQL
51
+ end
52
+ cond = {
53
+ :chrom => interval.chrom,
54
+ :bins => Bio::Ucsc::UcscBin.bin_all(zstart, zend),
55
+ :zstart => zstart,
56
+ :zend => zend,
57
+ }
58
+ self.find(first_all,
59
+ { :select => "*",
60
+ :conditions => [where, cond], })
61
+ end
62
+ end
63
+ !
64
+ end # each chromosome
65
+
66
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
67
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
68
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
69
+ chr_klass.__send__(:find_by_interval, interval, opt)
70
+ end
71
+
72
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
73
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
74
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
75
+ chr_klass.__send__(:find_all_by_interval, interval, opt)
76
+ end
77
+ end # class
78
+
79
+ end # module Hg18
80
+ end # module Ucsc
81
+ end # module Bio
@@ -9,16 +9,13 @@
9
9
 
10
10
  module Bio
11
11
  module Ucsc
12
- module GalGal3
12
+ module Rn4
13
13
 
14
14
  class ChainDanRer4
15
- include DBConnector
16
- DBConnection.database "galGal3"
17
-
18
15
  KLASS = "ChainDanRer4"
19
- KLASS_S = KLASS[0..0].downcase + KLASS[1..-1]
16
+ KLASS_S = "chainDanRer4"
20
17
 
21
- Bio::Ucsc::GalGal3::CHROMS.each do |chr|
18
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
22
19
  class_eval %!
23
20
  class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
24
21
  self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
@@ -0,0 +1,81 @@
1
+ # Copyright::
2
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
3
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
4
+ #
5
+ # In the hg18 database, this table is actually separated
6
+ # into "chr1_*", "chr2_*", etc. This class dynamically
7
+ # define *::Chr1_*, *::Chr2_*, etc. The
8
+ # Rmsk.find_by_interval calls an appropreate class automatically.
9
+
10
+ module Bio
11
+ module Ucsc
12
+ module Rn4
13
+
14
+ class ChainDanRer4Link
15
+ KLASS = "ChainDanRer4Link"
16
+ KLASS_S = "chainDanRer4Link"
17
+
18
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
19
+ class_eval %!
20
+ class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
21
+ self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
22
+ self.primary_key = nil
23
+ self.inheritance_column = nil
24
+
25
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
26
+ find_first_or_all_by_interval(interval, :first, opt)
27
+ end
28
+
29
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
30
+ find_first_or_all_by_interval(interval, :all, opt)
31
+ end
32
+
33
+ def self.find_first_or_all_by_interval(interval, first_all, opt); interval = Bio::Ucsc::Gi.wrap(interval)
34
+ zstart = interval.zero_start
35
+ zend = interval.zero_end
36
+ if opt[:partial] == true
37
+ where = <<-SQL
38
+ tName = :chrom
39
+ AND bin in (:bins)
40
+ AND ((tStart BETWEEN :zstart AND :zend)
41
+ OR (tEnd BETWEEN :zstart AND :zend)
42
+ OR (tStart <= :zstart AND tEnd >= :zend))
43
+ SQL
44
+ else
45
+ where = <<-SQL
46
+ tName = :chrom
47
+ AND bin in (:bins)
48
+ AND ((tStart BETWEEN :zstart AND :zend)
49
+ AND (tEnd BETWEEN :zstart AND :zend))
50
+ SQL
51
+ end
52
+ cond = {
53
+ :chrom => interval.chrom,
54
+ :bins => Bio::Ucsc::UcscBin.bin_all(zstart, zend),
55
+ :zstart => zstart,
56
+ :zend => zend,
57
+ }
58
+ self.find(first_all,
59
+ { :select => "*",
60
+ :conditions => [where, cond], })
61
+ end
62
+ end
63
+ !
64
+ end # each chromosome
65
+
66
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
67
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
68
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
69
+ chr_klass.__send__(:find_by_interval, interval, opt)
70
+ end
71
+
72
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
73
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
74
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
75
+ chr_klass.__send__(:find_all_by_interval, interval, opt)
76
+ end
77
+ end # class
78
+
79
+ end # module Hg18
80
+ end # module Ucsc
81
+ end # module Bio
@@ -0,0 +1,81 @@
1
+ # Copyright::
2
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
3
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
4
+ #
5
+ # In the hg18 database, this table is actually separated
6
+ # into "chr1_*", "chr2_*", etc. This class dynamically
7
+ # define *::Chr1_*, *::Chr2_*, etc. The
8
+ # Rmsk.find_by_interval calls an appropreate class automatically.
9
+
10
+ module Bio
11
+ module Ucsc
12
+ module Rn4
13
+
14
+ class ChainEquCab1
15
+ KLASS = "ChainEquCab1"
16
+ KLASS_S = "chainEquCab1"
17
+
18
+ Bio::Ucsc::Rn4::CHROMS.each do |chr|
19
+ class_eval %!
20
+ class #{chr[0..0].upcase + chr[1..-1]}_#{KLASS} < DBConnection
21
+ self.table_name = "#{chr[0..0].downcase + chr[1..-1]}_#{KLASS_S}"
22
+ self.primary_key = nil
23
+ self.inheritance_column = nil
24
+
25
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
26
+ find_first_or_all_by_interval(interval, :first, opt)
27
+ end
28
+
29
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
30
+ find_first_or_all_by_interval(interval, :all, opt)
31
+ end
32
+
33
+ def self.find_first_or_all_by_interval(interval, first_all, opt); interval = Bio::Ucsc::Gi.wrap(interval)
34
+ zstart = interval.zero_start
35
+ zend = interval.zero_end
36
+ if opt[:partial] == true
37
+ where = <<-SQL
38
+ tName = :chrom
39
+ AND bin in (:bins)
40
+ AND ((tStart BETWEEN :zstart AND :zend)
41
+ OR (tEnd BETWEEN :zstart AND :zend)
42
+ OR (tStart <= :zstart AND tEnd >= :zend))
43
+ SQL
44
+ else
45
+ where = <<-SQL
46
+ tName = :chrom
47
+ AND bin in (:bins)
48
+ AND ((tStart BETWEEN :zstart AND :zend)
49
+ AND (tEnd BETWEEN :zstart AND :zend))
50
+ SQL
51
+ end
52
+ cond = {
53
+ :chrom => interval.chrom,
54
+ :bins => Bio::Ucsc::UcscBin.bin_all(zstart, zend),
55
+ :zstart => zstart,
56
+ :zend => zend,
57
+ }
58
+ self.find(first_all,
59
+ { :select => "*",
60
+ :conditions => [where, cond], })
61
+ end
62
+ end
63
+ !
64
+ end # each chromosome
65
+
66
+ def self.find_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
67
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
68
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
69
+ chr_klass.__send__(:find_by_interval, interval, opt)
70
+ end
71
+
72
+ def self.find_all_by_interval(interval, opt = {:partial => true}); interval = Bio::Ucsc::Gi.wrap(interval)
73
+ chrom = interval.chrom[0..0].upcase + interval.chrom[1..-1]
74
+ chr_klass = self.const_get("#{chrom}_#{KLASS}")
75
+ chr_klass.__send__(:find_all_by_interval, interval, opt)
76
+ end
77
+ end # class
78
+
79
+ end # module Hg18
80
+ end # module Ucsc
81
+ end # module Bio