obo_parser 0.3.1 → 0.3.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.
@@ -69,6 +69,24 @@ class Test_Lexer < Test::Unit::TestCase
69
69
  assert_equal 'PATO:0001301', t.value
70
70
  end
71
71
 
72
+ def test_parse_term_stanza2
73
+ input = '[Term]
74
+ id: CL:0000009
75
+ name: fusiform initial
76
+ alt_id: CL:0000274
77
+ def: "An elongated cell with approximately wedge-shaped ends, found in the vascular cambium, which gives rise to the elements of the axial system in the secondary vascular tissues." [ISBN:0471245208]
78
+ synonym: "xylem initial" RELATED []
79
+ synonym: "xylem mother cell" RELATED []
80
+ is_a: CL:0000272 ! cambial initial
81
+ is_a: CL:0000610 ! plant cell'
82
+
83
+ assert foo = parse_obo_file(input)
84
+ assert_equal 2, foo.terms.first.tags_named('synonym').size
85
+ assert_equal 'xylem initial', foo.terms.first.tags_named('synonym').first.value
86
+ assert_equal 'xylem mother cell', foo.terms.first.tags_named('synonym')[1].value
87
+ assert_equal 'CL:0000274', foo.terms.first.tags_named('alt_id').first.value
88
+ end
89
+
72
90
  def test_parse_term
73
91
  lexer = OboParser::Lexer.new("[Term]")
74
92
  assert lexer.pop(OboParser::Tokens::Term)
@@ -94,7 +112,17 @@ class Test_Lexer < Test::Unit::TestCase
94
112
  assert_equal 'FOO!', t.comment
95
113
  assert_equal(['PATO:0000179'], t.xrefs)
96
114
  end
97
-
115
+
116
+ def test_that_synonyms_parse
117
+ lexer = OboParser::Lexer.new("synonym: \"Nematoblast\" EXACT []\n")
118
+ assert t = lexer.pop(OboParser::Tokens::TagValuePair)
119
+ assert_equal 'synonym', t.tag
120
+ assert_equal 'Nematoblast', t.value
121
+ assert_equal 'EXACT', t.qualifier
122
+ assert_equal nil, t.comment
123
+ assert_equal([], t.xrefs)
124
+ end
125
+
98
126
  end
99
127
 
100
128
  class Test_Parser < Test::Unit::TestCase
@@ -113,6 +141,23 @@ class Test_Parser < Test::Unit::TestCase
113
141
  assert_equal 'true', foo.terms.first.tags_named('is_obsolete').first.value
114
142
  end
115
143
 
144
+ def test_complex_file_parsing
145
+ assert of = File.read(File.expand_path(File.join(File.dirname(__FILE__), '../test/cell.obo')) )
146
+ foo = parse_obo_file(of)
147
+ assert_equal 'cell', foo.terms.first.name.value
148
+ assert_equal 'primary cell line cell', foo.terms[1].name.value
149
+
150
+ tmp = foo.terms[9].tags_named('synonym')
151
+ assert_equal 2, tmp.size
152
+ assert_equal 'xylem initial', tmp.first.value
153
+ assert_equal 'xylem mother cell', tmp[1].value
154
+ assert_equal([], tmp[1].xrefs)
155
+
156
+ assert_equal 2, foo.terms[9].tags_named('is_a').size
157
+
158
+ end
159
+
160
+
116
161
  def teardown
117
162
  @of = nil
118
163
  end
@@ -124,9 +169,3 @@ class Test_Parser < Test::Unit::TestCase
124
169
 
125
170
  end
126
171
 
127
-
128
-
129
-
130
-
131
-
132
-
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obo_parser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - mjy
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-05 00:00:00 -04:00
18
+ date: 2011-04-06 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21