biomart 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +22 -0
- data/History.txt +8 -0
- data/{Manifest.txt → Manifest} +4 -3
- data/README.rdoc +64 -1
- data/Rakefile +4 -30
- data/biomart.gemspec +19 -34
- data/lib/biomart.rb +10 -4
- data/lib/biomart/dataset.rb +32 -4
- data/lib/biomart/filter.rb +2 -0
- data/lib/biomart/version.rb +3 -0
- data/tasks/rcov.rake +16 -0
- data/tasks/shoulda.rake +10 -12
- data/tasks/yard.rake +9 -0
- data/test/test_biomart.rb +52 -9
- data/test/test_helper.rb +13 -6
- metadata +17 -24
- data/script/destroy +0 -14
- data/script/generate +0 -14
    
        data/.gitignore
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/Gemfile.lock
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            PATH
         | 
| 2 | 
            +
              remote: .
         | 
| 3 | 
            +
              specs:
         | 
| 4 | 
            +
                biomart (0.2.1)
         | 
| 5 | 
            +
                  builder
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            GEM
         | 
| 8 | 
            +
              remote: http://rubygems.org/
         | 
| 9 | 
            +
              specs:
         | 
| 10 | 
            +
                builder (2.1.2)
         | 
| 11 | 
            +
                shoulda (2.11.3)
         | 
| 12 | 
            +
                simplecov (0.4.0)
         | 
| 13 | 
            +
                  simplecov-html (~> 0.4.0)
         | 
| 14 | 
            +
                simplecov-html (0.4.3)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            PLATFORMS
         | 
| 17 | 
            +
              ruby
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            DEPENDENCIES
         | 
| 20 | 
            +
              biomart!
         | 
| 21 | 
            +
              shoulda (>= 2.10)
         | 
| 22 | 
            +
              simplecov
         | 
    
        data/History.txt
    CHANGED
    
    
    
        data/{Manifest.txt → Manifest}
    RENAMED
    
    | @@ -9,10 +9,11 @@ lib/biomart/database.rb | |
| 9 9 | 
             
            lib/biomart/dataset.rb
         | 
| 10 10 | 
             
            lib/biomart/filter.rb
         | 
| 11 11 | 
             
            lib/biomart/server.rb
         | 
| 12 | 
            -
             | 
| 13 | 
            -
            script/destroy
         | 
| 14 | 
            -
            script/generate
         | 
| 12 | 
            +
            lib/biomart/version.rb
         | 
| 15 13 | 
             
            tasks/metrics.rake
         | 
| 14 | 
            +
            tasks/rcov.rake
         | 
| 16 15 | 
             
            tasks/shoulda.rake
         | 
| 16 | 
            +
            tasks/yard.rake
         | 
| 17 17 | 
             
            test/test_biomart.rb
         | 
| 18 18 | 
             
            test/test_helper.rb
         | 
| 19 | 
            +
            Manifest
         | 
    
        data/README.rdoc
    CHANGED
    
    | @@ -10,7 +10,7 @@ don't have to get down and dirty with the basic webservice calls yourself. | |
| 10 10 |  | 
| 11 11 | 
             
            == Install
         | 
| 12 12 |  | 
| 13 | 
            -
             | 
| 13 | 
            +
              gem install biomart
         | 
| 14 14 |  | 
| 15 15 | 
             
            == Usage
         | 
| 16 16 |  | 
| @@ -80,6 +80,39 @@ just get on with things... | |
| 80 80 |  | 
| 81 81 | 
             
            See Biomart module and Class docs for more detail.
         | 
| 82 82 |  | 
| 83 | 
            +
            == Advanced Filtering
         | 
| 84 | 
            +
             | 
| 85 | 
            +
            Most filters in biomart are just pure textual filters, i.e.
         | 
| 86 | 
            +
             | 
| 87 | 
            +
              kermits.search( :filters => { "marker_symbol" => "Cbx1" } )
         | 
| 88 | 
            +
             | 
| 89 | 
            +
            To filter on more than one term, simply pass a comma concatenated string, 
         | 
| 90 | 
            +
            or an array (the following two searches are equivalent):
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              kermits.search( :filters => { "marker_symbol" => "Cbx1,Mysm1" } )
         | 
| 93 | 
            +
              kermits.search( :filters => { "marker_symbol" => ["Cbx1","Mysm1"] } )
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            Finally, there are also boolean filters (shown in the standard MartView 
         | 
| 96 | 
            +
            interface as a filter name and then two radio buttons: 'Only' or 
         | 
| 97 | 
            +
            'Excluded').  These filers can only accept the following:
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            - 'Only': true / 'only' / 'included'
         | 
| 100 | 
            +
            - 'Excluded': false / 'excluded'
         | 
| 101 | 
            +
             | 
| 102 | 
            +
            Here's some example usage:
         | 
| 103 | 
            +
             | 
| 104 | 
            +
              snp_mart = Biomart::Dataset.new( "http://www.ensembl.org/biomart", { :name => "hsapiens_snp" } )
         | 
| 105 | 
            +
              
         | 
| 106 | 
            +
              # These are equivalent to selecting 'Only' in MartView
         | 
