bio-chembl 0.1.1

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,11 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>bioruby-chembl</name>
4
+ <comment></comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ </buildSpec>
9
+ <natures>
10
+ </natures>
11
+ </projectDescription>
@@ -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,17 @@
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.3"
13
+ gem "bio", ">= 1.4.2"
14
+ gem "rdoc", "~> 3.12"
15
+ gem "curb", ">= 0"
16
+ gem "nokogiri", "~> 1.5.5"
17
+ end
@@ -0,0 +1,33 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ bio (1.4.2)
5
+ curb (0.8.0)
6
+ git (1.2.5)
7
+ jeweler (1.8.3)
8
+ bundler (~> 1.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rdoc
12
+ json (1.7.3)
13
+ nokogiri (1.5.5)
14
+ rake (0.9.2.2)
15
+ rdoc (3.12)
16
+ json (~> 1.4)
17
+ shoulda (3.0.1)
18
+ shoulda-context (~> 1.0.0)
19
+ shoulda-matchers (~> 1.0.0)
20
+ shoulda-context (1.0.0)
21
+ shoulda-matchers (1.0.0)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ bio (>= 1.4.2)
28
+ bundler (>= 1.0.0)
29
+ curb
30
+ jeweler (~> 1.8.3)
31
+ nokogiri (~> 1.5.5)
32
+ rdoc (~> 3.12)
33
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 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,79 @@
1
+ # bio-chembl
2
+
3
+ [![Build Status](https://secure.travis-ci.org/nakao/bioruby-chembl.png)](http://travis-ci.org/nakao/bioruby-chembl)
4
+
5
+ [ChEMBL REST Web Service API](https://www.ebi.ac.uk/chembldb/ws) client, parser and container classes.
6
+
7
+ REST API Client
8
+
9
+ ```ruby
10
+ # Show a web service URI
11
+ BioChEMBL::REST::ChEMBL_URI.compound("CHEMBL1")
12
+
13
+ # GET the XML data of the ChEMBL ID CHEMBL1
14
+ api = BioChEMBL::REST.new
15
+ api.compound("CHEMBL1")
16
+ ```
17
+
18
+ Parser and container
19
+
20
+ ```ruby
21
+ cpd = BioChEMBL::Compound.find("CHEMBL1")
22
+ cpd.chemblId #=> "CHEMBL1"
23
+ cpd.slimes
24
+
25
+ ba = cpd.bioactivities
26
+
27
+ assay = BioChEMBL::Assay.find("CHEMBL1217643")
28
+ assay.bioactivities[0].target
29
+ assay.bioactivities[0].parent_compound
30
+ ```
31
+
32
+ Note: this software is under active development!
33
+
34
+ ## Installation
35
+
36
+ ```sh
37
+ gem install bio-chembl
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```ruby
43
+ require 'bio-chembl'
44
+ ```
45
+
46
+ The API doc is online. For more code examples see the test files in
47
+ the source tree.
48
+
49
+ ## Project home page
50
+
51
+ Information on the source tree, documentation, examples, issues and
52
+ how to contribute, see
53
+
54
+ http://github.com/nakao/bio-chembl
55
+
56
+ The BioRuby community is on IRC server: irc.freenode.org, channel: #bioruby.
57
+
58
+ ## Todo list
59
+
60
+ * BioChEMBL::Target.find_by_refesq method.
61
+ * JSON output support (parser and address).
62
+ * ChEMBL RDF support.
63
+ * Local REST API server with local ChEMBL database.
64
+
65
+ ## Cite
66
+
67
+ If you use this software, please cite one of
68
+
69
+ * [BioRuby: bioinformatics software for the Ruby programming language](http://dx.doi.org/10.1093/bioinformatics/btq475)
70
+ * [Biogem: an effective tool-based approach for scaling up open source software development in bioinformatics](http://dx.doi.org/10.1093/bioinformatics/bts080)
71
+
72
+ ## Biogems.info
73
+
74
+ This Biogem is published at [#bio-chembl](http://biogems.info/index.html)
75
+
76
+ ## Copyright
77
+
78
+ Copyright (c) 2012 Mitsuteru Nakao. See LICENSE.txt for further details.
79
+
@@ -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-chembl"
18
+ gem.homepage = "http://github.com/nakao/bio-chembl"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{ChEMBL REST API Client, Parser and Container}
21
+ gem.description = %Q{BioRuby plugin for ChEMBL REST API Client, Parser and Container classes}
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-chembl #{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.1
@@ -0,0 +1,94 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{bio-chembl}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mitsuteru Nakao"]
12
+ s.date = %q{2012-07-22}
13
+ s.description = %q{BioRuby plugin for ChEMBL REST API Client, Parser and Container classes}
14
+ s.email = %q{mitsuteru.nakao@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".project",
22
+ ".travis.yml",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "bio-chembl.gemspec",
30
+ "lib/bio-chembl.rb",
31
+ "lib/bio-chembl/assay.rb",
32
+ "lib/bio-chembl/bioactivity.rb",
33
+ "lib/bio-chembl/chembl.rb",
34
+ "lib/bio-chembl/chemblid.rb",
35
+ "lib/bio-chembl/compound.rb",
36
+ "lib/bio-chembl/datamodel.rb",
37
+ "lib/bio-chembl/rest_api_server.rb",
38
+ "lib/bio-chembl/rest_client.rb",
39
+ "lib/bio-chembl/target.rb",
40
+ "test/helper.rb",
41
+ "test/test_bio-chembl-assay.rb",
42
+ "test/test_bio-chembl-assay.sh",
43
+ "test/test_bio-chembl-chemblid.rb",
44
+ "test/test_bio-chembl-chemblid.sh",
45
+ "test/test_bio-chembl-compound.rb",
46
+ "test/test_bio-chembl-compound.sh",
47
+ "test/test_bio-chembl-rest-client.rb",
48
+ "test/test_bio-chembl-rest-client.sh",
49
+ "test/test_bio-chembl-target.rb",
50
+ "test/test_bio-chembl-target.sh",
51
+ "test/test_bio-chembl.rb",
52
+ "test/test_bio-chembl.sh"
53
+ ]
54
+ s.homepage = %q{http://github.com/nakao/bio-chembl}
55
+ s.licenses = ["MIT"]
56
+ s.require_paths = ["lib"]
57
+ s.rubygems_version = %q{1.3.7}
58
+ s.summary = %q{ChEMBL REST API Client, Parser and Container}
59
+
60
+ if s.respond_to? :specification_version then
61
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
62
+ s.specification_version = 3
63
+
64
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
65
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
67
+ s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
68
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
69
+ s.add_development_dependency(%q<bio>, [">= 1.4.2"])
70
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
71
+ s.add_development_dependency(%q<curb>, [">= 0"])
72
+ s.add_development_dependency(%q<nokogiri>, ["~> 1.5.5"])
73
+ else
74
+ s.add_dependency(%q<shoulda>, [">= 0"])
75
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
76
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
77
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
78
+ s.add_dependency(%q<bio>, [">= 1.4.2"])
79
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
80
+ s.add_dependency(%q<curb>, [">= 0"])
81
+ s.add_dependency(%q<nokogiri>, ["~> 1.5.5"])
82
+ end
83
+ else
84
+ s.add_dependency(%q<shoulda>, [">= 0"])
85
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
86
+ s.add_dependency(%q<bundler>, [">= 1.0.0"])
87
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
88
+ s.add_dependency(%q<bio>, [">= 1.4.2"])
89
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
90
+ s.add_dependency(%q<curb>, [">= 0"])
91
+ s.add_dependency(%q<nokogiri>, ["~> 1.5.5"])
92
+ end
93
+ end
94
+
@@ -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-chembl/chembl.rb'
12
+
@@ -0,0 +1,96 @@
1
+ require 'nokogiri'
2
+ require 'bio-chembl/datamodel.rb'
3
+ require 'bio-chembl/bioactivity.rb'
4
+
5
+
6
+ module BioChEMBL
7
+
8
+
9
+
10
+ # ChEMBL Assay
11
+ #
12
+ # Data XML
13
+ # <assay>
14
+ # <chemblId>CHEMBL1217643</chemblId>
15
+ # <assayType>B</assayType>
16
+ # <journal>Bioorg. Med. Chem. Lett.</journal>
17
+ # <assayOrganism>Homo sapiens</assayOrganism>
18
+ # <assayStrain>Unspecified</assayStrain>
19
+ # <assayDescription>Inhibition of human hERG</assayDescription>
20
+ # <numBioactivities>1</numBioactivities>
21
+ # </assay>
22
+ #
23
+ #
24
+ class Assay
25
+ extend BioChEMBL::DataModel
26
+
27
+ ATTRIBUTES = [
28
+ :chemblId,
29
+ :assayType,
30
+ :journal,
31
+ :assayOrganism,
32
+ :assayStrain,
33
+ :assayDescription,
34
+ :numBioactivities
35
+ ]
36
+
37
+ set_attr_accessors(ATTRIBUTES)
38
+
39
+
40
+ def self.parse(str)
41
+ case str
42
+ when /^</
43
+ format = 'xml'
44
+ when /^\{/
45
+ format = 'json'
46
+ else
47
+ raise ArgumentError, "Unexpected file format: #{str.inspect}"
48
+ end
49
+ begin
50
+ eval "self.parse_#{format}(str)"
51
+ rescue
52
+ raise NoMethodError
53
+ end
54
+ end
55
+
56
+ def self.parse_xml(str)
57
+ xml = Nokogiri::XML(str)
58
+ this = new
59
+ eval set_attr_values(ATTRIBUTES)
60
+ this
61
+ end
62
+
63
+ def self.parse_json(str)
64
+ raise NotImplementedError
65
+ end
66
+
67
+ def self.parse_rdf(str)
68
+ raise NotImplementedError
69
+ end
70
+
71
+ def self.find(chemblId)
72
+ self.parse_xml(REST.new.assays(chemblId))
73
+ end
74
+
75
+
76
+ # new
77
+ def initialize(chemblId = nil)
78
+ @chemblId = chemblId
79
+ end
80
+
81
+ # Resolve the compound data by given ChEMBL ID
82
+ def resolve
83
+ resolved = self.class.find(@chemblId)
84
+ ATTRIBUTES.each do |attr|
85
+ eval "@#{attr} = resolved.#{attr}"
86
+ end
87
+ end
88
+
89
+ # ChEMBL Bioactivity
90
+ def bioactivities
91
+ BioChEMBL::Bioactivity.parse_list_xml(REST.new.assays(@chemblId, 'bioactivities'))
92
+ end
93
+
94
+ end
95
+
96
+ end
@@ -0,0 +1,113 @@
1
+ require 'nokogiri'
2
+ require 'bio-chembl/datamodel.rb'
3
+
4
+
5
+ module BioChEMBL
6
+
7
+ # BioChEMBL::Bioactivity
8
+ #
9
+ # Data XML
10
+ # <list>
11
+ # <bioactivity>
12
+ # <parent__cmpd__chemblid>CHEMBL1214402</parent__cmpd__chemblid>
13
+ # <ingredient__cmpd__chemblid>CHEMBL1214402</ingredient__cmpd__chemblid>
14
+ # <target__chemblid>CHEMBL240</target__chemblid>
15
+ # <target__confidence>9</target__confidence>
16
+ # <target__name>HERG</target__name>
17
+ # <reference>Bioorg. Med. Chem. Lett., (2010) 20:15:4359</reference>
18
+ # <name__in__reference>26</name__in__reference>
19
+ # <organism>Homo sapiens</organism>
20
+ # <bioactivity__type>IC50</bioactivity__type>
21
+ # <activity__comment>Unspecified</activity__comment>
22
+ # <operator>=</operator>
23
+ # <units>nM</units>
24
+ # <assay__chemblid>CHEMBL1217643</assay__chemblid>
25
+ # <assay__type>B</assay__type>
26
+ # <assay__description>Inhibition of human hERG</assay__description>
27
+ # <value>5900</value>
28
+ # </bioactivity>
29
+ # </list>
30
+ #
31
+ # Usage
32
+ #
33
+ class Bioactivity
34
+ extend BioChEMBL::DataModel
35
+
36
+ ATTRIBUTES = [
37
+ :parent__cmpd__chemblid,
38
+ :ingredient__cmpd__chemblid,
39
+ :target__chemblid,
40
+ :target__confidence,
41
+ :target__name,
42
+ :reference,
43
+ :name__in__reference,
44
+ :organism,
45
+ :bioactivity__type,
46
+ :activity__comment,
47
+ :operator,
48
+ :units,
49
+ :assay__chemblid,
50
+ :assay__type,
51
+ :assay__description,
52
+ :value
53
+ ]
54
+
55
+ set_attr_accessors(ATTRIBUTES)
56
+
57
+ def self.parse(str)
58
+ case str
59
+ when /^</
60
+ format = 'xml'
61
+ when /^\{/
62
+ format = 'json'
63
+ else
64
+ raise ArgumentError, "Unexpected file format: #{str.inspect}"
65
+ end
66
+ begin
67
+ eval "self.parse_#{format}(str)"
68
+ rescue
69
+ raise NoMethodError
70
+ end
71
+ end
72
+
73
+ def self.parse_xml(str)
74
+ xml = Nokogiri::XML(str)
75
+ this = new
76
+ eval set_attr_values(ATTRIBUTES)
77
+ this
78
+ end
79
+
80
+ # XML
81
+ # <list><bioactivity> ...
82
+ def self.parse_list_xml(str)
83
+ xmls = Nokogiri::XML(str)
84
+ xmls.xpath("/list/bioactivity").map do |cpd|
85
+ self.parse_xml(cpd.to_s)
86
+ end
87
+ end
88
+
89
+ def self.parse_json(str)
90
+ raise NotImplementedError
91
+ end
92
+
93
+ def self.parse_rdf(str)
94
+ raise NotImplementedError
95
+ end
96
+
97
+ def parent_compound
98
+ require 'bio-chembl/compound.rb'
99
+ BioChEMBL::Compound.find(@parent__cmpd__chemblid)
100
+ end
101
+
102
+ def target
103
+ require 'bio-chembl/target.rb'
104
+ BioChEMBL::Target.find(@target__chemblid)
105
+ end
106
+
107
+ def assay
108
+ require 'bio-chembl/assay.rb'
109
+ BioChEMBL::Assay.find(@assay__chemblid)
110
+ end
111
+ end
112
+
113
+ end