Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A ruby API for interacting with Biomart services
Ruby
tag: 0.1.2

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
script
tasks
test
.gitignore
History.txt
Manifest.txt
README.rdoc
Rakefile
biomart.gemspec

README.rdoc

Biomart

biomart.rubyforge.org

github.com/dazoakley/biomart

Biomart provides a simple interface for working with Biomart servers (see www.biomart.org for more info on Biomart itself), so you don't have to get down and dirty with the basic webservice calls yourself.

Install

sudo gem install biomart

Usage

Include the module in your code:

require "rubygems"
require "biomart"

To basically connect to a Biomart server and have access to all of its information and meta data:

biomart = Biomart::Server.new( "http://www.biomart.org/biomart" )

# List all of the available datasets on this Biomart server
# (be patient - this will take a while on this server as there's 
# a lot there...)
p biomart.list_datasets

# Grab the "kermits" dataset
kermits = biomart.datasets["kermits"]

# List it's filters and attributes
p kermits.list_filters
p kermits.list_attributes

# Count the total number of records in the dataset
p kermits.count()

# Do a count with a filter added
p kermits.count( :filters => { "sponsor" => "EUCOMM" } )

# Do a search using the default filters and attributes
# - this will return a hash with :headers (an array of the headers) 
#   and :data (an array of arrays of results)
#
# Doing a search like this is generally a BAD idea as biomarts tend 
# to hold a LOT of data... Unless you have time to kill...
p kermits.search()

# Do a search using some specific filters (but the default attributes)
p kermits.search( :filters => { "marker_symbol" => "Cbx1" } )

# Do a search with specific filters and attributes
p kermits.search( 
    :filters => { "marker_symbol" => "Cbx1" }, 
    :attributes => ["marker_symbol"] 
  )

# If you would like to retrieve a more useful results object - i.e. an 
# array of hashes, where each hash represents a row of results (keyed 
# by the attribute name), add the :process_results argument
p kermits.search( 
    :filters => { "marker_symbol" => "Cbx1" }, 
    :process_results => true 
  )

Or if you know the dataset you wish to work with and would like to just get on with things…

htgt_targ = Biomart::Dataset.new( 
  "http://www.sanger.ac.uk/htgt/biomart", 
  { :name => "htgt_targ" } 
)
p htgt_targ.count( :filters => { "is_eucomm" => "1" } )

# etc. etc.

See Biomart module and Class docs for more detail.

Using a Proxy

If you need to channel all of your requests via a proxy, specify your proxy via Biomart.proxy:

Biomart.proxy = "http://proxy.example.com/"

Now all requests made through Biomart will be proxied via proxy.example.com.

Alternatively you can also set your proxy url in the environment variable 'http_proxy', and Biomart will automatically detect this.

Meta

Written by Darren Oakley (daz dot oakley at gmail dot com)

biomart.rubyforge.org

github.com/dazoakley/biomart

License

(The MIT License)

Copyright © 2009 Darren Oakley

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Something went wrong with that request. Please try again.