| 107 | 
            +
              snp_mart.search( :filters => { 'with_variation_annotation' => true,       'ensembl_gene' => 'ENSG00000244734' } )
         | 
| 108 | 
            +
              snp_mart.search( :filters => { 'with_variation_annotation' => 'only',     'ensembl_gene' => 'ENSG00000244734' } )
         | 
| 109 | 
            +
              snp_mart.search( :filters => { 'with_variation_annotation' => 'included', 'ensembl_gene' => 'ENSG00000244734' } )
         | 
| 110 | 
            +
              
         | 
| 111 | 
            +
              # These are equivalent to selecting 'Excluded' in MartView
         | 
| 112 | 
            +
              snp_mart.search( :filters => { 'with_variation_annotation' => false,      'ensembl_gene' => 'ENSG00000244734' } )
         | 
| 113 | 
            +
              snp_mart.search( :filters => { 'with_variation_annotation' => 'excluded', 'ensembl_gene' => 'ENSG00000244734' } )
         | 
| 114 | 
            +
              
         | 
| 115 | 
            +
             | 
| 83 116 | 
             
            == Federated Searches
         | 
| 84 117 |  | 
| 85 118 | 
             
            To perform a federated search across two datasets...
         | 
| @@ -130,6 +163,36 @@ possible to federate across more than two datasets in biomart itself. | |
| 130 163 |  | 
| 131 164 | 
             
            Count queries are only allowed on single datasets.
         | 
| 132 165 |  | 
| 166 | 
            +
            == Required Attributes
         | 
| 167 | 
            +
             | 
| 168 | 
            +
            As biomarts are generally big de-normalised data stores, a common task 
         | 
| 169 | 
            +
            after receiving a set of results is to filter out rows that don't have 
         | 
| 170 | 
            +
            information for a given attribute or set of attributes.  A facility for 
         | 
| 171 | 
            +
            doing this has been built into the gem.
         | 
| 172 | 
            +
             | 
| 173 | 
            +
              htgt = Biomart::Server.new( "http://www.sanger.ac.uk/htgt/biomart" )
         | 
| 174 | 
            +
              
         | 
| 175 | 
            +
              res = htgt.datasets["mmusculus_gene_ensembl"].search(
         | 
| 176 | 
            +
                :filters => {
         | 
| 177 | 
            +
                  "chromosome_name" => "1",
         | 
| 178 | 
            +
                  "start"           => "1",
         | 
| 179 | 
            +
                  "end"             => "10000000"
         | 
| 180 | 
            +
                },
         | 
| 181 | 
            +
                :attributes => [
         | 
| 182 | 
            +
                  "ensembl_gene_id", "ensembl_transcript_id",
         | 
| 183 | 
            +
                  "mouse_paralog_ensembl_gene", "mouse_paralog_chromosome"
         | 
| 184 | 
            +
                ],
         | 
| 185 | 
            +
                :required_attributes => ["mouse_paralog_ensembl_gene"]
         | 
| 186 | 
            +
              )
         | 
| 187 | 
            +
             | 
| 188 | 
            +
            The above will perform a basic search and then automatically remove 
         | 
| 189 | 
            +
            any result row that does not have a value for the "mouse_paralog_ensembl_gene" 
         | 
| 190 | 
            +
            attribute.
         | 
| 191 | 
            +
             | 
| 192 | 
            +
            Note: You can specify more than one required attribute.  If more than one 
         | 
| 193 | 
            +
            required attribute is specified, ALL of these attributes must be present 
         | 
| 194 | 
            +
            for a data row to be returned (it is using AND logic).
         | 
| 195 | 
            +
             | 
| 133 196 | 
             
            == Using a Proxy
         | 
| 134 197 |  | 
| 135 198 | 
             
            If you need to channel all of your requests via a proxy, specify your 
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,32 +1,6 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require 'bundler'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
            gem "hoe", ">= 2.1.0"
         | 
| 3 | 
            +
            Bundler::GemHelper.install_tasks
         | 
| 5 4 |  | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
            require "./lib/biomart"
         | 
| 9 | 
            -
             | 
| 10 | 
            -
            Hoe.plugin :newgem
         | 
| 11 | 
            -
            # Hoe.plugin :website
         | 
| 12 | 
            -
            # Hoe.plugin :cucumberfeatures
         | 
| 13 | 
            -
             | 
| 14 | 
            -
            # Generate all the Rake tasks
         | 
| 15 | 
            -
            # Run "rake -T" to see list of generated tasks (from gem root directory)
         | 
| 16 | 
            -
            $hoe = Hoe.spec "biomart" do
         | 
| 17 | 
            -
              self.developer        "Darren Oakley", "daz.oakley@gmail.com"
         | 
| 18 | 
            -
              self.rubyforge_name   = self.name
         | 
| 19 | 
            -
              self.url              = "http://github.com/dazoakley/biomart"
         | 
| 20 | 
            -
              self.summary          = "A ruby API for interacting with Biomart services."
         | 
| 21 | 
            -
              self.description      = "A ruby API for interacting with Biomart XML based webservices."
         | 
