bio-ucsc-api 0.0.1

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 (101) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/COPYING +58 -0
  4. data/COPYING.ja +51 -0
  5. data/Gemfile +19 -0
  6. data/Gemfile.lock +49 -0
  7. data/README.rdoc +57 -0
  8. data/Rakefile +72 -0
  9. data/VERSION +1 -0
  10. data/bio-ucsc-api.gemspec +212 -0
  11. data/lib/bio-ucsc.rb +20 -0
  12. data/lib/bio-ucsc/hg18.rb +27 -0
  13. data/lib/bio-ucsc/hg18/activerecord.rb +166 -0
  14. data/lib/bio-ucsc/hg18/cnpiafrate2.rb +31 -0
  15. data/lib/bio-ucsc/hg18/cnplocke.rb +31 -0
  16. data/lib/bio-ucsc/hg18/cnpredon.rb +32 -0
  17. data/lib/bio-ucsc/hg18/cnpsebat2.rb +35 -0
  18. data/lib/bio-ucsc/hg18/cnpsharp2.rb +32 -0
  19. data/lib/bio-ucsc/hg18/db_connection.rb +61 -0
  20. data/lib/bio-ucsc/hg18/dgv.rb +27 -0
  21. data/lib/bio-ucsc/hg18/refgene.rb +27 -0
  22. data/lib/bio-ucsc/hg18/rmsk.rb +51 -0
  23. data/lib/bio-ucsc/hg18/tables.rb +142 -0
  24. data/lib/bio-ucsc/hg19.rb +54 -0
  25. data/lib/bio-ucsc/hg19/activerecord.rb +217 -0
  26. data/lib/bio-ucsc/hg19/ccdsgene.rb +33 -0
  27. data/lib/bio-ucsc/hg19/cytoband.rb +33 -0
  28. data/lib/bio-ucsc/hg19/db_connection.rb +61 -0
  29. data/lib/bio-ucsc/hg19/dgv.rb +27 -0
  30. data/lib/bio-ucsc/hg19/ensgene.rb +21 -0
  31. data/lib/bio-ucsc/hg19/gwascatalog.rb +26 -0
  32. data/lib/bio-ucsc/hg19/hapmapalleleschimp.rb +35 -0
  33. data/lib/bio-ucsc/hg19/hapmapallelesmacaque.rb +35 -0
  34. data/lib/bio-ucsc/hg19/hapmapsnpsasw.rb +33 -0
  35. data/lib/bio-ucsc/hg19/hapmapsnpsceu.rb +33 -0
  36. data/lib/bio-ucsc/hg19/hapmapsnpschb.rb +33 -0
  37. data/lib/bio-ucsc/hg19/hapmapsnpschd.rb +33 -0
  38. data/lib/bio-ucsc/hg19/hapmapsnpsgih.rb +34 -0
  39. data/lib/bio-ucsc/hg19/hapmapsnpsjpt.rb +34 -0
  40. data/lib/bio-ucsc/hg19/hapmapsnpslwk.rb +35 -0
  41. data/lib/bio-ucsc/hg19/hapmapsnpsmex.rb +35 -0
  42. data/lib/bio-ucsc/hg19/hapmapsnpsmkk.rb +35 -0
  43. data/lib/bio-ucsc/hg19/hapmapsnpstsi.rb +35 -0
  44. data/lib/bio-ucsc/hg19/hapmapsnpsyri.rb +35 -0
  45. data/lib/bio-ucsc/hg19/knowngene.rb +34 -0
  46. data/lib/bio-ucsc/hg19/omimgene.rb +25 -0
  47. data/lib/bio-ucsc/hg19/phastconselements46wayprimates.rb +27 -0
  48. data/lib/bio-ucsc/hg19/phylop46wayprimates.rb +27 -0
  49. data/lib/bio-ucsc/hg19/refgene.rb +27 -0
  50. data/lib/bio-ucsc/hg19/rmsk.rb +32 -0
  51. data/lib/bio-ucsc/hg19/snp131.rb +30 -0
  52. data/lib/bio-ucsc/hg19/snp132.rb +31 -0
  53. data/lib/bio-ucsc/hg19/snp132codingdbsnp.rb +29 -0
  54. data/lib/bio-ucsc/hg19/snp132common.rb +32 -0
  55. data/lib/bio-ucsc/hg19/snp132flagged.rb +31 -0
  56. data/lib/bio-ucsc/hg19/snp132mult.rb +32 -0
  57. data/lib/bio-ucsc/hg19/wgrna.rb +29 -0
  58. data/lib/bio-ucsc/ucsc_bin.rb +148 -0
  59. data/samples/hg19-sample.rb +66 -0
  60. data/spec/hg18/cnpiafrate2_spec.rb +23 -0
  61. data/spec/hg18/cnplocke_spec.rb +23 -0
  62. data/spec/hg18/cnpredon_spec.rb +23 -0
  63. data/spec/hg18/cnpsebat2_spec.rb +23 -0
  64. data/spec/hg18/cnpsharp2_spec.rb +23 -0
  65. data/spec/hg18/db_connection_spec.rb +36 -0
  66. data/spec/hg18/dgv_spec.rb +23 -0
  67. data/spec/hg18/refgene_spec.rb +23 -0
  68. data/spec/hg18/rmsk_spec.rb +33 -0
  69. data/spec/hg19/ccdsgene_spec.rb +23 -0
  70. data/spec/hg19/cytoband_spec.rb +23 -0
  71. data/spec/hg19/db_connection_spec.rb +37 -0
  72. data/spec/hg19/dgv_spec.rb +23 -0
  73. data/spec/hg19/ensgene_spec.rb +23 -0
  74. data/spec/hg19/gwascatalog_spec.rb +23 -0
  75. data/spec/hg19/hapmapalleleschimp_spec.rb +23 -0
  76. data/spec/hg19/hapmapallelesmacaque_spec.rb +23 -0
  77. data/spec/hg19/hapmapsnpsasw_spec.rb +23 -0
  78. data/spec/hg19/hapmapsnpsceu_spec.rb +23 -0
  79. data/spec/hg19/hapmapsnpschb_spec.rb +23 -0
  80. data/spec/hg19/hapmapsnpschd_spec.rb +23 -0
  81. data/spec/hg19/hapmapsnpsgih_spec.rb +23 -0
  82. data/spec/hg19/hapmapsnpsjpt_spec.rb +23 -0
  83. data/spec/hg19/hapmapsnpslwk_spec.rb +23 -0
  84. data/spec/hg19/hapmapsnpsmex_spec.rb +23 -0
  85. data/spec/hg19/hapmapsnpsmkk_spec.rb +23 -0
  86. data/spec/hg19/hapmapsnpstsi_spec.rb +23 -0
  87. data/spec/hg19/hapmapsnpsyri_spec.rb +23 -0
  88. data/spec/hg19/knowngene_spec.rb +23 -0
  89. data/spec/hg19/omimGene_spec.rb +23 -0
  90. data/spec/hg19/phastconselements46wayprimates_spec.rb +23 -0
  91. data/spec/hg19/phyloP46wayPrimates_spec.rb +23 -0
  92. data/spec/hg19/refgene_spec.rb +23 -0
  93. data/spec/hg19/rmsk_spec.rb +23 -0
  94. data/spec/hg19/snp132Flagged_spec.rb +24 -0
  95. data/spec/hg19/snp132_spec.rb +23 -0
  96. data/spec/hg19/snp132codingdbsnp_spec.rb +23 -0
  97. data/spec/hg19/snp132common_spec.rb +24 -0
  98. data/spec/hg19/snp132mult_spec.rb +23 -0
  99. data/spec/hg19/wgrna_spec.rb +23 -0
  100. data/spec/spec_helper.rb +12 -0
  101. metadata +368 -0
