bio-unichem 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+ - jruby-19mode # JRuby in 1.9 mode
6
+ - rbx-19mode
7
+ # - 1.8.7
8
+ # - jruby-18mode # JRuby in 1.8 mode
9
+ # - rbx-18mode
10
+
11
+ # uncomment this line if your project needs to run something other than `rake`:
12
+ # script: bundle exec rspec spec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "> 1.0.0"
12
+ gem "jeweler", "~> 1.8.4"
13
+ gem "bio", ">= 1.4.2"
14
+ gem "rdoc", "~> 3.12"
15
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Mitsuteru Nakao
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,104 @@
1
+ # bio-unichem
2
+
3
+ [![Build Status](https://secure.travis-ci.org/nakao/bio-unichem.png)](http://travis-ci.org/nakao/bio-unichem)
4
+
5
+ BioRuby plugin for [UniChem REST Web service](https://www.ebi.ac.uk/unichem/info/webservices).
6
+
7
+ REST API address
8
+ ```ruby
9
+ Bio::UniChem::REST::UniChem_URI.src_compound_id("CHEMBL12", "1", "2")
10
+ #=> "http://www.ebi.ac.uk/unichem/rest/src_compound_id/CHEMBL12/1/2"
11
+
12
+ Bio::UniChem::REST::UniChem_URI.mapping("4", "1")
13
+ #=> "http://www.ebi.ac.uk/unichem/rest/mapping/4/1"
14
+ ```
15
+
16
+ Get Data
17
+ ```ruby
18
+ client = Bio::UniChem::REST.new
19
+ result = client.src_compound_id("CHEMBL12", "1", "2")
20
+ p result
21
+ #=> [{"src_compound_id"=>"DB00829"}]
22
+ ```
23
+
24
+ Get Data using [Source ID by Short name](https://www.ebi.ac.uk/unichem/ucquery/listSources)
25
+ ```ruby
26
+ client = Bio::UniChem::REST.new
27
+ result = client.src_compound_id("CHEMBL12",
28
+ Bio::UniChem::Sources['chembl'].src_id,
29
+ Bio::UniChem::Sources['drugbank'].src_id)
30
+ p eresult
31
+ #=> [{"src_compound_id"=>"DB00829"}]
32
+ ```
33
+
34
+ Sources and Souece models [list of sources](https://www.ebi.ac.uk/unichem/ucquery/listSources)
35
+ ```ruby
36
+ chembl = Bio::UniChem::Sources['chembl']
37
+ chembl.src_id
38
+ #=> "1"
39
+ chembl.short_name
40
+ #=> "chembl"
41
+ chembl.full_name
42
+ #=> "ChEMBL"
43
+ ```
44
+
45
+ The Ruby script bellow utilizes the Bio UniChem module
46
+ ```ruby
47
+ require 'bio-unichem'
48
+
49
+ ## --------------------------
50
+ ## create client ...
51
+ client = Bio::UniChem::REST.new
52
+
53
+ ## --------------------------
54
+ ## get the data ...
55
+ result = client.src_compound_id("CHEMBL12", Bio::UniChem::Sources["chembl"].src_id)
56
+
57
+ ## --------------------------
58
+ ## print ...
59
+ p result
60
+ ```
61
+
62
+
63
+
64
+ Note: this software is under active development!
65
+
66
+ ## Installation
67
+
68
+ ```sh
69
+ gem install bio-unichem
70
+ ```
71
+
72
+ ## Usage
73
+
74
+ ```ruby
75
+ require 'bio-unichem'
76
+ ```
77
+
78
+ The API doc is online. For more code examples see the test files in
79
+ the source tree.
80
+
81
+ ## Project home page
82
+
83
+ Information on the source tree, documentation, examples, issues and
84
+ how to contribute, see
85
+
86
+ http://github.com/nakao/bio-unichem
87
+
88
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
89
+
90
+ ## Cite
91
+
92
+ If you use this software, please cite one of
93
+
94
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
95
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
96
+
97
+ ## Biogems.info
98
+
99
+ This Biogem is published at [#bio-unichem](http://biogems.info/index.html)
100
+
101
+ ## Copyright
102
+
103
+ Copyright (c) 2013 Mitsuteru Nakao. See LICENSE.txt for further details.
104
+
@@ -0,0 +1,45 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "bio-unichem"
18
+ gem.homepage = "http://github.com/nakao/bioruby-unichem"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{BioRuby plugin for UniChem REST Web service}
21
+ gem.description = %Q{BioRuby plugin for UniChem REST Web service}
22
+ gem.email = "mitsuteru.nakao@gmail.com"
23
+ gem.authors = ["Mitsuteru Nakao"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ task :default => :test
36
+
37
+ require 'rdoc/task'
38
+ Rake::RDocTask.new do |rdoc|
39
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
40
+
41
+ rdoc.rdoc_dir = 'rdoc'
42
+ rdoc.title = "bio-unichem #{version}"
43
+ rdoc.rdoc_files.include('README*')
44
+ rdoc.rdoc_files.include('lib/**/*.rb')
45
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,12 @@
1
+ # Please require your code below, respecting the naming conventions in the
2
+ # bioruby directory tree.
3
+ #
4
+ # For example, say you have a plugin named bio-plugin, the only uncommented
5
+ # line in this file would be
6
+ #
7
+ # require 'bio/bio-plugin/plugin'
8
+ #
9
+ # In this file only require other files. Avoid other source code.
10
+
11
+ require 'bio-unichem/unichem.rb'
12
+
@@ -0,0 +1,165 @@
1
+ module Bio
2
+ class UniChem
3
+
4
+ # Bio::UniChem::Source
5
+ #
6
+ # hash = {'src_id' => '1, 'short_name' => ... }
7
+ # chembl = Bio::UniChem::Source.new(hash)
8
+ # chembl.src_id
9
+ # #=> "1"
10
+ # chembl.short_name
11
+ # #=> "chembl"
12
+ # chembl.full_name
13
+ # #=> "ChEMBL"
14
+ #
15
+ class Source
16
+ attr_reader :src_id
17
+ attr_reader :short_name
18
+ attr_reader :full_name
19
+ attr_reader :description
20
+ attr_reader :process_of_data_acquisition
21
+
22
+
23
+ # Bio::UniChem::Source.new(hash)
24
+ def initialize(hash = nil)
25
+ @src_id = hash["src_id"]
26
+ @short_name = hash["short_name"]
27
+ @full_name = hash["full_name"]
28
+ @description = hash["description"]
29
+ @process_of_data_acquisition = hash["process_of_data_acquisition"]
30
+ end
31
+
32
+ end
33
+
34
+ # Bio::UniChem::Sources
35
+ #
36
+ # Usage
37
+ # aSource = Bio::UniChem::Sources["chembl"]
38
+ # aSource = Bio::UniChem::Sources["1"]
39
+ # aSource.src_id
40
+ # #=> "1"
41
+ # aSource.short_name
42
+ # #=> "chembl"
43
+ # aSource.full_name
44
+ # #=> "ChEMBL"
45
+ #
46
+ class Sources
47
+
48
+ # 2013-02-09 at https://www.ebi.ac.uk/unichem/ucquery/listSources
49
+ # src_id
50
+ # Short name
51
+ # Full name
52
+ # Description
53
+ # Process of Data Acquisition
54
+ data = %q|
55
+ 1
56
+ chembl
57
+ ChEMBL
58
+ A database of bioactive drug-like small molecules and associated bioactivities abstracted from the scientific literature
59
+ Standard InChIs and Keys provided on ftp site for each release.
60
+ //
61
+ 2
62
+ drugbank
63
+ DrugBank
64
+ A database that combines drug (i.e. chemical, pharmacological and pharmaceutical) data with drug target (i.e. sequence, structure, and pathway) information.
65
+ Standard InChIs and Keys provided within sd file on ftp site for each release.
66
+ //
67
+ 3
68
+ pdb
69
+ PDBe (Protein Data Bank Europe)
70
+ The European resource for the collection, organisation and dissemination of data on biological macromolecular structures, including structures of small molecule ligands for proteins.
71
+ Standard InChIs and Keys provided by direct querying of Oracle DB.
72
+ //
73
+ 4
74
+ iuphar
75
+ International Union of Basic and Clinical Pharmacology A resource for representing the interests of pharmacologists around the world. DB contains structures of small molecule ligands of pharmacological significance.
76
+ Standard InChIs and Keys provided by email on request.
77
+ //
78
+ 5
79
+ pubchem_dotf
80
+ PubChem ('Drugs of the Future' subset) A subset of the PubChem DB: from the original depositor 'drugs of the future' (Prous).
81
+ Mol files for SIDs downloaded manually, via PubChem interface, and Standard InChIs and Keys generated by InChI software. SIDs used as identifiers.
82
+ //
83
+ 6
84
+ kegg_ligand
85
+ KEGG (Kyoto Encyclopedia of Genes and Genomes) Ligand
86
+ KEGG LIGAND is a composite DB consisting of COMPOUND, GLYCAN, REACTION, RPAIR, RCLASS, and ENZYME DBs, whose entries are identified by C, G, R, RP, RC, and EC numbers, respectively.
87
+ Mol files were downloaded manually prior to this download becoming private. Standard InChIs and Keys generated by InChI software.
88
+ //
89
+ 7
90
+ chebi
91
+ ChEBI (Chemical Entities of Biological Interest).
92
+ ChEBI is a freely available dictionary of molecular entities focused on 'small' chemical compounds
93
+ Std InChis (but no keys) provided on ftp site. Keys generated by UniChem. Only 'three star' compounds downloaded
94
+ //
95
+ 8
96
+ nih_ncc
97
+ NIH Clinical Collection
98
+ Collections of plated arrays of small molecules that have a history of use in human clinical trials. Assembled by the National Institutes of Health (NIH) through the Molecular Libraries Roadmap Initiative
99
+ Mol files downloaded manually and Standard InChIs and Keys generated by InChI software
100
+ //
101
+ 9
102
+ zinc
103
+ ZINC
104
+ A free database of commercially-available compounds for virtual screening, provided by the Shoichet Laboratory in the Department of Pharmaceutical Chemistry at the University of California, San Francisco (UCSF). [Irwin and Shoichet, J. Chem. Inf. Model. 2005;45(1):177-82]
105
+ SD file ('Standard', 'All Purchasable' of ~17.8 million) downloaded from source and InChis generated by UniChem
106
+ //
107
+ 10
108
+ emolecules
109
+ eMolecules
110
+ A free chemical structure search engine containing millions of public domain structures. Pricing, availabilities, and vendor information requires an eMolecules Plus subscription.
111
+ Downloaded as an SD file from source, Converted to InChI and INChIKeys by UniChem
112
+ //
113
+ 11
114
+ ibm
115
+ IBM strategic IP insight platform and the National Institutes of Health
116
+ A massive, searchable database of chemical and pharmaceutical data, extracted from millions of patents and scientific literature. Identifiers in UniChem are IBM compound identifiers.
117
+ SMILES download available. Converted to InChi by PPP in house.
118
+ //
119
+ 12
120
+ atlas
121
+ Gene Expression Atlas
122
+ The Gene Expression Atlas is a semantically enriched database of meta-analysis based summary statistics over a curated subset of ArrayExpress Archive, servicing queries for condition-specific gene expression patterns as well as broader exploratory searches for biologically interesting genes/samples.
123
+ Currently extracted from compound names.
124
+ //
125
+ 13
126
+ patents
127
+ IBM strategic IP insight platform and the National Institutes of Health.
128
+ Data, provided by IBM-NIH, was originally extracted from patents from three publishing bodies (US, EPO and WIPO) with publication dates through (including) 2000-12-31. For UniChem, these data were parsed to include only whole molecules present in either the title or claims fields. Further filters included removal of: 1. All molecules mapping to > 10,000 patents, 2. Non-organic molecules, 3. Small molecules (mw <90, number of atoms < 7). In addition, for structures mapping to >100 patents, only 100 randomly selected patents were selected. Identifiers in UniChem are patent number identifiers
129
+ SMILES download available. Converted to InChi in house. Patent Ids used for Ids instead of cpd_ids. Data set filtered to remove compounds not appearing in the title or claims sections of the patent, and to remove very frequently occurring compounds
130
+ |
131
+ delimiter = "/\/\//"
132
+ Data = data.strip.split(delimiter).map do |record|
133
+ t = record.strip.split("\n").map {|line| line.strip }
134
+ Bio::UniChem::Source.new({"src_id" => t[0],
135
+ "short_name" => t[1],
136
+ "full_name" => t[2],
137
+ "description" => t[3],
138
+ "process_of_data_acquisition" => t[4]})
139
+ end
140
+
141
+ # Bio::UniChem::Sources.find_by_src_id(src_id) #=> aSource
142
+ def self.find_by_src_id(src_id)
143
+ Data.find {|x| x.src_id == src_id.to_s }
144
+ end
145
+
146
+ # Bio::UniChem::Sources.find_by_short_name(short_name) #=> aSource
147
+ def self.find_by_short_name(short_name)
148
+ Data.find {|x| x.short_name == short_name }
149
+ end
150
+
151
+ # Bio::UniChem::Sources[arg] #=> aSource
152
+ # arg : src_id, short_name
153
+ def self.[](arg)
154
+ case arg
155
+ when /^\d$/
156
+ self.find_by_src_id(arg)
157
+ else
158
+ self.find_by_short_name(arg)
159
+ end
160
+ end
161
+ end
162
+
163
+ end
164
+
165
+ end
@@ -0,0 +1,168 @@
1
+ require 'bio'
2
+ require 'open-uri'
3
+ require 'json'
4
+
5
+ module Bio
6
+
7
+ class UniChem
8
+
9
+
10
+ # UniChem REST Web service API Client.
11
+ #
12
+ # # URI
13
+ # Bio::UniChem::REST::UniChem_URI
14
+ #
15
+ class REST
16
+
17
+ HOST_NAME = "www.ebi.ac.uk"
18
+ API_ROOT = "unichem/rest"
19
+ BASE_URL = "https://" + HOST_NAME + "/" + API_ROOT
20
+
21
+ # Generate URIs for UniChem REST Web service
22
+ # Bio::UniChem::REST::UniChem_URI
23
+ module UniChem_URI
24
+
25
+ def self.address(path)
26
+ "#{BASE_URL}/#{path}"
27
+ end
28
+
29
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id/CHEMBL12/1
30
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id/CHEMBL12/1/2
31
+ def self.src_compound_id(src_compound_id, src_id, to_src_id = nil)
32
+ path = [src_compound_id, src_id, to_src_id].compact.join("/")
33
+ address("src_compound_id/#{path}")
34
+ end
35
+
36
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id_all/CHEMBL12/1
37
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id_all/CHEMBL12/1/2
38
+ def self.src_compound_id_all(src_compound_id, src_id, to_src_id = nil)
39
+ path = [src_compound_id, src_id, to_src_id].compact.join("/")
40
+ address("src_compound_id_all/#{path}")
41
+ end
42
+
43
+ # Example: http://www.ebi.ac.uk/unichem/rest/mapping/4/1
44
+ def self.mapping(src_id, to_src_id)
45
+ address("mapping/#{src_id}/#{to_src_id}")
46
+ end
47
+
48
+ # Example: http://www.ebi.ac.uk/unichem/rest/inchikey/AAOVKJBEBIDNHE-UHFFFAOYSA-N
49
+ def self.inchikey(inchikey)
50
+ address("inchikey/#{inchikey}")
51
+ end
52
+
53
+ # Example: http://www.ebi.ac.uk/unichem/rest/inchikey_all/AAOVKJBEBIDNHE-UHFFFAOYSA-N
54
+ def self.inchikey_all(inchikey)
55
+ address("inchikey_all/#{inchikey}")
56
+ end
57
+
58
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_ids/
59
+ def self.src_ids
60
+ address("src_ids/")
61
+ end
62
+
63
+ # Example: http://www.ebi.ac.uk/unichem/rest/sources/1
64
+ def self.sources(src_id)
65
+ address("sources/#{src_id}")
66
+ end
67
+
68
+ # Example: http://www.ebi.ac.uk/unichem/rest/structure/CHEMBL12/1
69
+ def self.structure(src_compound_id, src_id)
70
+ address("structure/#{src_compound_id}/#{src_id}")
71
+ end
72
+
73
+ # Example: http://www.ebi.ac.uk/unichem/rest/structure_all/CHEMBL12/1
74
+ def self.structure_all(src_compound_id, src_id)
75
+ address("structure_all/#{src_compound_id}/#{src_id}")
76
+ end
77
+
78
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id_url/CHEMBL12/1/2
79
+ def self.src_compound_id_url(src_compound_id, src_id, to_src_id)
80
+ address("src_compound_id_url/#{src_compound_id}/#{src_id}/#{to_src_id}")
81
+ end
82
+
83
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id_all_obsolete/DB07699/2
84
+ # Example: http://www.ebi.ac.uk/unichem/rest/src_compound_id_all_obsolete/DB07699/2/1
85
+ def self.src_compound_id_all_obsolete(src_compound_id, src_id, to_src_id = nil)
86
+ path = [src_compound_id, src_id, to_src_id].compact.join("/")
87
+ address("src_compound_id_all_obsolete/#{path}")
88
+ end
89
+
90
+ # Example: http://www.ebi.ac.uk/unichem/rest/verbose_inchikey/HAUGRYOERYOXHX-UHFFFAOYSA-N
91
+ def self.verbose_inchikey(inchikey)
92
+ address("verbose_inchikey/#{inchikey}")
93
+ end
94
+
95
+ end
96
+
97
+
98
+ # Bio::UniChem::REST.new
99
+ def initialize
100
+ @header = {
101
+ 'User-Agent' => "Bio::UniChem, BioRuby/#{Bio::BIORUBY_VERSION_ID}"
102
+ }
103
+ @debug = false
104
+ @status = ""
105
+ end
106
+
107
+ #
108
+ def get(uri)
109
+ res = open(uri, @header)
110
+ @status = res.status
111
+ return JSON(res.read)
112
+ end
113
+ private :get
114
+
115
+ #
116
+ def src_compound_id(src_compound_id, src_id, to_src_id = nil)
117
+ get(Bio::UniChem::REST::UniChem_URI.src_compound_id(src_compound_id, src_id, to_src_id))
118
+ end
119
+
120
+ def src_compound_id_all(src_compound_id, src_id, to_src_id = nil)
121
+ get(Bio::UniChem::REST::UniChem_URI.src_compound_id_all(src_compound_id, src_id, to_src_id))
122
+ end
123
+
124
+ def mapping(src_id, to_src_id)
125
+ get(Bio::UniChem::REST::UniChem_URI.mapping(src_id, to_src_id))
126
+ end
127
+
128
+ def inchikey(inchikey)
129
+ get(Bio::UniChem::REST::UniChem_URI.inchikey(inchikey))
130
+ end
131
+
132
+ def inchikey_all(inchikey)
133
+ get(Bio::UniChem::REST::UniChem_URI. inchikey_all(inchikey))
134
+ end
135
+
136
+ def src_ids
137
+ get(Bio::UniChem::REST::UniChem_URI.src_ids)
138
+ end
139
+
140
+ def sources(src_id)
141
+ get(Bio::UniChem::REST::UniChem_URI.sources(src_id))
142
+ end
143
+
144
+ def structure(src_compound_id, src_id)
145
+ get(Bio::UniChem::REST::UniChem_URI.structure(src_compound_id, src_id))
146
+ end
147
+
148
+ def structure_all(src_compound_id, src_id)
149
+ get(Bio::UniChem::REST::UniChem_URI.structure_all(src_compound_id, src_id))
150
+ end
151
+
152
+ def src_compound_id_url(src_compound_id, src_id, to_src_id)
153
+ get(Bio::UniChem::REST::UniChem_URI.src_compound_id_url(src_compound_id, src_id, to_src_id))
154
+ end
155
+
156
+ def src_compound_id_all_obsolete(src_compound_id, src_id, to_src_id = nil)
157
+ get(Bio::UniChem::REST::UniChem_URI.src_compound_id_all_obsolete(src_compound_id, src_id, to_src_id = nil))
158
+ end
159
+
160
+ def verbose_inchikey(inchikey)
161
+ get(Bio::UniChem::REST::UniChem_URI.verbose_inchikey(inchikey))
162
+ end
163
+
164
+ end
165
+
166
+ end
167
+
168
+ end
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'bio-unichem'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ # testing script for Jnekins task
4
+ # test/test.sh test_bio-unichem-model.rb
5
+
6
+ cd /Users/mitsuteru/Applications/biogems/bioruby-unichem/
7
+ /opt/local/bin/ruby1.9 -I lib -I test test/${1}
@@ -0,0 +1,75 @@
1
+ require 'helper'
2
+ require 'bio-unichem/model.rb'
3
+
4
+ class TestBioUniChemModelSource < Test::Unit::TestCase
5
+ def setup
6
+ record = {
7
+ 'src_id' => "1",
8
+ "short_name" => "chembl",
9
+ "description" => "A database of bioactive drug-like small molecules and associated bioactivities abstracted from the scientific literature",
10
+ "full_name" => "ChEMBL",
11
+ "process_of_data_acquisition" => "Standard InChIs and Keys provided on ftp site for each release.",
12
+ }
13
+ @obj = Bio::UniChem::Source.new(record)
14
+ end
15
+
16
+
17
+ def test_src_id
18
+ assert_equal(@obj.src_id, "1")
19
+ end
20
+
21
+ def test_short_name
22
+ assert_equal(@obj.short_name, "chembl")
23
+ end
24
+
25
+ def test_description
26
+ assert_equal(@obj.description, "A database of bioactive drug-like small molecules and associated bioactivities abstracted from the scientific literature")
27
+ end
28
+
29
+ def test_full_name
30
+ assert_equal(@obj.full_name, "ChEMBL")
31
+ end
32
+
33
+ def test_process_of_data_acquisition
34
+ assert_equal(@obj.process_of_data_acquisition, "Standard InChIs and Keys provided on ftp site for each release.")
35
+ end
36
+
37
+ end
38
+
39
+
40
+
41
+
42
+ class TestBioUniChemModelSources < Test::Unit::TestCase
43
+ def setup
44
+ @o = Bio::UniChem::Sources.new
45
+ end
46
+
47
+ def test_new
48
+ assert_equal(@o.class, Bio::UniChem::Sources)
49
+ end
50
+
51
+ def test_find_by_src_id
52
+ assert_equal(Bio::UniChem::Sources.find_by_src_id("1").class, Bio::UniChem::Source)
53
+ end
54
+
55
+ def test_find_by_src_id_integer
56
+ assert_equal(Bio::UniChem::Sources.find_by_src_id(1).class, Bio::UniChem::Source)
57
+ end
58
+
59
+
60
+ def test_find_by_short_name
61
+ assert_equal(Bio::UniChem::Sources.find_by_short_name("chembl").class, Bio::UniChem::Source)
62
+ assert_equal(Bio::UniChem::Sources.find_by_short_name("chembl").src_id, "1")
63
+ end
64
+
65
+ def test_a_short_name
66
+ assert_equal(Bio::UniChem::Sources["chembl"].class, Bio::UniChem::Source)
67
+ assert_equal(Bio::UniChem::Sources["chembl"].src_id, "1")
68
+ end
69
+
70
+ def test_a_src_id
71
+ assert_equal(Bio::UniChem::Sources["1"].class, Bio::UniChem::Source)
72
+ assert_equal(Bio::UniChem::Sources["1"].short_name, "chembl")
73
+ end
74
+
75
+ end
@@ -0,0 +1,169 @@
1
+ require 'helper'
2
+ require 'bio-unichem/unichem.rb'
3
+
4
+ class TestBioUniChemRESTClient < Test::Unit::TestCase
5
+ def setup
6
+ @obj = Bio::UniChem::REST.new
7
+ end
8
+
9
+ def test_src_compound_id_2
10
+ res = @obj.src_compound_id("CHEMBL12", "1")
11
+ assert_equal(res.class, Array)
12
+ assert_equal(res.first.class, Hash)
13
+ end
14
+
15
+ def test_src_compound_id_2_src_id
16
+ res = @obj.src_compound_id("CHEMBL12", "1")
17
+ assert_equal(res.class, Array)
18
+ assert_equal(res.first.class, Hash)
19
+ end
20
+
21
+ def test_src_compound_id_3
22
+ res = @obj.src_compound_id("CHEMBL12", "1", "2")
23
+ assert_equal(res.class, Array)
24
+ assert_equal(res.first.class, Hash)
25
+ assert_equal(res.first["src_compound_id"], "DB00829")
26
+ end
27
+
28
+ def test_src_compound_id_3_src_id
29
+ res = @obj.src_compound_id("CHEMBL12", "1", "2")
30
+ assert_equal(res.class, Array)
31
+ assert_equal(res.first.class, Hash)
32
+ assert_equal(res.first["src_compound_id"], "DB00829")
33
+ end
34
+
35
+ def test_src_compound_id_all_2
36
+ res = @obj.src_compound_id_all("CHEMBL12", "1")
37
+ t = res.find {|x| x['src_id'] == "1" }
38
+ assert_equal(res.class, Array)
39
+ assert_equal(t.class, Hash)
40
+ assert_equal(t["assignment"], "1")
41
+ assert_equal(t["src_id"], "1")
42
+ assert_equal(t["src_compound_id"], "CHEMBL12")
43
+ end
44
+
45
+ def test_src_compound_id_all_3
46
+ res = @obj.src_compound_id_all("CHEMBL12", "1", "2")
47
+ t = res.find {|x| x['src_compound_id'] == "DB00829" }
48
+ assert_equal(res.class, Array)
49
+ assert_equal(t.class, Hash)
50
+ assert_equal(t["assignment"], "1")
51
+ assert_equal(t["src_compound_id"], "DB00829")
52
+ end
53
+
54
+ def test_mapping
55
+ res = @obj.mapping("4", "1")
56
+ t = res.find {|x| x['1'] == "CHEMBL247132" }
57
+ assert_equal(res.class, Array)
58
+ assert_equal(t.class, Hash)
59
+ assert_equal(t["1"], "CHEMBL247132")
60
+ assert_equal(t["4"], "1592")
61
+ end
62
+
63
+ def test_mapping_src_id
64
+ res = @obj.mapping("4", "1")
65
+ t = res.find {|x| x['1'] == "CHEMBL247132" }
66
+ assert_equal(res.class, Array)
67
+ assert_equal(t.class, Hash)
68
+ assert_equal(t["1"], "CHEMBL247132")
69
+ assert_equal(t["4"], "1592")
70
+ end
71
+
72
+ def test_inchikey
73
+ res = @obj.inchikey("AAOVKJBEBIDNHE-UHFFFAOYSA-N")
74
+ t = res.find {|x| x['src_id'] == "1" }
75
+ assert_equal(res.class, Array)
76
+ assert_equal(t.class, Hash)
77
+ assert_equal(t["src_id"], "1")
78
+ assert_equal(t["src_compound_id"], "CHEMBL12")
79
+ end
80
+
81
+ def test_inchikey_all
82
+ res = @obj.inchikey_all("AAOVKJBEBIDNHE-UHFFFAOYSA-N")
83
+ t = res.find {|x| x['src_id'] == "1" }
84
+ assert_equal(res.class, Array)
85
+ assert_equal(t.class, Hash)
86
+ assert_equal(t["assignment"], "1")
87
+ assert_equal(t["src_id"], "1")
88
+ assert_equal(t["src_compound_id"], "CHEMBL12")
89
+ end
90
+
91
+ def test_src_ids
92
+ res = @obj.src_ids
93
+ assert_equal(res.class, Array)
94
+ assert_equal(res.first.class, Hash)
95
+ assert_equal(res.first["src_id"], "1")
96
+ end
97
+
98
+ def test_sources
99
+ res = @obj.sources("1")
100
+ assert_equal(res.class, Array)
101
+ assert_equal(res.first.class, Hash)
102
+ assert_equal(res.first["src_id"], "1")
103
+ end
104
+
105
+ def test_structure
106
+ res = @obj.structure("CHEMBL12", "1")
107
+ t = res.find {|x| x['standardinchikey'] == "AAOVKJBEBIDNHE-UHFFFAOYSA-N" }
108
+ assert_equal(res.class, Array)
109
+ assert_equal(t.class, Hash)
110
+ assert_equal(t["standardinchikey"], "AAOVKJBEBIDNHE-UHFFFAOYSA-N")
111
+ assert_equal(t["standardinchi"],
112
+ "InChI=1S/C16H13ClN2O/c1-19-14-8-7-12(17)9-13(14)16(18-10-15(19)20)11-5-3-2-4-6-11/h2-9H,10H2,1H3")
113
+ end
114
+
115
+ def test_structure_all
116
+ res = @obj.structure_all("CHEMBL12", "1")
117
+ assert_equal(res.class, Array)
118
+ assert_equal(res.first.class, Hash)
119
+ assert_equal(res.first["assignment"], "1")
120
+ assert_equal(res.first["standardinchikey"], "AAOVKJBEBIDNHE-UHFFFAOYSA-N")
121
+ assert_equal(res.first["standardinchi"],
122
+ "InChI=1S/C16H13ClN2O/c1-19-14-8-7-12(17)9-13(14)16(18-10-15(19)20)11-5-3-2-4-6-11/h2-9H,10H2,1H3")
123
+ end
124
+
125
+ def test_src_compound_id_url
126
+ res = @obj.src_compound_id_url("CHEMBL12", "1", "2")
127
+ assert_equal(res.class, Array)
128
+ assert_equal(res.first.class, Hash)
129
+ assert_equal(res.first["url"], "http://www.drugbank.ca/drugs/DB00829")
130
+ end
131
+
132
+ def test_src_compound_id_all_obsolete_2
133
+ res = @obj.src_compound_id_all_obsolete("DB07699", "2")
134
+ t = res.find {|x| x['src_id'] == "1" }
135
+ assert_equal(res.class, Array)
136
+ assert_equal(t.class, Hash)
137
+ assert_equal(t["assignment"], "1")
138
+ assert_equal(t["src_id"], "1")
139
+ assert_equal(t["UCI"], "304698")
140
+ assert_equal(t["src_compound_id"], "CHEMBL12")
141
+ end
142
+
143
+ def test_src_compound_id_all_obsolete_3
144
+ res = @obj.src_compound_id_all_obsolete("DB07699", "2", "1")
145
+ t = res.find {|x| x['src_id'] == "1" }
146
+ assert_equal(res.class, Array)
147
+ assert_equal(t.class, Hash)
148
+ assert_equal(t["assignment"], "1")
149
+ assert_equal(t["src_id"], "1")
150
+ assert_equal(t["UCI"], "304698")
151
+ assert_equal(t["src_compound_id"], "CHEMBL12")
152
+ end
153
+
154
+ def test_verbose_inchikey
155
+ res = @obj.verbose_inchikey("HAUGRYOERYOXHX-UHFFFAOYSA-N")
156
+ t = res.find {|x| x['name'] == "chembl" }
157
+ assert_equal(res.class, Array)
158
+ assert_equal(res.first.class, Hash)
159
+ assert_equal(res.first["name"], "chembl")
160
+ assert_equal(res.first["description"], "A database of bioactive drug-like small molecules and associated bioactivities abstracted from the scientific literature")
161
+ assert_equal(res.first["name_long"], "ChEMBL")
162
+ assert_equal(res.first["src_compound_id"], ["CHEMBL68500"])
163
+ assert_equal(res.first["base_id_url"], "https://www.ebi.ac.uk/chembldb/compound/inspect/")
164
+ assert_equal(res.first["src_id"], "1")
165
+ assert_equal(res.first["base_id_url_available"], "1")
166
+ assert_equal(res.first["src_url"], "https://www.ebi.ac.uk/chembl/")
167
+ end
168
+
169
+ end
@@ -0,0 +1,99 @@
1
+ require 'helper'
2
+ require 'bio-unichem/unichem.rb'
3
+
4
+ class TestBioUniChemURI < Test::Unit::TestCase
5
+ def setup
6
+ @obj = Bio::UniChem::REST::UniChem_URI
7
+ end
8
+
9
+ def test_src_compound_id_2
10
+ assert_equal(
11
+ @obj.src_compound_id("CHEMBL12", "1"),
12
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id/CHEMBL12/1")
13
+ end
14
+
15
+ def test_src_compound_id_3
16
+ assert_equal(
17
+ @obj.src_compound_id("CHEMBL12", "1", "2"),
18
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id/CHEMBL12/1/2")
19
+ end
20
+
21
+ def test_src_compound_id_all_2
22
+ assert_equal(
23
+ @obj.src_compound_id_all("CHEMBL12", "1"),
24
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id_all/CHEMBL12/1")
25
+ end
26
+
27
+ def test_src_compound_id_all_3
28
+ assert_equal(
29
+ @obj.src_compound_id_all("CHEMBL12", "1", "2"),
30
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id_all/CHEMBL12/1/2")
31
+ end
32
+
33
+ def test_mapping
34
+ assert_equal(
35
+ @obj.mapping("4", "1"),
36
+ "https://www.ebi.ac.uk/unichem/rest/mapping/4/1")
37
+ end
38
+
39
+ def test_inchikey
40
+ assert_equal(
41
+ @obj.inchikey("AAOVKJBEBIDNHE-UHFFFAOYSA-N"),
42
+ "https://www.ebi.ac.uk/unichem/rest/inchikey/AAOVKJBEBIDNHE-UHFFFAOYSA-N")
43
+ end
44
+
45
+ def test_inchikey_all
46
+ assert_equal(
47
+ @obj.inchikey_all("AAOVKJBEBIDNHE-UHFFFAOYSA-N"),
48
+ "https://www.ebi.ac.uk/unichem/rest/inchikey_all/AAOVKJBEBIDNHE-UHFFFAOYSA-N")
49
+ end
50
+
51
+ def test_src_ids
52
+ assert_equal(
53
+ @obj.src_ids,
54
+ "https://www.ebi.ac.uk/unichem/rest/src_ids/")
55
+ end
56
+
57
+ def test_sources
58
+ assert_equal(
59
+ @obj.sources("1"),
60
+ "https://www.ebi.ac.uk/unichem/rest/sources/1")
61
+ end
62
+
63
+ def test_structure
64
+ assert_equal(
65
+ @obj.structure("CHEMBL12", "1"),
66
+ "https://www.ebi.ac.uk/unichem/rest/structure/CHEMBL12/1")
67
+ end
68
+
69
+ def test_structure_all
70
+ assert_equal(
71
+ @obj.structure_all("CHEMBL12", "1"),
72
+ "https://www.ebi.ac.uk/unichem/rest/structure_all/CHEMBL12/1")
73
+ end
74
+
75
+ def test_src_compound_id_url
76
+ assert_equal(
77
+ @obj.src_compound_id_url("CHEMBL12", "1", "2"),
78
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id_url/CHEMBL12/1/2")
79
+ end
80
+
81
+ def test_src_compound_id_all_obsolete_2
82
+ assert_equal(
83
+ @obj.src_compound_id_all_obsolete("DB07699", "2"),
84
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id_all_obsolete/DB07699/2")
85
+ end
86
+
87
+ def test_src_compound_id_all_obsolete_3
88
+ assert_equal(
89
+ @obj.src_compound_id_all_obsolete("DB07699", "2", "1"),
90
+ "https://www.ebi.ac.uk/unichem/rest/src_compound_id_all_obsolete/DB07699/2/1")
91
+ end
92
+
93
+ def test_verbose_inchikey
94
+ assert_equal(
95
+ @obj.verbose_inchikey("HAUGRYOERYOXHX-UHFFFAOYSA-N"),
96
+ "https://www.ebi.ac.uk/unichem/rest/verbose_inchikey/HAUGRYOERYOXHX-UHFFFAOYSA-N")
97
+ end
98
+
99
+ end
@@ -0,0 +1,5 @@
1
+ require 'helper'
2
+ require 'bio-unichem/unichem.rb'
3
+
4
+ class TestBioUnichem < Test::Unit::TestCase
5
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bio-unichem
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mitsuteru Nakao
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-02-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: shoulda
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rdoc
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '3.12'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.12'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>'
52
+ - !ruby/object:Gem::Version
53
+ version: 1.0.0
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>'
60
+ - !ruby/object:Gem::Version
61
+ version: 1.0.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: jeweler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.8.4
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.8.4
78
+ - !ruby/object:Gem::Dependency
79
+ name: bio
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: 1.4.2
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: 1.4.2
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '3.12'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.12'
110
+ description: BioRuby plugin for UniChem REST Web service
111
+ email: mitsuteru.nakao@gmail.com
112
+ executables: []
113
+ extensions: []
114
+ extra_rdoc_files:
115
+ - LICENSE.txt
116
+ - README.md
117
+ files:
118
+ - .document
119
+ - .travis.yml
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - VERSION
125
+ - lib/bio-unichem.rb
126
+ - lib/bio-unichem/model.rb
127
+ - lib/bio-unichem/unichem.rb
128
+ - test/helper.rb
129
+ - test/test.sh
130
+ - test/test_bio-unichem-model.rb
131
+ - test/test_bio-unichem-rest-client.rb
132
+ - test/test_bio-unichem-rest-uri.rb
133
+ - test/test_bio-unichem.rb
134
+ homepage: http://github.com/nakao/bioruby-unichem
135
+ licenses:
136
+ - MIT
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ segments:
148
+ - 0
149
+ hash: -2975473207476778755
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ none: false
152
+ requirements:
153
+ - - ! '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 1.8.23
159
+ signing_key:
160
+ specification_version: 3
161
+ summary: BioRuby plugin for UniChem REST Web service
162
+ test_files: []