| 22 | 
            -
              self.extra_deps       = [["builder",">= 0"]]
         | 
| 23 | 
            -
              self.extra_dev_deps   = [["shoulda",">= 2.10"]]
         | 
| 24 | 
            -
              self.extra_rdoc_files = ["README.rdoc"]
         | 
| 25 | 
            -
            end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
            require "newgem/tasks"
         | 
| 28 | 
            -
            Dir["tasks/*.rake"].each { |t| load t }
         | 
| 29 | 
            -
             | 
| 30 | 
            -
            # TODO - want other tests/tasks run by default? Add them to the list
         | 
| 31 | 
            -
            # remove_task :default
         | 
| 32 | 
            -
            # task :default => [:spec, :features]
         | 
| 5 | 
            +
            Dir['tasks/*.rake'].each { |t| load t }
         | 
| 6 | 
            +
            task :default => [:test]
         | 
    
        data/biomart.gemspec
    CHANGED
    
    | @@ -1,40 +1,25 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "biomart/version"
         | 
| 2 4 |  | 
| 3 5 | 
             
            Gem::Specification.new do |s|
         | 
| 4 | 
            -
              s.name | 
| 5 | 
            -
              s.version | 
| 6 | 
            +
              s.name        = "biomart"
         | 
| 7 | 
            +
              s.version     = Biomart::VERSION
         | 
| 8 | 
            +
              s.platform    = Gem::Platform::RUBY
         | 
| 9 | 
            +
              s.authors     = ["Darren Oakley"]
         | 
| 10 | 
            +
              s.email       = ["daz.oakley@gmail.com"]
         | 
| 11 | 
            +
              s.homepage    = "http://github.com/dazoakley/biomart"
         | 
| 12 | 
            +
              s.summary     = "A ruby API for interacting with Biomart services."
         | 
| 13 | 
            +
              s.description = "A ruby API for interacting with Biomart XML based webservices."
         | 
| 6 14 |  | 
| 7 | 
            -
              s. | 
| 8 | 
            -
              s.authors = ["Darren Oakley"]
         | 
| 9 | 
            -
              s.date = %q{2010-06-10}
         | 
| 10 | 
            -
              s.description = %q{A ruby API for interacting with Biomart XML based webservices.}
         | 
| 11 | 
            -
              s.email = ["daz.oakley@gmail.com"]
         | 
| 12 | 
            -
              s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.rdoc"]
         | 
| 13 | 
            -
              s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "biomart.gemspec", "lib/biomart.rb", "lib/biomart/attribute.rb", "lib/biomart/database.rb", "lib/biomart/dataset.rb", "lib/biomart/filter.rb", "lib/biomart/server.rb", "script/console", "script/destroy", "script/generate", "tasks/metrics.task", "tasks/shoulda.task", "test/test_biomart.rb", "test/test_helper.rb"]
         | 