data/lib/bio-ucsc.rb ADDED
@@ -0,0 +1,20 @@
1
+ #
2
+ # = ucsc.rb
3
+ # Copyright:: Cioyrught (C) 2011
4
+ # MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # License:: Ruby licence (Ryby's / GPLv2 dual)
6
+
7
+ base = File.dirname(__FILE__)
8
+ require "#{base}/bio-ucsc/ucsc_bin"
9
+ require "bio-genomic-interval"
10
+
11
+ module Bio
12
+ module Ucsc
13
+ base = File.dirname(__FILE__)
14
+ autoload :Hg18, "#{base}/bio-ucsc/hg18"
15
+ autoload :Hg19, "#{base}/bio-ucsc/hg19"
16
+
17
+ # ToDo
18
+ # autoload :Mm9, "#{base}/bio-ucsc/mm9"
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ #
2
+ # = ucsc.rb
3
+ # Copyright:: Cioyrught (C) 2011
4
+ # MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright:: Copyright (C) 2008
6
+ # Jan Aerts <jan.aerts@gmail.com>
7
+ # License:: Ruby's
8
+
9
+ base = File.dirname(__FILE__)
10
+ require "#{base}/hg18/db_connection"
11
+ require "#{base}/hg18/activerecord"
12
+
13
+ module Bio
14
+ module Ucsc
15
+ module Hg18
16
+ base = File.dirname(__FILE__)
17
+ autoload :RefGene, "#{base}/hg18/refgene"
18
+ autoload :Dgv, "#{base}/hg18/dgv"
19
+ autoload :CnpIafrate2, "#{base}/hg18/cnpiafrate2"
20
+ autoload :CnpLocke, "#{base}/hg18/cnplocke"
21
+ autoload :CnpRedon, "#{base}/hg18/cnpredon"
22
+ autoload :CnpSebat2, "#{base}/hg18/cnpsebat2"
23
+ autoload :CnpSharp2, "#{base}/hg18/cnpsharp2"
24
+ autoload :Rmsk, "#{base}/hg18/rmsk.rb"
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,166 @@
1
+ #
2
+ # = ucsc/hg18/activerecord.rb - ActiveRecord mappings to UCSC hg18 database
3
+ #
4
+ # Copyright::
5
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
6
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
7
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
8
+ #
9
+ # = DESCRIPTION
10
+ # == What is it?
11
+ # The UCSC module provides an API to the UCSC databases
12
+ # stored at genome-mysql.cse.ucsc.edu. This is the same information that is
13
+ # available from http://genome.ucsc.edu
14
+ #
15
+ # The Ucsc::Hg18 module covers the hg19 (= GRCh37) assembly.
16
+ #
17
+ # == ActiveRecord
18
+ # The UCSC API provides a ruby interface to the UCSC mysql databases
19
+ # at genome-mysql.cse.ucsc.edu. Most of the API is based on ActiveRecord to
20
+ # get data from that database. In general, each table is described by a
21
+ # class with the same name: the cnpRedon table is covered by the
22
+ # CnpRedon class, the dgv table is covered by the Dgv class,
23
+ # etc. As a result, accessors are available for all columns in each table.
24
+ # For example, the cnpRedon table has the following columns: chrom, chromStart,
25
+ # chromEnd and name. Through ActiveRecord, these column names become available
26
+ # as attributes of CnpRedon objects:
27
+ # puts my_cnp_redon.name
28
+ # puts my_cnp_redon.chrom
29
+ # puts my_cnp_redon.chromStart
30
+ # puts my_cnp_redon.chromEnd
31
+ #
32
+ # ActiveRecord makes it easy to extract data from those tables using the
33
+ # collection of #find methods. There are three types of #find methods (e.g.
34
+ # for the CnpRedon class):
35
+ # a. find based on primary key in table:
36
+ # # not possible with the UCSC database
37
+ # b. find_by_sql:
38
+ # my_cnp = CnpRedon.find_by_sql('SELECT * FROM cnpRedon WHERE name = 'cnp1'")
39
+ # c. find_by_<insert_your_column_name_here>
40
+ # my_cnp = CnpRedon.find_by_name('cnp1')
41
+ # my_cnp2 = CnpRedon.find_by_chrom_and_chromStart('chr1',377)
42
+ # To find out which find_by_<column> methods are available, you can list the
43
+ # column names using the column_names class methods:
44
+ #
45
+ # puts Ucsc::Hg18::CnpRedon.column_names.join("\t")
46
+ #
47
+ # For more information on the find methods, see
48
+ # http://ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000344
49
+ #
50
+
51
+ module Bio
52
+ module Ucsc
53
+
54
+ # = DESCRIPTION
55
+ # The Bin::Ucsc::Hg18 module covers the hg18 database from
56
+ # genome-mysql.cse.ucsc.edu and covers mainly sequences and their annotations.
57
+ # For a more information about the database tables, click on the "Describe
58
+ # table schema" in the Table Browser.
59
+ module Hg18
60
+ # interval: chromStart, chromEnd
61
+ # bin index is enabled
62
+ module QueryUsingChromBin
63
+ def find_by_interval(interval)
64
+ zstart = interval.zero_start
65
+ zend = interval.zero_end
66
+ where = <<-SQL
67
+ chrom = :chrom
68
+ AND bin in (:bins)
69
+ AND ((chromStart BETWEEN :zstart AND :zend)
70
+ OR (chromEnd BETWEEN :zstart AND :zend)
71
+ OR (chromStart <= :zstart AND chromEnd >= :zend))
72
+ SQL
73
+ cond = {
74
+ :chrom => interval.chrom,
75
+ :bins => Ucsc::UcscBin.bin_all(zstart, zend),
76
+ :zstart => zstart,
77
+ :zend => zend,
78
+ }
79
+
80
+ self.find(:all,
81
+ :select => "*",
82
+ :conditions => [where, cond],
83
+ )
84
+ end
85
+ end # module QueryUsingChromBin
86
+
87
+ # interval: chromStart, chromEnd
88
+ # bin index is disabled
89
+ module QueryUsingChrom
90
+ def find_by_interval(interval)
91
+ zstart = interval.zero_start
92
+ zend = interval.zero_end
93
+ where = <<-SQL
94
+ chrom = :chrom
95
+ AND ((chromStart BETWEEN :zstart AND :zend)
96
+ OR (chromEnd BETWEEN :zstart AND :zend)
97
+ OR (chromStart <= :zstart AND chromEnd >= :zend))
98
+ SQL
99
+ cond = {
100
+ :chrom => interval.chrom,
101
+ :zstart => zstart,
102
+ :zend => zend,
103
+ }
104
+ self.find(:all,
105
+ :select => "*",
106
+ :conditions => [where, cond],
107
+ )
108
+ end
109
+ end # module QueryUsingChrom
110
+
111
+ # interval: chromStart, chromEnd
112
+ # bin index is disabled
113
+ module QueryUsingTxBin
114
+ def find_by_interval(interval)
115
+ zstart = interval.zero_start
116
+ zend = interval.zero_end
117
+ where = <<-SQL
118
+ chrom = :chrom
119
+ AND bin in (:bins)
120
+ AND ((txStart BETWEEN :zstart AND :zend)
121
+ OR (txEnd BETWEEN :zstart AND :zend)
122
+ OR (txStart <= :zstart AND txEnd >= :zend))
123
+ SQL
124
+ cond = {
125
+ :chrom => interval.chrom,
126
+ :bins => Bio::Ucsc::UcscBin.bin_all(zstart, zend),
127
+ :zstart => zstart,
128
+ :zend => zend,
129
+ }
130
+ self.find(:all,
131
+ :select => "*",
132
+ :conditions => [where, cond],
133
+ )
134
+ end
135
+ end # module QueryUsingTxBin
136
+
137
+ # interval: genoName, genoStart, genoEnd
138
+ # bin index is enabled
139
+ module QueryUsingGenoBin
140
+ def find_by_interval(interval)
141
+ zstart = interval.zero_start
142
+ zend = interval.zero_end
143
+ where = <<-SQL
144
+ genoName = :chrom
145
+ AND bin in (:bins)
146
+ AND ((genoStart BETWEEN :zstart AND :zend)
147
+ OR (genoEnd BETWEEN :zstart AND :zend)
148
+ OR (genoStart <= :zstart AND genoEnd >= :zend))
149
+ SQL
150
+ cond = {
151
+ :chrom => interval.chrom,
152
+ :bins => Ucsc::UcscBin.bin_all(zstart, zend),
153
+ :zstart => zstart,
154
+ :zend => zend,
155
+ }
156
+
157
+ self.find(:all,
158
+ :select => "*",
159
+ :conditions => [where, cond],
160
+ )
161
+ end
162
+ end # module QueryUsingChromBin
163
+
164
+ end # module Hg18
165
+ end # module Ucsc
166
+ end # module Bio
@@ -0,0 +1,31 @@
1
+ #
2
+ # = hg18/cnpiafrate2.rb
3
+ # Copyright::
4
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+ # = Table desfription in UCSC Table Browser
9
+ # This annotation shows regions detected as putative copy number
10
+ # polymorphisms (CNP) and sites of detected intermediate-sized
11
+ # structural variation (ISV). The CNPs and ISVs were determined by
12
+ # various methods, displayed in individual subtracks within the
13
+ # annotation.
14
+ #
15
+ # Iafrate BAC microarray analysis
16
+ # All hybridizations were performed in duplicate incorporating a
17
+ # dye-reversal using proprieta#ry 1 Mb GenomeChip V1.2 Human BAC Arrays
18
+ # consisting of 2,632 BAC clones (Spectral Genomics,# Houston, TX). The
19
+ # false positive rate was estimated at ~1 clone per 5,264 tested.
20
+
21
+ module Bio
22
+ module Ucsc
23
+ module Hg18
24
+ class CnpIafrate2 < DBConnection
25
+ extend Bio::Ucsc::Hg18::QueryUsingChromBin
26
+ set_table_name 'cnpIafrate2'
27
+ set_primary_key nil
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,31 @@
1
+ #
2
+ # = hg18/cnplocke.rb
3
+ # Copyright::
4
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+ # = Table desfription in UCSC Table Browser
9
+ # This annotation shows regions detected as putative copy number
10
+ # polymorphisms (CNP) and sites of detected intermediate-sized
11
+ # structural variation (ISV). The CNPs and ISVs were determined by
12
+ # various methods, displayed in individual subtracks within the
13
+ # annotation.
14
+ #
15
+ # Locke analysis of duplication-rich regions
16
+ # DNA samples were obtained from Coriell Cell Repositories. The
17
+ # reference DNA used for all hybridizations was from a single male of
18
+ # Czechoslovakian descent, Coriell ID GM15724 (also used in the Sharp
19
+ # study).
20
+
21
+ module Bio
22
+ module Ucsc
23
+ module Hg18
24
+ class CnpLocke < DBConnection
25
+ extend Bio::Ucsc::Hg18::QueryUsingChromBin
26
+ set_table_name 'cnpLocke'
27
+ set_primary_key nil
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # = hg18/cnpredon.rb
3
+ # Copyright::
4
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+ # = Table desfription in UCSC Table Browser
9
+ # This annotation shows regions detected as putative copy number
10
+ # polymorphisms (CNP) and sites of detected intermediate-sized
11
+ # structural variation (ISV). The CNPs and ISVs were determined by
12
+ # various methods, displayed in individual subtracks within the
13
+ # annotation.
14
+ #
15
+ # Redon analysis of HapMap data
16
+ # Experiments were performed with the International HapMap DNA and
17
+ # cell-line collection using two technologies: comparative analysis of
18
+ # hybridization intensities on Affymetric GeneChip Human Mapping 500K
19
+ # early access arrays (500K EA) and comparative genomic hybridization
20
+ # with a Whole Genome TilePath (WGTP) array.
21
+
22
+ module Bio
23
+ module Ucsc
24
+ module Hg18
25
+ class CnpRedon < DBConnection
26
+ extend Bio::Ucsc::Hg18::QueryUsingChromBin
27
+ set_table_name 'cnpRedon'
28
+ set_primary_key nil
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,35 @@
1
+ #
2
+ # = hg18/cnpsebat2.rb
3
+ # Copyright::
4
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+ # = Table desfription in UCSC Table Browser
9
+ # This annotation shows regions detected as putative copy number
10
+ # polymorphisms (CNP) and sites of detected intermediate-sized
11
+ # structural variation (ISV). The CNPs and ISVs were determined by
12
+ # various methods, displayed in individual subtracks within the
13
+ # annotation.
14
+ #
15
+ # Sebat ROMA Following digestion with BglII or HindIII, genomic DNA
16
+ # was hybridized to a custom array consisting of 85,000
17
+ # oligonucleotide probes. The probes were selected to be free of
18
+ # common repeats and have unique homology within the human genome. The
19
+ # average resolution of the array was -5 kb; however, only intervals
20
+ # in which three consecutive probes showed concordant signals were
21
+ # scored as CNPs. All hybridizations were performed in duplicate
22
+ # incorporating a dye-reversal, with the false positive rate estimated
23
+ # to be -6%.
24
+
25
+ module Bio
26
+ module Ucsc
27
+ module Hg18
28
+ class CnpSebat2 < DBConnection
29
+ extend Bio::Ucsc::Hg18::QueryUsingChrom
30
+ set_table_name 'cnpSebat2'
31
+ set_primary_key nil
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,32 @@
1
+ #
2
+ # = hg18/cnpsharp2.rb
3
+ # Copyright::
4
+ # Copyright (C) 2011 MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
5
+ # Copyright (C) 2008 Jan Aerts <jan.aerts@gmail.com>
6
+ # License:: The Ruby licence (Ryby's / GPLv2 dual)
7
+ #
8
+ # = Table desfription in UCSC Table Browser
9
+ # This annotation shows regions detected as putative copy number
10
+ # polymorphisms (CNP) and sites of detected intermediate-sized
11
+ # structural variation (ISV). The CNPs and ISVs were determined by
12
+ # various methods, displayed in individual subtracks within the
13
+ # annotation.
14
+ #
15
+ # Sharp BAC microarray analysis
16
+ # All hybridizations were performed in duplicate incorporating a
17
+ # dye-reversal using a custom array consisting of 2,194 end-sequence
18
+ # or FISH-confirmed BACs, targeted to regions of the genome flanked by
19
+ # segmental duplications. The false positive rate was estimated at -3
20
+ # clones per 4,000 tested.
21
+
22
+ module Bio
23
+ module Ucsc
24
+ module Hg18
25
+ class CnpSharp2 < DBConnection
26
+ extend Bio::Ucsc::Hg18::QueryUsingChromBin
27
+ set_table_name 'cnpSharp2'
28
+ set_primary_key nil
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,61 @@
1
+ #
2
+ # = lib/ucsc/hg18/db_connection.rb - UCSC hg18 DB connection
3
+ #
4
+ # Copyright:: Cioyrught (C) 2011
5
+ # MISHIMA, Hiroyuki <missy at be.to / hmishima at nagasaki-u.ac.jp>
6
+ # Copyright:: Copyright (C) 2008
7
+ # Jan Aerts <jan.aerts@gmail.com>
8
+ # License:: Ruby licence (Ryby's / GPLv2 dual)
9
+
10
+ require 'rubygems'
11
+ require 'active_record'
12
+
13
+ module Bio
14
+ module Ucsc
15
+
16
+ module Hg18
17
+ # = DESCRIPTION
18
+ # The Ucsc::Hg18::DBConnection is the actual connection established
19
+ # with the UCSC mysql server.
20
+
21
+ class DBConnection < ActiveRecord::Base
22
+ # = DESCRIPTION
23
+ # The Ucsc::Hg18::DBConnection#connect method makes the connection
24
+ # to the UCSC hg18 database.
25
+ #
26
+ # = USAGE
27
+ # # Connect to the hg18
28
+ # Ensembl::Core::DBConnection.connect
29
+ #
30
+ # ---
31
+ # *Arguments*: none
32
+ @@db_adapter = 'mysql'
33
+ @@db_host = 'genome-mysql.cse.ucsc.edu'
34
+ @@db_username = 'genome'
35
+ @@db_password = ''
36
+
37
+ cattr_accessor :db_host, :db_username, :db_password
38
+
39
+ self.abstract_class = true
40
+
41
+ def self.default
42
+ @@db_adapter = 'mysql'
43
+ @@db_host = 'genome-mysql.cse.ucsc.edu'
44
+ @@db_username = 'genome'
45
+ @@db_password = ''
46
+ end
47
+
48
+ def self.connect
49
+ establish_connection(
50
+ :adapter => @@db_adapter,
51
+ :host => @@db_host,
52
+ :database => 'hg18',
53
+ :username => @@db_username,
54
+ :password => @@db_password
55
+ )
56
+ end
57
+ end
58
+ end # module Hg18
59
+
60
+ end # module Ucsc
61
+ end # module Bio