Permalink
Browse files

minor changes

  • Loading branch information...
1 parent 62a9b88 commit b125cd3b1140d13c2ae1feb8a8157352974222c1 Marc Hoeppner committed Aug 29, 2011
Showing with 53 additions and 24 deletions.
  1. +31 −4 lib/files/activerecord.rb
  2. +20 −19 lib/files/db_connection.rb
  3. +2 −1 lib/locus-database.rb
  4. BIN locus-database-0.0.1.gem
@@ -3,8 +3,10 @@
module LocusDB
class GenomeDb < DBConnection
- set_primary_key 'id'
- hass_many :genes
+ set_primary_key 'genome_db_id'
+ has_many :genes
+ has_many :xref_genome_datasets
+ has_many :datasets, :through => :xref_genome_datasets
end # genome_db
@@ -35,12 +37,37 @@ class Dataset < DBConnection
has_many :groupings
has_many :genomic_align_blocks
has_many :dollo_nodes
+ has_many :xref_genome_datasets
+
+
+ def genome_dbs
+ return self.xref_genome_datasets.collect{|x| x.genome_db }
+ end
+
+ def output_phylip
+ tree_string = self.tree_string
+ tree_organisms = self.tree.leaves.collect{|t| t.name.strip }
+ tree_organisms.each do |t_o|
+ phylip_name = t_o.gsub(/\s/, '_').phylip_name
+ t_o = t_o.gsub(/\s/ , '_')
+ tree_string.gsub!(/#{t_o}/, "#{phylip_name}")
+ end
+ return tree_string
+
+ end
+
end # dataset
+ class XrefGenomeDataset < DBConnection
+ set_primary_keys :genome_db_id, :dataset_id
+ belongs_to :genome_db, :foreign_key => "genome_db_id"
+ belongs_to :dataset_id, :foreign_key => "dataset_id"
+ end
+
class GenomicAlignBlock < DBConnection
set_primary_key 'genomic_align_block_id'
- belongs_to :dataset, :foreign_key => "dataset_id",
+ belongs_to :dataset, :foreign_key => "dataset_id"
has_many :groupings
end # genomic_align_block
@@ -50,4 +77,4 @@ class DolloNode < DBConnection
end # dollo_node
-end # module
+end # module
@@ -1,30 +1,31 @@
#!/usr/bin/ruby
-DB_ADAPTER = 'postgresql'
-DB_HOST = 'localhost'
-DATABASE = 'locusdb'
-DB_USERNAME = 'tools'
-DB_PASSWORD = 'analysis'
+Locus_DB_ADAPTER = 'postgresql'
+Locus_DB_HOST = 'localhost'
+Locus_DATABASE = 'locus_db'
+Locus_DB_USERNAME = 'tools'
+Locus_DB_PASSWORD = 'analysis'
module LocusDB
- include ActiveRecord
+ include ActiveRecord
- class DBConnection < ActiveRecord::Base
- self.abstract_class = true
-
- def self.connect(version="")
+ class DBConnection < ActiveRecord::Base
+ self.abstract_class = true
+ self.pluralize_table_names = false
+
+ def self.connect(version="")
- establish_connection(
- :adapter => DB_ADAPTER,
- :host => DB_HOST,
- :database => "#{DATABASE}#{version}",
- :username => DB_USERNAME,
- :password => DB_PASSWORD
+ establish_connection(
+ :adapter => Locus_DB_ADAPTER,
+ :host => Locus_DB_HOST,
+ :database => "#{Locus_DATABASE}_#{version}",
+ :username => Locus_DB_USERNAME,
+ :password => Locus_DB_PASSWORD
#:port => port
)
- end
+ end
- end
+ end
-end
+end
@@ -1,8 +1,9 @@
require 'rubygems'
-require 'activerecord'
+require 'active_record'
require 'composite_primary_keys'
gem 'activerecord', '>= 3.0'
gem 'activesupport', '>= 3.0'
+require File.dirname(__FILE__) + '/files/db_connection.rb'
require File.dirname(__FILE__) + '/files/activerecord.rb'
Binary file not shown.

0 comments on commit b125cd3

Please sign in to comment.