Module: Builder

Includes:
XlsParser
Included in:
Vardb
Defined in:
lib/vardb/snp_db_build.rb

Instance Method Summary collapse

Methods included from XlsParser

load_meta_fields

Instance Method Details

#format_matrixObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/vardb/snp_db_build.rb', line 6

def format_matrix
  host = ConfigData.get_connection

  conn = PGconn.connect(:host => host[:host], :port => host[:port], :dbname => host[:dbname], :user => host[:user], :password => host[:password])

  puts "formatting annotations table..."
  conn.exec("CREATE TABLE annotations (id numeric(11) PRIMARY KEY, cds varchar(128), transcript varchar(128), transcript_id varchar(128), info text, orientation varchar(128), cds_locus varchar(128), codon_pos varchar(128), codon varchar(128), peptide varchar(128), amino_a varchar(128), syn varchar(128))")

  puts "formatting snps table..."
  conn.exec("CREATE TABLE snps (id numeric(11) PRIMARY KEY, locus numeric(11), annotation_id numeric(11))")

  puts "formatting samples table..."
  conn.exec("CREATE TABLE samples (id numeric(11) PRIMARY KEY, name varchar(128))")

  puts "formatting samples_snps join table..."
  conn.exec("CREATE TABLE samples_snps (sample_id numeric(11), snp_id numeric(11))")
end

#format_metadataObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/vardb/snp_db_build.rb', line 24

def 
  host = ConfigData.get_connection

  conn = PGconn.connect(:host => host[:host], :port => host[:port], :dbname => host[:dbname], :user => host[:user], :password => host[:password])

   = XlsParser.load_meta_fields(ConfigData.)

   = ""

  .each do |name|
    name << " varchar(128)"
     << name
  end

  puts "formatting sample metadata table..."
  conn.exec("CREATE TABLE sample_metadata (id numeric (11) PRIMARY KEY#{metadata_field_names})")
end