Module: Ucsc

Defined in:
lib/ucsc/hg18/activerecord.rb,
lib/ucsc/hg18/slice.rb,
lib/ucsc/db_connection.rb

Overview

DESCRIPTION

What is it?

The UCSC module provides an API to the UCSC databases stored at genome-mysql.cse.ucsc.edu. This is the same information that is available from genome.ucsc.edu

The Ucsc::Hg18 module covers the hg18 (= NCBI build 36) assembly.

ActiveRecord

The UCSC API provides a ruby interface to the UCSC mysql databases at genome-mysql.cse.ucsc.edu. Most of the API is based on ActiveRecord to get data from that database. In general, each table is described by a class with the same name: the cnpRedon table is covered by the CnpRedon class, the dgv table is covered by the Dgv class, etc. As a result, accessors are available for all columns in each table. For example, the cnpRedon table has the following columns: chrom, chromStart, chromEnd and name. Through ActiveRecord, these column names become available as attributes of CnpRedon objects:

puts my_cnp_redon.name
puts my_cnp_redon.chrom
puts my_cnp_redon.chromStart
puts my_cnp_redon.chromEnd

ActiveRecord makes it easy to extract data from those tables using the collection of #find methods. There are three types of #find methods (e.g. for the CnpRedon class):

  1. find based on primary key in table:

# not possible with the UCSC database
  1. find_by_sql:

my_cnp = CnpRedon.find_by_sql('SELECT * FROM cnpRedon WHERE name = 'cnp1'")
  1. find_by_<insert_your_column_name_here>

my_cnp = CnpRedon.find_by_name('cnp1')
my_cnp2 = CnpRedon.find_by_chrom_and_chromStart('chr1',377)

To find out which find_by_<column> methods are available, you can list the column names using the column_names class methods:

puts Ucsc::Hg18::CnpRedon.column_names.join("\t")

For more information on the find methods, see ar.rubyonrails.org/classes/ActiveRecord/Base.html#M000344

Defined Under Namespace

Modules: Hg18