| 14 | 
            -
              s.homepage = %q{http://github.com/dazoakley/biomart}
         | 
| 15 | 
            -
              s.rdoc_options = ["--main", "README.rdoc"]
         | 
| 16 | 
            -
              s.require_paths = ["lib"]
         | 
| 17 | 
            -
              s.rubyforge_project = %q{biomart}
         | 
| 18 | 
            -
              s.rubygems_version = %q{1.3.7}
         | 
| 19 | 
            -
              s.summary = %q{A ruby API for interacting with Biomart services.}
         | 
| 20 | 
            -
              s.test_files = ["test/test_biomart.rb", "test/test_helper.rb"]
         | 
| 21 | 
            -
             | 
| 22 | 
            -
              if s.respond_to? :specification_version then
         | 
| 23 | 
            -
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 24 | 
            -
                s.specification_version = 3
         | 
| 15 | 
            +
              s.rubyforge_project = "biomart"
         | 
| 25 16 |  | 
| 26 | 
            -
             | 
| 27 | 
            -
             | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
             | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
              else
         | 
| 36 | 
            -
                s.add_dependency(%q<builder>, [">= 0"])
         | 
| 37 | 
            -
                s.add_dependency(%q<shoulda>, [">= 2.10"])
         | 
| 38 | 
            -
                s.add_dependency(%q<hoe>, [">= 2.6.1"])
         | 
| 39 | 
            -
              end
         | 
| 17 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 18 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 19 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 20 | 
            +
              s.require_paths = ["lib"]
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              s.add_runtime_dependency("builder", [">= 0"])
         | 
| 23 | 
            +
              s.add_development_dependency("shoulda", [">= 2.10"])
         | 
| 24 | 
            +
              s.add_development_dependency("simplecov", [">= 0"])
         | 
| 40 25 | 
             
            end
         | 
    
        data/lib/biomart.rb
    CHANGED
    
    | @@ -8,8 +8,6 @@ require "rubygems" | |
| 8 8 | 
             
            require "builder"
         | 
| 9 9 |  | 
| 10 10 | 
             
            module Biomart
         | 
| 11 | 
            -
              VERSION = "0.2.0"
         | 
| 12 | 
            -
              
         | 
| 13 11 | 
             
              # This is the base Biomart error/exception class. Rescue it if 
         | 
| 14 12 | 
             
              # you want to catch any exceptions that this code might raise.
         | 
| 15 13 | 
             
              class BiomartError < StandardError
         | 
| @@ -71,9 +69,16 @@ module Biomart | |
| 71 69 | 
             
                  response = http.request(req)
         | 
| 72 70 | 
             
                end
         | 
| 73 71 |  | 
| 74 | 
            -
                 | 
| 72 | 
            +
                response_code = response.code
         | 
| 73 | 
            +
                response_body = response.body
         | 
| 74 | 
            +
                
         | 
| 75 | 
            +
                if defined? Encoding && response_body.encoding == Encoding::ASCII_8BIT
         | 
| 76 | 
            +
                  response_body = response_body.force_encoding(Encoding::UTF_8).encode
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
                
         | 
| 79 | 
            +
                check_response( response_body, response_code )
         | 
| 75 80 |  | 
| 76 | 
            -
                return  | 
| 81 | 
            +
                return response_body
         | 
| 77 82 | 
             
              end
         | 
| 78 83 |  | 
| 79 84 | 
             
              class << self
         | 
| @@ -133,6 +138,7 @@ end | |
| 133 138 |  | 
| 134 139 | 
             
            directory = File.expand_path(File.dirname(__FILE__))
         | 
| 135 140 |  | 
| 141 | 
            +
            require File.join(directory, 'biomart', 'version')
         | 
| 136 142 | 
             
            require File.join(directory, 'biomart', 'server')
         | 
| 137 143 | 
             
            require File.join(directory, 'biomart', 'database')
         | 
| 138 144 | 
             
            require File.join(directory, 'biomart', 'dataset')
         | 
    
        data/lib/biomart/dataset.rb
    CHANGED
    
    | @@ -6,6 +6,19 @@ module Biomart | |
| 6 6 |  | 
| 7 7 | 
             
                attr_reader :name, :display_name, :visible
         | 
| 8 8 |  | 
| 9 | 
            +
                # Creates a new Biomart::Dataset object.
         | 
| 10 | 
            +
                #
         | 
| 11 | 
            +
                # @param [String] url The URL location of the biomart server.
         | 
| 12 | 
            +
                # @param [Hash] args An arguments hash giving details of the dataset.
         | 
| 13 | 
            +
                #
         | 
| 14 | 
            +
                # arguments hash:
         | 
| 15 | 
            +
                #
         | 
| 16 | 
            +
                #   {
         | 
| 17 | 
            +
                #     :name         => String,     #
         | 
| 18 | 
            +
                #     "name"        => String,     #
         | 
| 19 | 
            +
                #     :display_name => {}          #
         | 
| 20 | 
            +
                #     
         | 
| 21 | 
            +
                #   }
         | 
| 9 22 | 
             
                def initialize( url, args )
         | 
| 10 23 | 
             
                  @url = url or raise ArgumentError, "must pass :url"
         | 
| 11 24 | 
             
                  unless @url =~ /martservice/
         | 
| @@ -235,15 +248,30 @@ module Biomart | |
| 235 248 |  | 
| 236 249 | 
             
                      if args[:filters]
         | 
| 237 250 | 
             
                        args[:filters].each do |name,value|
         | 
| 238 | 
            -
                          if  | 
| 239 | 
            -
             | 
| 251 | 
            +
                          raise Biomart::ArgumentError, "The filter '#{name}' does not exist" if dataset.filters[name].nil?
         | 
| 252 | 
            +
                          
         | 
| 253 | 
            +
                          if dataset.filters[name].type == 'boolean'
         | 
| 254 | 
            +
                            value = value.downcase if value.is_a? String
         | 
| 255 | 
            +
                            if [true,'included','only'].include?(value)
         | 
| 256 | 
            +
                              xml.Filter( :name => name, :excluded => '0' )
         | 
| 257 | 
            +
                            elsif [false,'excluded'].include?(value)
         | 
| 258 | 
            +
                              xml.Filter( :name => name, :excluded => '1' )
         | 
| 259 | 
            +
                            else
         | 
| 260 | 
            +
                              raise Biomart::ArgumentError, "The boolean filter '#{name}' can only accept 'true/included/only' or 'false/excluded' arguments."
         | 
| 261 | 
            +
                            end
         | 
| 262 | 
            +
                          else
         | 
| 263 | 
            +
                            value = value.join(",") if value.is_a? Array
         | 
| 264 | 
            +
                            xml.Filter( :name => name, :value => value )
         | 
| 240 265 | 
             
                          end
         | 
| 241 | 
            -
                          xml.Filter( :name => name, :value => value )
         | 
| 242 266 | 
             
                        end
         | 
| 243 267 | 
             
                      else
         | 
| 244 268 | 
             
                        dataset.filters.each do |name,filter|
         | 
| 245 269 | 
             
                          if filter.default?
         | 
| 246 | 
            -
                             | 
| 270 | 
            +
                            if filter.type == 'boolean'
         | 
| 271 | 
            +
                              xml.Filter( :name => name, :excluded => filter.default_value )
         | 
| 272 | 
            +
                            else
         | 
| 273 | 
            +
                              xml.Filter( :name => name, :value => filter.default_value )
         | 
| 274 | 
            +
                            end
         | 
| 247 275 | 
             
                          end
         | 
| 248 276 | 
             
                        end
         | 
| 249 277 | 
             
                      end
         | 
    
        data/lib/biomart/filter.rb
    CHANGED
    
    
    
        data/tasks/rcov.rake
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            begin
         | 
| 2 | 
            +
              require "rcov/rcovtask"
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              desc "Analyze code coverage with tests"
         | 
| 5 | 
            +
              Rcov::RcovTask.new do |t|
         | 
| 6 | 
            +
                t.libs << "test"
         | 
| 7 | 
            +
                t.test_files = FileList["test/test*.rb"]
         | 
| 8 | 
            +
                t.verbose = true
         | 
| 9 | 
            +
                t.rcov_opts << "--exclude /gems/,/Library/,spec,features"
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            rescue LoadError
         | 
| 12 | 
            +
              if /^1\.8/ === RUBY_VERSION
         | 
| 13 | 
            +
                puts "[ERROR] Unable to load 'rcov' tasks - please install rcov"
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| 16 | 
            +
             | 
    
        data/tasks/shoulda.rake
    CHANGED
    
    | @@ -1,15 +1,13 @@ | |
| 1 1 | 
             
            begin
         | 
| 2 | 
            -
              require  | 
| 3 | 
            -
             | 
| 4 | 
            -
              require 'rubygems' unless ENV['NO_RUBYGEMS']
         | 
| 5 | 
            -
              require 'shoulda'
         | 
| 6 | 
            -
            end
         | 
| 2 | 
            +
              require "shoulda"
         | 
| 3 | 
            +
              require "rake/testtask"
         | 
| 7 4 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 5 | 
            +
              desc "Run the test suite under /test"
         | 
| 6 | 
            +
              Rake::TestTask.new do |t|
         | 
| 7 | 
            +
                 t.libs << "test"
         | 
| 8 | 
            +
                 t.test_files = FileList["test/test*.rb"]
         | 
| 9 | 
            +
                 t.verbose = true
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            rescue LoadError
         | 
| 12 | 
            +
              puts "[ERROR] Unable to load 'test' task - please install shoulda"
         | 
| 15 13 | 
             
            end
         | 
    
        data/tasks/yard.rake
    ADDED
    
    
    
        data/test/test_biomart.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require  | 
| 1 | 
            +
            require 'test_helper'
         | 
| 2 2 |  | 
| 3 3 | 
             
            class BiomartTest < Test::Unit::TestCase
         | 
| 4 4 | 
             
              def setup
         | 
| @@ -42,12 +42,13 @@ class BiomartTest < Test::Unit::TestCase | |
| 42 42 |  | 
| 43 43 | 
             
              context "A Biomart::Dataset instance" do
         | 
| 44 44 | 
             
                setup do
         | 
| 45 | 
            -
                  @htgt_targ | 
| 46 | 
            -
                  @htgt_trap | 
| 47 | 
            -
                  @kermits | 
| 48 | 
            -
                  @ensembl | 
| 49 | 
            -
                  @ | 
| 50 | 
            -
                  @ | 
| 45 | 
            +
                  @htgt_targ   = @htgt.datasets["htgt_targ"]
         | 
| 46 | 
            +
                  @htgt_trap   = @htgt.datasets["htgt_trap"]
         | 
| 47 | 
            +
                  @kermits     = @htgt.datasets["kermits"]
         | 
| 48 | 
            +
                  @ensembl     = @htgt.datasets["mmusculus_gene_ensembl"]
         | 
| 49 | 
            +
                  @ensembl_var = Biomart::Dataset.new( "http://www.ensembl.org/biomart", { :name => "hsapiens_snp" } )
         | 
| 50 | 
            +
                  @emma        = Biomart::Dataset.new( "http://www.emmanet.org/biomart", { :name => "strains" } )
         | 
| 51 | 
            +
                  @dcc         = Biomart::Dataset.new( "http://www.knockoutmouse.org/biomart", { :name => "dcc" } )
         | 
| 51 52 | 
             
                end
         | 
| 52 53 |  | 
| 53 54 | 
             
                should "have basic metadata" do
         | 
| @@ -252,6 +253,47 @@ class BiomartTest < Test::Unit::TestCase | |
| 252 253 | 
             
                    assert_equal( false, data_row["ikmc_project_id"].nil?, "The required_attributes search has not filtered out nil values." )
         | 
| 253 254 | 
             
                  end
         | 
| 254 255 | 
             
                end
         | 
| 256 | 
            +
                
         | 
| 257 | 
            +
                should "perform searches that involve boolean filters" do
         | 
| 258 | 
            +
                  search_opts = {
         | 
| 259 | 
            +
                    :filters         => { 'with_variation_annotation' => true, 'ensembl_gene' => 'ENSG00000244734' },
         | 
| 260 | 
            +
                    :attributes      => [ 'refsnp_id','chr_name','chrom_start' ],
         | 
| 261 | 
            +
                    :process_results => true
         | 
| 262 | 
            +
                  }
         | 
| 263 | 
            +
                  
         | 
| 264 | 
            +
                  true_results = {}
         | 
| 265 | 
            +
                  assert_nothing_raised( Biomart::BiomartError ) { true_results = @ensembl_var.search( search_opts ) }
         | 
| 266 | 
            +
                  assert( !true_results.empty?, "The search using a boolean filter is empty." )
         | 
| 267 | 
            +
                  
         | 
| 268 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annotation' => 'included' })
         | 
| 269 | 
            +
                  true_results2 = {}
         | 
| 270 | 
            +
                  assert_nothing_raised( Biomart::BiomartError ) { true_results2 = @ensembl_var.search( search_opts ) }
         | 
| 271 | 
            +
                  assert( !true_results2.empty?, "The search using a boolean filter is empty." )
         | 
| 272 | 
            +
                  assert_equal( true_results, true_results2, "Using 'included' for a boolean filter does not give the same result as 'true'." )
         | 
| 273 | 
            +
                  
         | 
| 274 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annotation' => 'only' })
         | 
| 275 | 
            +
                  true_results3 = {}
         | 
| 276 | 
            +
                  assert_nothing_raised( Biomart::BiomartError ) { true_results3 = @ensembl_var.search( search_opts ) }
         | 
| 277 | 
            +
                  assert( !true_results3.empty?, "The search using a boolean filter is empty." )
         | 
| 278 | 
            +
                  assert_equal( true_results, true_results3, "Using 'only' for a boolean filter does not give the same result as 'true'." )
         | 
| 279 | 
            +
                  
         | 
| 280 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annotation' => false })
         | 
| 281 | 
            +
                  false_results = {}
         | 
| 282 | 
            +
                  assert_nothing_raised( Biomart::BiomartError ) { false_results = @ensembl_var.search( search_opts ) }
         | 
| 283 | 
            +
                  assert( !false_results.empty?, "The search using a boolean filter is empty." )
         | 
| 284 | 
            +
                  
         | 
| 285 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annotation' => 'excluded' })
         | 
| 286 | 
            +
                  false_results2 = {}
         | 
| 287 | 
            +
                  assert_nothing_raised( Biomart::BiomartError ) { false_results2 = @ensembl_var.search( search_opts ) }
         | 
| 288 | 
            +
                  assert( !false_results2.empty?, "The search using a boolean filter is empty." )
         | 
| 289 | 
            +
                  assert_equal( false_results, false_results2, "Using 'excluded' for a boolean filter does not give the same result as 'false'." )
         | 
| 290 | 
            +
                  
         | 
| 291 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annotation' => 'flibble' })
         | 
| 292 | 
            +
                  assert_raise( Biomart::ArgumentError ) { @ensembl_var.search( search_opts ) }
         | 
| 293 | 
            +
                  
         | 
| 294 | 
            +
                  search_opts[:filters].merge!({ 'with_variation_annot' => true })
         | 
| 295 | 
            +
                  assert_raise( Biomart::ArgumentError ) { @ensembl_var.search( search_opts ) }
         | 
| 296 | 
            +
                end
         | 
| 255 297 | 
             
              end
         | 
| 256 298 |  | 
| 257 299 | 
             
              context "A Biomart::Attribute instance" do
         | 
| @@ -282,6 +324,7 @@ class BiomartTest < Test::Unit::TestCase | |
| 282 324 |  | 
| 283 325 | 
             
                  assert( !ens_gene_id.name.nil?, "Biomart::Filter.name is nil." )
         | 
| 284 326 | 
             
                  assert( !ens_gene_id.display_name.nil?, "Biomart::Filter.display_name is nil." )
         | 
| 327 | 
            +
                  assert( !ens_gene_id.type.nil?, "Biomart::Filter.type is nil." )
         | 
| 285 328 |  | 
| 286 329 | 
             
                  assert( true_false.include?( ens_gene_id.hidden? ), "Biomart::Filter.hidden? is not returning true/false." )
         | 
| 287 330 | 
             
                  assert( true_false.include?( ens_gene_id.default? ), "Biomart::Filter.default? is not returning true/false." )
         | 
| @@ -294,7 +337,7 @@ class BiomartTest < Test::Unit::TestCase | |
| 294 337 | 
             
                  @not_biomart  = Biomart::Server.new( "http://www.sanger.ac.uk" )
         | 
| 295 338 | 
             
                  @htgt_targ    = @htgt.datasets["htgt_targ"]
         | 
| 296 339 | 
             
                  @bad_dataset  = Biomart::Dataset.new( "http://www.sanger.ac.uk/htgt/biomart", { :name => "wibble" } )
         | 
| 297 | 
            -
                  @good_biomart = Biomart::Server.new( "http://www. | 
| 340 | 
            +
                  @good_biomart = Biomart::Server.new( "http://www.knockoutmouse.org/biomart" )
         | 
| 298 341 | 
             
                end
         | 
| 299 342 |  | 
| 300 343 | 
             
                should "allow you to ping a server" do
         | 
| @@ -308,7 +351,7 @@ class BiomartTest < Test::Unit::TestCase | |
| 308 351 | 
             
                end
         | 
| 309 352 |  | 
| 310 353 | 
             
                should "handle biomart server errors gracefully" do
         | 
| 311 | 
            -
                  assert_raise( Biomart:: | 
| 354 | 
            +
                  assert_raise( Biomart::ArgumentError )  { @htgt_targ.count( :filters => { "wibbleblibbleblip" => "1" } ) }
         | 
| 312 355 | 
             
                  assert_raise( Biomart::AttributeError ) { @htgt_targ.search( :attributes => ["wibbleblibbleblip"] ) }
         | 
| 313 356 | 
             
                  assert_raise( Biomart::DatasetError )   { @bad_dataset.count() }
         | 
| 314 357 |  | 
    
        data/test/test_helper.rb
    CHANGED
    
    | @@ -1,9 +1,16 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
             | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 1 | 
            +
             | 
| 2 | 
            +
            $:.unshift( "#{File.expand_path(File.dirname(__FILE__))}/../lib" )
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'rubygems'
         | 
| 5 | 
            +
            require 'bundler/setup'
         | 
| 6 | 
            +
            require 'shoulda'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            # Set-up SimpleCov (code coverage tool for Ruby 1.9)
         | 
| 9 | 
            +
            if /^1.9/ === RUBY_VERSION
         | 
| 10 | 
            +
              require 'simplecov'
         | 
| 11 | 
            +
              SimpleCov.start do
         | 
| 12 | 
            +
                coverage_dir 'simplecov'
         | 
| 13 | 
            +
              end
         | 
| 6 14 | 
             
            end
         | 
| 7 15 |  | 
| 8 | 
            -
            $:.unshift(File.dirname(__FILE__) + '/../lib')
         | 
| 9 16 | 
             
            require 'biomart'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,12 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: biomart
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash: 23
         | 
| 5 4 | 
             
              prerelease: false
         | 
| 6 5 | 
             
              segments: 
         | 
| 7 6 | 
             
              - 0
         | 
| 8 7 | 
             
              - 2
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 0.2. | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              version: 0.2.1
         | 
| 11 10 | 
             
            platform: ruby
         | 
| 12 11 | 
             
            authors: 
         | 
| 13 12 | 
             
            - Darren Oakley
         | 
| @@ -15,7 +14,7 @@ autorequire: | |
| 15 14 | 
             
            bindir: bin
         | 
| 16 15 | 
             
            cert_chain: []
         | 
| 17 16 |  | 
| 18 | 
            -
            date:  | 
| 17 | 
            +
            date: 2011-02-16 00:00:00 +00:00
         | 
| 19 18 | 
             
            default_executable: 
         | 
| 20 19 | 
             
            dependencies: 
         | 
| 21 20 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| @@ -26,7 +25,6 @@ dependencies: | |
| 26 25 | 
             
                requirements: 
         | 
| 27 26 | 
             
                - - ">="
         | 
| 28 27 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 29 | 
            -
                    hash: 3
         | 
| 30 28 | 
             
                    segments: 
         | 
| 31 29 | 
             
                    - 0
         | 
| 32 30 | 
             
                    version: "0"
         | 
| @@ -40,7 +38,6 @@ dependencies: | |
| 40 38 | 
             
                requirements: 
         | 
| 41 39 | 
             
                - - ">="
         | 
| 42 40 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 43 | 
            -
                    hash: 23
         | 
| 44 41 | 
             
                    segments: 
         | 
| 45 42 | 
             
                    - 2
         | 
| 46 43 | 
             
                    - 10
         | 
| @@ -48,19 +45,16 @@ dependencies: | |
| 48 45 | 
             
              type: :development
         | 
| 49 46 | 
             
              version_requirements: *id002
         | 
| 50 47 | 
             
            - !ruby/object:Gem::Dependency 
         | 
| 51 | 
            -
              name:  | 
| 48 | 
            +
              name: simplecov
         | 
| 52 49 | 
             
              prerelease: false
         | 
| 53 50 | 
             
              requirement: &id003 !ruby/object:Gem::Requirement 
         | 
| 54 51 | 
             
                none: false
         | 
| 55 52 | 
             
                requirements: 
         | 
| 56 53 | 
             
                - - ">="
         | 
| 57 54 | 
             
                  - !ruby/object:Gem::Version 
         | 
| 58 | 
            -
                    hash: 21
         | 
| 59 55 | 
             
                    segments: 
         | 
| 60 | 
            -
                    -  | 
| 61 | 
            -
                     | 
| 62 | 
            -
                    - 1
         | 
| 63 | 
            -
                    version: 2.6.1
         | 
| 56 | 
            +
                    - 0
         | 
| 57 | 
            +
                    version: "0"
         | 
| 64 58 | 
             
              type: :development
         | 
| 65 59 | 
             
              version_requirements: *id003
         | 
| 66 60 | 
             
            description: A ruby API for interacting with Biomart XML based webservices.
         | 
| @@ -70,13 +64,14 @@ executables: [] | |
| 70 64 |  | 
| 71 65 | 
             
            extensions: []
         | 
| 72 66 |  | 
| 73 | 
            -
            extra_rdoc_files: 
         | 
| 74 | 
            -
             | 
| 75 | 
            -
            - Manifest.txt
         | 
| 76 | 
            -
            - README.rdoc
         | 
| 67 | 
            +
            extra_rdoc_files: []
         | 
| 68 | 
            +
             | 
| 77 69 | 
             
            files: 
         | 
| 70 | 
            +
            - .gitignore
         | 
| 71 | 
            +
            - Gemfile
         | 
| 72 | 
            +
            - Gemfile.lock
         | 
| 78 73 | 
             
            - History.txt
         | 
| 79 | 
            -
            - Manifest | 
| 74 | 
            +
            - Manifest
         | 
| 80 75 | 
             
            - README.rdoc
         | 
| 81 76 | 
             
            - Rakefile
         | 
| 82 77 | 
             
            - biomart.gemspec
         | 
| @@ -86,11 +81,12 @@ files: | |
| 86 81 | 
             
            - lib/biomart/dataset.rb
         | 
| 87 82 | 
             
            - lib/biomart/filter.rb
         | 
| 88 83 | 
             
            - lib/biomart/server.rb
         | 
| 84 | 
            +
            - lib/biomart/version.rb
         | 
| 89 85 | 
             
            - script/console
         | 
| 90 | 
            -
            - script/destroy
         | 
| 91 | 
            -
            - script/generate
         | 
| 92 86 | 
             
            - tasks/metrics.rake
         | 
| 87 | 
            +
            - tasks/rcov.rake
         | 
| 93 88 | 
             
            - tasks/shoulda.rake
         | 
| 89 | 
            +
            - tasks/yard.rake
         | 
| 94 90 | 
             
            - test/test_biomart.rb
         | 
| 95 91 | 
             
            - test/test_helper.rb
         | 
| 96 92 | 
             
            has_rdoc: true
         | 
| @@ -98,9 +94,8 @@ homepage: http://github.com/dazoakley/biomart | |
| 98 94 | 
             
            licenses: []
         | 
| 99 95 |  | 
| 100 96 | 
             
            post_install_message: 
         | 
| 101 | 
            -
            rdoc_options: 
         | 
| 102 | 
            -
             | 
| 103 | 
            -
            - README.rdoc
         | 
| 97 | 
            +
            rdoc_options: []
         | 
| 98 | 
            +
             | 
| 104 99 | 
             
            require_paths: 
         | 
| 105 100 | 
             
            - lib
         | 
| 106 101 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| @@ -108,7 +103,6 @@ required_ruby_version: !ruby/object:Gem::Requirement | |
| 108 103 | 
             
              requirements: 
         | 
| 109 104 | 
             
              - - ">="
         | 
| 110 105 | 
             
                - !ruby/object:Gem::Version 
         | 
| 111 | 
            -
                  hash: 3
         | 
| 112 106 | 
             
                  segments: 
         | 
| 113 107 | 
             
                  - 0
         | 
| 114 108 | 
             
                  version: "0"
         | 
| @@ -117,7 +111,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 117 111 | 
             
              requirements: 
         | 
| 118 112 | 
             
              - - ">="
         | 
| 119 113 | 
             
                - !ruby/object:Gem::Version 
         | 
| 120 | 
            -
                  hash: 3
         | 
| 121 114 | 
             
                  segments: 
         | 
| 122 115 | 
             
                  - 0
         | 
| 123 116 | 
             
                  version: "0"
         | 
    
        data/script/destroy
    DELETED
    
    | @@ -1,14 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
            APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            begin
         | 
| 5 | 
            -
              require 'rubigen'
         | 
| 6 | 
            -
            rescue LoadError
         | 
| 7 | 
            -
              require 'rubygems'
         | 
| 8 | 
            -
              require 'rubigen'
         | 
| 9 | 
            -
            end
         | 
| 10 | 
            -
            require 'rubigen/scripts/destroy'
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            ARGV.shift if ['--help', '-h'].include?(ARGV[0])
         | 
| 13 | 
            -
            RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
         | 
| 14 | 
            -
            RubiGen::Scripts::Destroy.new.run(ARGV)
         | 
    
        data/script/generate
    DELETED
    
    | @@ -1,14 +0,0 @@ | |
| 1 | 
            -
            #!/usr/bin/env ruby
         | 
| 2 | 
            -
            APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            begin
         | 
| 5 | 
            -
              require 'rubigen'
         | 
| 6 | 
            -
            rescue LoadError
         | 
| 7 | 
            -
              require 'rubygems'
         | 
| 8 | 
            -
              require 'rubigen'
         | 
| 9 | 
            -
            end
         | 
| 10 | 
            -
            require 'rubigen/scripts/generate'
         | 
| 11 | 
            -
             | 
| 12 | 
            -
            ARGV.shift if ['--help', '-h'].include?(ARGV[0])
         | 
| 13 | 
            -
            RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
         | 
| 14 | 
            -
            RubiGen::Scripts::Generate.new.run(ARGV)
         |