simple_bioc 0.0.1 → 0.0.2
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.
- checksums.yaml +4 -4
- data/README.md +73 -3
- data/Rakefile +5 -0
- data/html/BioCReader.html +657 -0
- data/html/BioCWriter.html +556 -0
- data/html/README_md.html +231 -0
- data/html/SimpleBioC.html +255 -0
- data/html/SimpleBioC/Annotation.html +279 -0
- data/html/SimpleBioC/Collection.html +316 -0
- data/html/SimpleBioC/Document.html +426 -0
- data/html/SimpleBioC/Location.html +288 -0
- data/html/SimpleBioC/Node.html +334 -0
- data/html/SimpleBioC/NodeBase.html +281 -0
- data/html/SimpleBioC/Passage.html +418 -0
- data/html/SimpleBioC/Relation.html +301 -0
- data/html/SimpleBioC/Sentence.html +399 -0
- data/html/created.rid +15 -0
- data/html/images/add.png +0 -0
- data/html/images/arrow_up.png +0 -0
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/delete.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_blue.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/transparent.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +212 -0
- data/html/js/darkfish.js +155 -0
- data/html/js/jquery.js +18 -0
- data/html/js/navigation.js +142 -0
- data/html/js/search.js +94 -0
- data/html/js/search_index.js +1 -0
- data/html/js/searcher.js +228 -0
- data/html/rdoc.css +595 -0
- data/html/table_of_contents.html +199 -0
- data/lib/simple_bioc.rb +4 -0
- data/lib/simple_bioc/annotation.rb +10 -6
- data/lib/simple_bioc/bioc_reader.rb +2 -2
- data/lib/simple_bioc/collection.rb +13 -11
- data/lib/simple_bioc/document.rb +31 -22
- data/lib/simple_bioc/location.rb +13 -7
- data/lib/simple_bioc/node.rb +14 -8
- data/lib/simple_bioc/node_base.rb +13 -10
- data/lib/simple_bioc/passage.rb +26 -23
- data/lib/simple_bioc/relation.rb +13 -8
- data/lib/simple_bioc/sentence.rb +21 -15
- data/lib/simple_bioc/version.rb +2 -2
- data/samples/print_annotation.rb +18 -0
- data/samples/sample1.rb +31 -0
- data/simple_bioc.gemspec +1 -1
- metadata +52 -2
data/lib/simple_bioc/relation.rb
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
require 'simple_bioc/node_base'
|
2
|
+
module SimpleBioC
|
3
|
+
class Relation < NodeBase
|
4
|
+
attr_accessor :nodes
|
2
5
|
|
3
|
-
|
4
|
-
|
6
|
+
def initialize(parent)
|
7
|
+
super(parent)
|
8
|
+
@nodes = []
|
9
|
+
end
|
5
10
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
end
|
11
|
+
def adjust_ref
|
12
|
+
nodes.each{|n| n.adjust_ref}
|
13
|
+
end
|
10
14
|
|
11
|
-
|
12
|
-
|
15
|
+
def to_c
|
16
|
+
"Relation:#{id}"
|
17
|
+
end
|
13
18
|
end
|
14
19
|
end
|
data/lib/simple_bioc/sentence.rb
CHANGED
@@ -1,20 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
module SimpleBioC
|
2
|
+
class Sentence
|
3
|
+
attr_accessor :offset, :text, :infons, :annotations, :relations
|
4
|
+
attr_reader :passage
|
4
5
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
def initialize(parent)
|
7
|
+
@infons = {}
|
8
|
+
@annotations = []
|
9
|
+
@relations = []
|
10
|
+
@passage = parent
|
11
|
+
end
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
def find_node(id)
|
14
|
+
(relations+annotations).each{|n| return n if n.id == id}
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def each_relation
|
19
|
+
relations.each{|r| yield r}
|
20
|
+
end
|
16
21
|
|
17
|
-
|
18
|
-
|
22
|
+
def to_c
|
23
|
+
"Sentence @#{offset}: #{text}"
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
data/lib/simple_bioc/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.0.
|
1
|
+
module SimpleBioC
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# print_annotation: print all annotations in the given file
|
2
|
+
|
3
|
+
require 'simple_bioc'
|
4
|
+
|
5
|
+
if ARGF.argv.size < 1
|
6
|
+
puts "usage: ruby print_annotation.rb {filepath}"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
collection = SimpleBioC::from_xml(ARGF.argv[0])
|
11
|
+
collection.documents.each do |d|
|
12
|
+
d.passages.each do |p|
|
13
|
+
p.sentences.each do |s|
|
14
|
+
s.annotations.each{|a| puts "#{d} #{a}"}
|
15
|
+
end
|
16
|
+
p.annotations.each{|a| puts "#{d} #{a}"}
|
17
|
+
end
|
18
|
+
end
|
data/samples/sample1.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Sample1: parse, traverse, manipulate, and build BioC data
|
2
|
+
require 'simple_bioc'
|
3
|
+
|
4
|
+
# parse BioC file
|
5
|
+
collection = SimpleBioC.from_xml("../xml/everything.xml")
|
6
|
+
|
7
|
+
# the returned object contains all the information in the BioC file
|
8
|
+
# traverse & read information
|
9
|
+
collection.documents.each do |document|
|
10
|
+
puts document
|
11
|
+
document.passages.each do |passage|
|
12
|
+
puts passage
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# manipulate
|
17
|
+
doc = SimpleBioC::Document.new(collection)
|
18
|
+
doc.id = "23071747"
|
19
|
+
doc.infons["journal"] = "PLoS One"
|
20
|
+
collection.documents << doc
|
21
|
+
|
22
|
+
p = SimpleBioC::Passage.new(doc)
|
23
|
+
p.offset = 0
|
24
|
+
p.text = "TRIP database 2.0: a manually curated information hub for accessing TRP channel interaction network."
|
25
|
+
p.infons["type"] = "title"
|
26
|
+
doc.passages << p
|
27
|
+
|
28
|
+
|
29
|
+
# build BioC document from data
|
30
|
+
xml = SimpleBioC.to_xml(collection)
|
31
|
+
puts xml
|
data/simple_bioc.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'simple_bioc/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "simple_bioc"
|
8
|
-
spec.version =
|
8
|
+
spec.version = SimpleBioC::VERSION
|
9
9
|
spec.authors = ["Dongseop Kwon"]
|
10
10
|
spec.email = ["dongseop@gmail.com"]
|
11
11
|
spec.description = "Simple BioC parser/builder for ruby. BioC is a 'A Minimalist Approach to Interoperability for Biomedical Text Processing' (http://www.ncbi.nlm.nih.gov/CBBresearch/Dogan/BioC/BioCHome.html)"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_bioc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dongseop Kwon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -94,6 +94,54 @@ files:
|
|
94
94
|
- LICENSE.txt
|
95
95
|
- README.md
|
96
96
|
- Rakefile
|
97
|
+
- html/BioCReader.html
|
98
|
+
- html/BioCWriter.html
|
99
|
+
- html/README_md.html
|
100
|
+
- html/SimpleBioC.html
|
101
|
+
- html/SimpleBioC/Annotation.html
|
102
|
+
- html/SimpleBioC/Collection.html
|
103
|
+
- html/SimpleBioC/Document.html
|
104
|
+
- html/SimpleBioC/Location.html
|
105
|
+
- html/SimpleBioC/Node.html
|
106
|
+
- html/SimpleBioC/NodeBase.html
|
107
|
+
- html/SimpleBioC/Passage.html
|
108
|
+
- html/SimpleBioC/Relation.html
|
109
|
+
- html/SimpleBioC/Sentence.html
|
110
|
+
- html/created.rid
|
111
|
+
- html/images/add.png
|
112
|
+
- html/images/arrow_up.png
|
113
|
+
- html/images/brick.png
|
114
|
+
- html/images/brick_link.png
|
115
|
+
- html/images/bug.png
|
116
|
+
- html/images/bullet_black.png
|
117
|
+
- html/images/bullet_toggle_minus.png
|
118
|
+
- html/images/bullet_toggle_plus.png
|
119
|
+
- html/images/date.png
|
120
|
+
- html/images/delete.png
|
121
|
+
- html/images/find.png
|
122
|
+
- html/images/loadingAnimation.gif
|
123
|
+
- html/images/macFFBgHack.png
|
124
|
+
- html/images/package.png
|
125
|
+
- html/images/page_green.png
|
126
|
+
- html/images/page_white_text.png
|
127
|
+
- html/images/page_white_width.png
|
128
|
+
- html/images/plugin.png
|
129
|
+
- html/images/ruby.png
|
130
|
+
- html/images/tag_blue.png
|
131
|
+
- html/images/tag_green.png
|
132
|
+
- html/images/transparent.png
|
133
|
+
- html/images/wrench.png
|
134
|
+
- html/images/wrench_orange.png
|
135
|
+
- html/images/zoom.png
|
136
|
+
- html/index.html
|
137
|
+
- html/js/darkfish.js
|
138
|
+
- html/js/jquery.js
|
139
|
+
- html/js/navigation.js
|
140
|
+
- html/js/search.js
|
141
|
+
- html/js/search_index.js
|
142
|
+
- html/js/searcher.js
|
143
|
+
- html/rdoc.css
|
144
|
+
- html/table_of_contents.html
|
97
145
|
- lib/simple_bioc.rb
|
98
146
|
- lib/simple_bioc/annotation.rb
|
99
147
|
- lib/simple_bioc/bioc_reader.rb
|
@@ -107,6 +155,8 @@ files:
|
|
107
155
|
- lib/simple_bioc/relation.rb
|
108
156
|
- lib/simple_bioc/sentence.rb
|
109
157
|
- lib/simple_bioc/version.rb
|
158
|
+
- samples/print_annotation.rb
|
159
|
+
- samples/sample1.rb
|
110
160
|
- simple_bioc.gemspec
|
111
161
|
- spec/simple_bioc_spec.rb
|
112
162
|
- xml/BioC.dtd
|