oba-client 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +6 -0
- data/History.md +3 -0
- data/README.md +2 -2
- data/Rakefile +65 -11
- data/VERSION +1 -0
- data/lib/oba-client.rb +23 -11
- data/oba-client.gemspec +53 -0
- data/test/test_oba_client.rb +4 -4
- metadata +21 -50
- data/.autotest +0 -23
- data/Manifest.txt +0 -7
data/History.md
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# oba-client
|
2
2
|
|
3
|
-
* [
|
3
|
+
* [GitHub](github.com/rtirrell/oba-client_ruby)
|
4
4
|
|
5
5
|
## DESCRIPTION:
|
6
6
|
|
7
|
-
A client for accessing the NCBO's Open Biomedical Annotator service.
|
7
|
+
A client for accessing the NCBO's Open Biomedical Annotator web service.
|
8
8
|
See [the Annotator documentation](http://www.bioontology.org/wiki/index.php/Annotator_User_Guide "Documentation") for much more information.
|
9
9
|
|
10
10
|
## FEATURES:
|
data/Rakefile
CHANGED
@@ -1,17 +1,71 @@
|
|
1
1
|
require "rubygems"
|
2
|
-
require "
|
2
|
+
require File.dirname(__FILE__) + "/lib/oba-client.rb"
|
3
|
+
#require "hoe"
|
3
4
|
|
4
|
-
Hoe.plugin :yard
|
5
|
+
#Hoe.plugin :yard
|
5
6
|
|
6
|
-
Hoe.spec "oba-client" do
|
7
|
-
self.developer "Rob Tirrell", "rpt@stanford.edu"
|
8
|
-
self.url = "http://rubyforge.org/projects/oba-client"
|
9
|
-
|
10
|
-
self.yard_title = "OBAClient Documentation"
|
11
|
-
self.yard_options = ["--default-return", "void"]
|
12
|
-
self.yard_markup = "markdown"
|
13
|
-
self.remote_yard_dir = ""
|
7
|
+
#Hoe.spec "oba-client" do
|
8
|
+
# self.developer "Rob Tirrell", "rpt@stanford.edu"
|
9
|
+
# self.url = "http://rubyforge.org/projects/oba-client"
|
10
|
+
#
|
11
|
+
# self.yard_title = "OBAClient Documentation"
|
12
|
+
# self.yard_options = ["--default-return", "void"]
|
13
|
+
# self.yard_markup = "markdown"
|
14
|
+
# self.remote_yard_dir = ""
|
15
|
+
#
|
16
|
+
# self.rubyforge_name = "oba-client"
|
17
|
+
#end
|
14
18
|
|
15
|
-
|
19
|
+
require "rubygems"
|
20
|
+
require "rake"
|
21
|
+
|
22
|
+
begin
|
23
|
+
require "jeweler"
|
24
|
+
Jeweler::Tasks.new do |gem|
|
25
|
+
gem.name = "oba-client"
|
26
|
+
gem.summary = "A client for the Open Biomedical Annotator."
|
27
|
+
gem.description = "See above."
|
28
|
+
gem.email = "rpt@stanford.edu"
|
29
|
+
gem.homepage = "http://github.com/rtirrell/oba-client"
|
30
|
+
gem.authors = ["Rob Tirrell"]
|
31
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
32
|
+
gem.add_development_dependency "yard", ">= 0"
|
33
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
34
|
+
end
|
35
|
+
Jeweler::GemcutterTasks.new
|
36
|
+
rescue LoadError
|
37
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
16
38
|
end
|
17
39
|
|
40
|
+
require "rake/testtask"
|
41
|
+
Rake::TestTask.new(:test) do |test|
|
42
|
+
test.libs << "lib" << "test"
|
43
|
+
test.pattern = "test/**/test_*.rb"
|
44
|
+
test.verbose = true
|
45
|
+
end
|
46
|
+
|
47
|
+
begin
|
48
|
+
require "rcov/rcovtask"
|
49
|
+
Rcov::RcovTask.new do |test|
|
50
|
+
test.libs << "test"
|
51
|
+
test.pattern = "test/**/test_*.rb"
|
52
|
+
test.verbose = true
|
53
|
+
end
|
54
|
+
rescue LoadError
|
55
|
+
task :rcov do
|
56
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
task :test => :check_dependencies
|
61
|
+
|
62
|
+
task :default => :test
|
63
|
+
|
64
|
+
begin
|
65
|
+
require "yard"
|
66
|
+
YARD::Rake::YardocTask.new
|
67
|
+
rescue LoadError
|
68
|
+
task :yardoc do
|
69
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
70
|
+
end
|
71
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.0
|
data/lib/oba-client.rb
CHANGED
@@ -9,7 +9,7 @@ require "uri"
|
|
9
9
|
# things we do: get text, and parse it. We can do both independently or
|
10
10
|
# serially.
|
11
11
|
class OBAClient
|
12
|
-
VERSION = "2.0.
|
12
|
+
VERSION = "2.0.4"
|
13
13
|
|
14
14
|
##
|
15
15
|
# A high HTTP read timeout, as the service sometimes takes awhile to respond.
|
@@ -50,10 +50,13 @@ class OBAClient
|
|
50
50
|
# Instantiate the class with a set of reused options. Options used by the
|
51
51
|
# method are:
|
52
52
|
#
|
53
|
-
# *
|
54
|
-
#
|
55
|
-
# *
|
56
|
-
#
|
53
|
+
# * {String} **uri**: the URI of the annotator service (default:
|
54
|
+
# {DEFAULT_URI}).
|
55
|
+
# * {Fixnum} **timeout**: the length of the read timeout (default:
|
56
|
+
# {DEFAULT_TIMEOUT}).
|
57
|
+
# * {Boolean} **parse_xml**: whether to parse the received text (default:
|
58
|
+
# false).
|
59
|
+
# * {Array}<{String}> **ontologies**: a pseudo-parameter which sets both
|
57
60
|
# ontologiesToExpand and ontologiesToKeepInResult.
|
58
61
|
# @param [Hash<String, String>] options Parameters for the annotation.
|
59
62
|
def initialize(options = {})
|
@@ -83,7 +86,8 @@ class OBAClient
|
|
83
86
|
end
|
84
87
|
|
85
88
|
if !@options.include?(:email)
|
86
|
-
puts "TIP: as a courtesy, consider including your email in the
|
89
|
+
puts "TIP: as a courtesy, consider including your email in the " +
|
90
|
+
"request (:email => 'a@b.com')"
|
87
91
|
end
|
88
92
|
end
|
89
93
|
|
@@ -187,9 +191,11 @@ class OBAClient
|
|
187
191
|
}
|
188
192
|
|
189
193
|
##
|
190
|
-
# Parse a context
|
194
|
+
# Parse a context: an annotation, or a mapping/mgrep context bean.
|
195
|
+
#
|
191
196
|
# @param [Nokgiri::XML::Node] context The root node of the context.
|
192
|
-
#
|
197
|
+
#
|
198
|
+
# @return [Hash<Symbol, Object>] The parsed context.
|
193
199
|
def self.parse_context(context)
|
194
200
|
# Annotations (annotationBeans) do not have a class, so we'll refer to them
|
195
201
|
# as annotationContextBeans. context_class will be one of the types in
|
@@ -206,9 +212,11 @@ class OBAClient
|
|
206
212
|
end
|
207
213
|
|
208
214
|
##
|
209
|
-
# Parse a concept
|
215
|
+
# Parse a concept: a toplevel annotation concept, or an annotation's
|
210
216
|
# mapping concept.
|
217
|
+
#
|
211
218
|
# @param [Nokogiri::XML::Node] concept The root node of the concept.
|
219
|
+
#
|
212
220
|
# @return [Hash<Symbol, Object>] The parsed concept.
|
213
221
|
def self.parse_concept(concept)
|
214
222
|
Hash[CONCEPT_ATTRIBUTES.map do |k, v|
|
@@ -222,9 +230,11 @@ class OBAClient
|
|
222
230
|
# statistics (annotations by mapping type, etc., as a Hash), an Array of
|
223
231
|
# each annotation (as a Hash), and an Array of ontologies used (also as
|
224
232
|
# a Hash).
|
225
|
-
#
|
233
|
+
#
|
234
|
+
# @param [String] xml The XML we'll be parsing.
|
235
|
+
#
|
226
236
|
# @return [Hash<Symbol, Object>] A Hash representation of the XML, as
|
227
|
-
# described
|
237
|
+
# described in the README.
|
228
238
|
def self.parse(xml)
|
229
239
|
puts "WARNING: text is empty!" if (xml.gsub(/\n/, "") == "")
|
230
240
|
doc = Nokogiri::XML.parse(xml)
|
@@ -257,7 +267,9 @@ class OBAClient
|
|
257
267
|
##
|
258
268
|
# A little helper: convert a string true/false or 1/0 value to boolean.
|
259
269
|
# AFAIK, there's no better way to do this.
|
270
|
+
#
|
260
271
|
# @param [String] value The value to convert.
|
272
|
+
#
|
261
273
|
# @return [true, false]
|
262
274
|
def self.to_b(value)
|
263
275
|
case value
|
data/oba-client.gemspec
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{oba-client}
|
8
|
+
s.version = "2.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Rob Tirrell"]
|
12
|
+
s.date = %q{2010-07-26}
|
13
|
+
s.description = %q{See above.}
|
14
|
+
s.email = %q{rpt@stanford.edu}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.md"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".gitignore",
|
20
|
+
"History.md",
|
21
|
+
"README.md",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/oba-client.rb",
|
25
|
+
"oba-client.gemspec",
|
26
|
+
"test/test_oba_client.rb"
|
27
|
+
]
|
28
|
+
s.homepage = %q{http://github.com/rtirrell/oba-client}
|
29
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
30
|
+
s.require_paths = ["lib"]
|
31
|
+
s.rubygems_version = %q{1.3.7}
|
32
|
+
s.summary = %q{A client for the Open Biomedical Annotator.}
|
33
|
+
s.test_files = [
|
34
|
+
"test/test_oba_client.rb"
|
35
|
+
]
|
36
|
+
|
37
|
+
if s.respond_to? :specification_version then
|
38
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
43
|
+
s.add_development_dependency(%q<yard>, [">= 0"])
|
44
|
+
else
|
45
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
46
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
47
|
+
end
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
50
|
+
s.add_dependency(%q<yard>, [">= 0"])
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
data/test/test_oba_client.rb
CHANGED
@@ -3,10 +3,10 @@ require "oba-client"
|
|
3
3
|
|
4
4
|
TEST_TEXTS = [
|
5
5
|
"Mexico,, Disease Thing \o\r\m\n\t\v\l\rzebrafish !!! cancer of the thorax. large intestine thorax",
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
%Q{LOROE aonuhaso unseu anoeuhs aeuhsaonuh asoneuhason uaosenuh aosenuhaose
|
7
|
+
aoneuhasonuhaoenuh anoeuhasn euhasoneu haosneuhaosenuhaoesunahoeusnaoeuteeano
|
8
|
+
aot tt t t t t t t tae \n!!@)$@(#)%@\#!)@# asoeuaohsenutahoeusaheou
|
9
|
+
}
|
10
10
|
]
|
11
11
|
|
12
12
|
class TestOBAClient < Test::Unit::TestCase
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oba-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 2
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 2.0.3
|
10
|
+
version: 2.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Rob Tirrell
|
@@ -15,90 +15,61 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-26 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
22
|
-
name:
|
22
|
+
name: thoughtbot-shoulda
|
23
23
|
prerelease: false
|
24
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 3
|
30
30
|
segments:
|
31
|
-
- 2
|
32
31
|
- 0
|
33
|
-
|
34
|
-
version: 2.0.4
|
32
|
+
version: "0"
|
35
33
|
type: :development
|
36
34
|
version_requirements: *id001
|
37
35
|
- !ruby/object:Gem::Dependency
|
38
|
-
name:
|
36
|
+
name: yard
|
39
37
|
prerelease: false
|
40
38
|
requirement: &id002 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash:
|
43
|
+
hash: 3
|
46
44
|
segments:
|
47
45
|
- 0
|
48
|
-
|
49
|
-
- 2
|
50
|
-
version: 0.1.2
|
46
|
+
version: "0"
|
51
47
|
type: :development
|
52
48
|
version_requirements: *id002
|
53
|
-
|
54
|
-
|
55
|
-
prerelease: false
|
56
|
-
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
hash: 21
|
62
|
-
segments:
|
63
|
-
- 2
|
64
|
-
- 6
|
65
|
-
- 1
|
66
|
-
version: 2.6.1
|
67
|
-
type: :development
|
68
|
-
version_requirements: *id003
|
69
|
-
description: |-
|
70
|
-
A client for accessing the NCBO's Open Biomedical Annotator service.
|
71
|
-
See [the Annotator documentation](http://www.bioontology.org/wiki/index.php/Annotator_User_Guide "Documentation") for much more information.
|
72
|
-
email:
|
73
|
-
- rpt@stanford.edu
|
49
|
+
description: See above.
|
50
|
+
email: rpt@stanford.edu
|
74
51
|
executables: []
|
75
52
|
|
76
53
|
extensions: []
|
77
54
|
|
78
55
|
extra_rdoc_files:
|
79
|
-
-
|
80
|
-
- History.md
|
56
|
+
- README.md
|
81
57
|
files:
|
82
|
-
- .
|
58
|
+
- .gitignore
|
83
59
|
- History.md
|
84
|
-
- Manifest.txt
|
85
60
|
- README.md
|
86
61
|
- Rakefile
|
62
|
+
- VERSION
|
87
63
|
- lib/oba-client.rb
|
64
|
+
- oba-client.gemspec
|
88
65
|
- test/test_oba_client.rb
|
89
|
-
has_rdoc:
|
90
|
-
homepage: http://
|
66
|
+
has_rdoc: true
|
67
|
+
homepage: http://github.com/rtirrell/oba-client
|
91
68
|
licenses: []
|
92
69
|
|
93
70
|
post_install_message:
|
94
71
|
rdoc_options:
|
95
|
-
- --
|
96
|
-
- void
|
97
|
-
- --title
|
98
|
-
- OBAClient Documentation
|
99
|
-
- --markup
|
100
|
-
- markdown
|
101
|
-
- --quiet
|
72
|
+
- --charset=UTF-8
|
102
73
|
require_paths:
|
103
74
|
- lib
|
104
75
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -121,10 +92,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
92
|
version: "0"
|
122
93
|
requirements: []
|
123
94
|
|
124
|
-
rubyforge_project:
|
95
|
+
rubyforge_project:
|
125
96
|
rubygems_version: 1.3.7
|
126
97
|
signing_key:
|
127
98
|
specification_version: 3
|
128
|
-
summary: A client for
|
99
|
+
summary: A client for the Open Biomedical Annotator.
|
129
100
|
test_files:
|
130
101
|
- test/test_oba_client.rb
|
data/.autotest
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# -*- ruby -*-
|
2
|
-
|
3
|
-
require 'autotest/restart'
|
4
|
-
|
5
|
-
# Autotest.add_hook :initialize do |at|
|
6
|
-
# at.extra_files << "../some/external/dependency.rb"
|
7
|
-
#
|
8
|
-
# at.libs << ":../some/external"
|
9
|
-
#
|
10
|
-
# at.add_exception 'vendor'
|
11
|
-
#
|
12
|
-
# at.add_mapping(/dependency.rb/) do |f, _|
|
13
|
-
# at.files_matching(/test_.*rb$/)
|
14
|
-
# end
|
15
|
-
#
|
16
|
-
# %w(TestA TestB).each do |klass|
|
17
|
-
# at.extra_class_map[klass] = "test/test_misc.rb"
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
|
21
|
-
# Autotest.add_hook :run_command do |at|
|
22
|
-
# system "rake build"
|
23
|
-
# end
|