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.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +73 -3
  3. data/Rakefile +5 -0
  4. data/html/BioCReader.html +657 -0
  5. data/html/BioCWriter.html +556 -0
  6. data/html/README_md.html +231 -0
  7. data/html/SimpleBioC.html +255 -0
  8. data/html/SimpleBioC/Annotation.html +279 -0
  9. data/html/SimpleBioC/Collection.html +316 -0
  10. data/html/SimpleBioC/Document.html +426 -0
  11. data/html/SimpleBioC/Location.html +288 -0
  12. data/html/SimpleBioC/Node.html +334 -0
  13. data/html/SimpleBioC/NodeBase.html +281 -0
  14. data/html/SimpleBioC/Passage.html +418 -0
  15. data/html/SimpleBioC/Relation.html +301 -0
  16. data/html/SimpleBioC/Sentence.html +399 -0
  17. data/html/created.rid +15 -0
  18. data/html/images/add.png +0 -0
  19. data/html/images/arrow_up.png +0 -0
  20. data/html/images/brick.png +0 -0
  21. data/html/images/brick_link.png +0 -0
  22. data/html/images/bug.png +0 -0
  23. data/html/images/bullet_black.png +0 -0
  24. data/html/images/bullet_toggle_minus.png +0 -0
  25. data/html/images/bullet_toggle_plus.png +0 -0
  26. data/html/images/date.png +0 -0
  27. data/html/images/delete.png +0 -0
  28. data/html/images/find.png +0 -0
  29. data/html/images/loadingAnimation.gif +0 -0
  30. data/html/images/macFFBgHack.png +0 -0
  31. data/html/images/package.png +0 -0
  32. data/html/images/page_green.png +0 -0
  33. data/html/images/page_white_text.png +0 -0
  34. data/html/images/page_white_width.png +0 -0
  35. data/html/images/plugin.png +0 -0
  36. data/html/images/ruby.png +0 -0
  37. data/html/images/tag_blue.png +0 -0
  38. data/html/images/tag_green.png +0 -0
  39. data/html/images/transparent.png +0 -0
  40. data/html/images/wrench.png +0 -0
  41. data/html/images/wrench_orange.png +0 -0
  42. data/html/images/zoom.png +0 -0
  43. data/html/index.html +212 -0
  44. data/html/js/darkfish.js +155 -0
  45. data/html/js/jquery.js +18 -0
  46. data/html/js/navigation.js +142 -0
  47. data/html/js/search.js +94 -0
  48. data/html/js/search_index.js +1 -0
  49. data/html/js/searcher.js +228 -0
  50. data/html/rdoc.css +595 -0
  51. data/html/table_of_contents.html +199 -0
  52. data/lib/simple_bioc.rb +4 -0
  53. data/lib/simple_bioc/annotation.rb +10 -6
  54. data/lib/simple_bioc/bioc_reader.rb +2 -2
  55. data/lib/simple_bioc/collection.rb +13 -11
  56. data/lib/simple_bioc/document.rb +31 -22
  57. data/lib/simple_bioc/location.rb +13 -7
  58. data/lib/simple_bioc/node.rb +14 -8
  59. data/lib/simple_bioc/node_base.rb +13 -10
  60. data/lib/simple_bioc/passage.rb +26 -23
  61. data/lib/simple_bioc/relation.rb +13 -8
  62. data/lib/simple_bioc/sentence.rb +21 -15
  63. data/lib/simple_bioc/version.rb +2 -2
  64. data/samples/print_annotation.rb +18 -0
  65. data/samples/sample1.rb +31 -0
  66. data/simple_bioc.gemspec +1 -1
  67. metadata +52 -2
@@ -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
- class Relation < NodeBase
4
- attr_accessor :nodes
6
+ def initialize(parent)
7
+ super(parent)
8
+ @nodes = []
9
+ end
5
10
 
6
- def initialize(parent)
7
- super(parent)
8
- @nodes = []
9
- end
11
+ def adjust_ref
12
+ nodes.each{|n| n.adjust_ref}
13
+ end
10
14
 
11
- def adjust_ref
12
- nodes.each{|n| n.adjust_ref}
15
+ def to_c
16
+ "Relation:#{id}"
17
+ end
13
18
  end
14
19
  end
@@ -1,20 +1,26 @@
1
- class Sentence
2
- attr_accessor :offset, :text, :infons, :annotations, :relations
3
- attr_reader :passage
1
+ module SimpleBioC
2
+ class Sentence
3
+ attr_accessor :offset, :text, :infons, :annotations, :relations
4
+ attr_reader :passage
4
5
 
5
- def initialize(parent)
6
- @infons = {}
7
- @annotations = []
8
- @relations = []
9
- @passage = parent
10
- end
6
+ def initialize(parent)
7
+ @infons = {}
8
+ @annotations = []
9
+ @relations = []
10
+ @passage = parent
11
+ end
11
12
 
12
- def find_node(id)
13
- (relations+annotations).each{|n| return n if n.id == id}
14
- nil
15
- end
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
- def each_relation
18
- relations.each{|r| yield r}
22
+ def to_c
23
+ "Sentence @#{offset}: #{text}"
24
+ end
19
25
  end
20
26
  end
@@ -1,3 +1,3 @@
1
- module SimpleBioc
2
- VERSION = "0.0.1"
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
@@ -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 = SimpleBioc::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.1
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-04 00:00:00.000000000 Z
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