Sha256: 064615f4cbdaf525a202ec1a906733cffff6e504f8a4baa76096bf1c1ed6464b

Contents?: true

Size: 1.99 KB

Versions: 28

Compression:

Stored size: 1.99 KB

Contents

def db_schema
ActiveRecord::Schema.define do
  unless table_exists? :strains
    create_table :strains do |t|
      t.column :name, :string
      t.column :description, :string
    end
  end

  unless table_exists? :features
    create_table :features do |t|
      t.column :name,      :string
      t.column :sequence, :string
      t.column :start, :integer
      t.column :end, :integer
      t.column :strand, :integer
    end
  end

  unless table_exists? :snps
    create_table :snps do |t|
      t.column :feature_id, :integer
      t.column :ref_pos, :integer
      t.column :reference_allele_id, :integer
    end
  end

  unless table_exists? :alleles
    create_table :alleles do |t|name
      t.column :snp_id, :integer
      t.column :base, :string
    end
  end
 
  unless table_exists? :genotypes
    create_table :genotypes do |t|
      t.column :allele_id, :integer
      t.column :strain_id, :integer
    end
  end

  unless table_exists? :annotations
    create_table :annotations do |t|
      t.column  :qualifier, :string
      t.column :value, :string
      t.column :feature_id, :integer
    end
  end
   
  # indices
  unless index_exists? :features, :name
    add_index :features, :name
  end
  unless index_exists? :features, :start
    add_index :features, :start
  end
  unless index_exists? :features, :end
    add_index :features, :end
  end
  unless index_exists? :features, :strand
    add_index :features, :strand
  end
  unless index_exists? :snps, :ref_pos
    add_index :snps, :ref_pos
  end
  unless index_exists? :snps, :feature_id
    add_index :snps, :feature_id
  end
  unless index_exists? :alleles, :snp_id
    add_index :alleles, :snp_id
  end
  unless index_exists? :alleles, :base
    add_index :alleles, :base
  end
 unless index_exists? :genotypes, :allele_id
  add_index :genotypes, :allele_id
  end
  unless index_exists? :genotypes, :strain_id
  add_index :genotypes, :strain_id
  end
  unless index_exists? :annotations, :feature_id
    add_index :annotations, :feature_id
  end
end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
snp-search-1.0.0 lib/snp_db_schema.rb
snp-search-0.34.0 lib/snp_db_schema.rb
snp-search-0.33.0 lib/snp_db_schema.rb
snp-search-0.32.0 lib/snp_db_schema.rb
snp-search-0.31.0 lib/snp_db_schema.rb
snp-search-0.30.0 lib/snp_db_schema.rb
snp-search-0.29.0 lib/snp_db_schema.rb
snp-search-0.27.2 lib/snp_db_schema.rb
snp-search-0.27.1 lib/snp_db_schema.rb
snp-search-0.27.0 lib/snp_db_schema.rb
snp-search-0.26.0 lib/snp_db_schema.rb
snp-search-0.23.0 lib/snp_db_schema.rb
snp-search-0.22.0 lib/snp_db_schema.rb
snp-search-0.21.0 lib/snp_db_schema.rb
snp-search-0.19.0 lib/snp_db_schema.rb
snp-search-0.17.0 lib/snp_db_schema.rb
snp-search-0.16.0 lib/snp_db_schema.rb
snp-search-0.15.0 lib/snp_db_schema.rb
snp-search-0.14.0 lib/snp_db_schema.rb
snp-search-0.12.0 lib/snp_db_schema.rb