mesh-medical-subject-headings 1.3.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/data/mesh_data_2014/d2014.en_gb.bin.gz +0 -0
- data/lib/MESH.rb +2 -1
- data/lib/MESH/classifier.rb +0 -32
- data/lib/MESH/heading.rb +155 -0
- data/lib/MESH/tree.rb +216 -0
- data/lib/MESH/version.rb +1 -1
- data/match.rb +3 -3
- data/test/classifier_test.rb +239 -259
- data/test/{mesh_test.rb → mesh_core_test.rb} +172 -172
- data/test/test_helper.rb +11 -11
- data/tr_speed.rb +2 -2
- metadata +7 -5
- data/lib/MESH/mesh.rb +0 -314
@@ -1,152 +1,153 @@
|
|
1
1
|
require_relative 'test_helper'
|
2
2
|
|
3
3
|
module MESH
|
4
|
-
|
4
|
+
class MeshCoreTest < Minitest::Test
|
5
5
|
|
6
|
-
|
6
|
+
def test_yield_to_a_block_for_each
|
7
7
|
block_called = false
|
8
|
-
|
8
|
+
@mesh_tree.each do |h|
|
9
9
|
block_called = true
|
10
10
|
break
|
11
11
|
end
|
12
12
|
assert block_called
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
def test_not_have_nil_headings
|
16
|
+
@mesh_tree.each do |h|
|
17
17
|
refute_nil h
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
mh =
|
21
|
+
def test_find_by_unique_id
|
22
|
+
mh = @mesh_tree.find('D000001')
|
23
23
|
refute_nil mh
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
mh =
|
26
|
+
def test_find_by_tree_number
|
27
|
+
mh = @mesh_tree.find_by_tree_number('G14.640.079')
|
28
28
|
refute_nil mh
|
29
29
|
assert_equal 'D000065', mh.unique_id
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
mh =
|
32
|
+
def test_find_by_original_heading
|
33
|
+
mh = @mesh_tree.find_by_original_heading('Allergens')
|
34
34
|
refute_nil mh
|
35
35
|
assert_equal 'D000485', mh.unique_id
|
36
36
|
end
|
37
37
|
|
38
|
-
|
39
|
-
mh =
|
38
|
+
def test_not_find_original_heading_that_doesnt_exist
|
39
|
+
mh = @mesh_tree.find_by_original_heading('Lorem')
|
40
40
|
assert_nil mh
|
41
41
|
end
|
42
42
|
|
43
|
-
|
44
|
-
mh =
|
43
|
+
def test_have_the_correct_unique_id
|
44
|
+
mh = @mesh_tree.find('D000001')
|
45
45
|
assert_equal 'D000001', mh.unique_id
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
mh =
|
48
|
+
def test_have_the_correct_tree_number
|
49
|
+
mh = @mesh_tree.find('D000001')
|
50
50
|
assert_equal 1, mh.tree_numbers.length
|
51
51
|
assert_includes mh.tree_numbers, 'D03.438.221.173'
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
mh =
|
54
|
+
def test_have_the_correct_tree_numbers
|
55
|
+
mh = @mesh_tree.find('D000224')
|
56
56
|
assert_equal 2, mh.tree_numbers.length
|
57
57
|
assert_includes mh.tree_numbers, 'C19.053.500.263'
|
58
58
|
assert_includes mh.tree_numbers, 'C20.111.163'
|
59
59
|
end
|
60
60
|
|
61
|
-
|
62
|
-
mh =
|
61
|
+
def test_have_the_correct_root_letters
|
62
|
+
mh = @mesh_tree.find('D000224')
|
63
63
|
assert_equal ['C'], mh.roots
|
64
|
-
mh =
|
64
|
+
mh = @mesh_tree.find('D064946')
|
65
65
|
assert_equal ['H', 'N'], mh.roots
|
66
66
|
end
|
67
67
|
|
68
|
-
|
69
|
-
mh =
|
68
|
+
def test_have_the_correct_descriptor_class
|
69
|
+
mh = @mesh_tree.find('D000224')
|
70
70
|
assert_equal :topical_descriptor, mh.descriptor_class
|
71
|
-
mh =
|
71
|
+
mh = @mesh_tree.find('D005260')
|
72
72
|
assert_equal :check_tag, mh.descriptor_class
|
73
73
|
end
|
74
74
|
|
75
|
-
|
76
|
-
mh =
|
75
|
+
def test_have_the_correct_original_heading
|
76
|
+
mh = @mesh_tree.find('D000224')
|
77
77
|
assert_equal 'Addison Disease', mh.original_heading
|
78
|
-
mh =
|
78
|
+
mh = @mesh_tree.find('D000014')
|
79
79
|
assert_equal 'Abnormalities, Drug-Induced', mh.original_heading
|
80
80
|
end
|
81
81
|
|
82
|
-
|
83
|
-
mh =
|
82
|
+
def test_have_anglicised_original_heading
|
83
|
+
mh = @mesh_tree.find('D001471')
|
84
84
|
assert_equal 'Barrett Esophagus', mh.original_heading
|
85
|
-
assert_equal 'Barrett Oesophagus', mh.original_heading(
|
85
|
+
assert_equal 'Barrett Oesophagus', mh.original_heading(:en_gb)
|
86
86
|
end
|
87
87
|
|
88
|
-
|
89
|
-
mh =
|
88
|
+
def test_have_natural_language_name
|
89
|
+
mh = @mesh_tree.find('D000224')
|
90
90
|
assert_equal 'Addison Disease', mh.natural_language_name
|
91
|
-
mh =
|
91
|
+
mh = @mesh_tree.find('D000014')
|
92
92
|
assert_equal 'Drug-Induced Abnormalities', mh.natural_language_name
|
93
93
|
end
|
94
94
|
|
95
|
-
|
96
|
-
mh =
|
95
|
+
def test_have_anglicised_natural_language_name
|
96
|
+
mh = @mesh_tree.find('D001471')
|
97
97
|
assert_equal 'Barrett Esophagus', mh.natural_language_name
|
98
|
-
assert_equal 'Barrett Oesophagus', mh.natural_language_name(
|
98
|
+
assert_equal 'Barrett Oesophagus', mh.natural_language_name(:en_gb)
|
99
99
|
end
|
100
100
|
|
101
|
-
|
102
|
-
mh =
|
101
|
+
def test_have_the_correct_summary
|
102
|
+
mh = @mesh_tree.find('D000238')
|
103
103
|
assert_equal 'A benign tumor of the anterior pituitary in which the cells do not stain with acidic or basic dyes.', mh.summary
|
104
104
|
end
|
105
105
|
|
106
|
-
|
107
|
-
mh =
|
106
|
+
def test_have_anglicised_summary
|
107
|
+
mh = @mesh_tree.find('D001471')
|
108
108
|
assert_equal 'A condition with damage to the lining of the lower ESOPHAGUS resulting from chronic acid reflux (ESOPHAGITIS, REFLUX). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the INTESTINE or the salmon-pink mucosa of the STOMACH. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to ADENOCARCINOMA of the esophagus.', mh.summary
|
109
|
-
assert_equal 'A condition with damage to the lining of the lower OESOPHAGUS resulting from chronic acid reflux (OESOPHAGITIS, REFLUX). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the INTESTINE or the salmon-pink mucosa of the STOMACH. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to ADENOCARCINOMA of the oesophagus.', mh.summary(
|
109
|
+
assert_equal 'A condition with damage to the lining of the lower OESOPHAGUS resulting from chronic acid reflux (OESOPHAGITIS, REFLUX). Through the process of metaplasia, the squamous cells are replaced by a columnar epithelium with cells resembling those of the INTESTINE or the salmon-pink mucosa of the STOMACH. Barrett\'s columnar epithelium is a marker for severe reflux and precursor to ADENOCARCINOMA of the oesophagus.', mh.summary(:en_gb)
|
110
110
|
end
|
111
111
|
|
112
|
-
|
112
|
+
def test_have_the_correct_entries
|
113
113
|
expected_entries = ['Activity Cycles', 'Ultradian Cycles', 'Activity Cycle', 'Cycle, Activity', 'Cycle, Ultradian', 'Cycles, Activity', 'Cycles, Ultradian', 'Ultradian Cycle']
|
114
114
|
expected_entries.sort!
|
115
|
-
mh =
|
115
|
+
mh = @mesh_tree.find('D000204')
|
116
116
|
assert_equal expected_entries, mh.entries
|
117
117
|
end
|
118
118
|
|
119
|
-
|
119
|
+
def test_have_anglicised_entries
|
120
120
|
expected_entries = ['Barrett Esophagus', 'Barrett Syndrome', 'Esophagus, Barrett', 'Barrett Epithelium', 'Barrett Metaplasia', 'Barrett\'s Esophagus', 'Barrett\'s Syndrome', 'Barretts Esophagus', 'Barretts Syndrome', 'Epithelium, Barrett', 'Esophagus, Barrett\'s', 'Syndrome, Barrett', 'Syndrome, Barrett\'s']
|
121
121
|
expected_entries_en = ['Barrett Oesophagus', 'Barrett Syndrome', 'Oesophagus, Barrett', 'Barrett Epithelium', 'Barrett Metaplasia', 'Barrett\'s Oesophagus', 'Barrett\'s Syndrome', 'Barretts Oesophagus', 'Barretts Syndrome', 'Epithelium, Barrett', 'Oesophagus, Barrett\'s', 'Syndrome, Barrett', 'Syndrome, Barrett\'s']
|
122
|
+
|
122
123
|
expected_entries.sort!
|
123
124
|
expected_entries_en.sort!
|
124
|
-
mh =
|
125
|
-
assert_equal expected_entries, mh.entries
|
126
|
-
assert_equal expected_entries_en, mh.entries(
|
125
|
+
mh = @mesh_tree.find('D001471')
|
126
|
+
assert_equal expected_entries.sort, mh.entries
|
127
|
+
assert_equal expected_entries_en.sort, mh.entries(:en_gb)
|
127
128
|
end
|
128
129
|
|
129
|
-
|
130
|
-
mh =
|
130
|
+
def test_have_the_correct_parent
|
131
|
+
mh = @mesh_tree.find('D000001')
|
131
132
|
assert_equal 1, mh.parents.length
|
132
133
|
assert_equal 'D001583', mh.parents[0].unique_id
|
133
134
|
end
|
134
135
|
|
135
|
-
|
136
|
-
mh =
|
137
|
-
p1 =
|
138
|
-
p2 =
|
136
|
+
def test_have_the_correct_parents
|
137
|
+
mh = @mesh_tree.find('D000224')
|
138
|
+
p1 = @mesh_tree.find('D000309')
|
139
|
+
p2 = @mesh_tree.find('D001327')
|
139
140
|
assert_equal 2, mh.parents.length
|
140
141
|
assert_includes mh.parents, p1
|
141
142
|
assert_includes mh.parents, p2
|
142
143
|
end
|
143
144
|
|
144
|
-
|
145
|
-
parent =
|
146
|
-
child1 =
|
147
|
-
child2 =
|
148
|
-
child3 =
|
149
|
-
child4 =
|
145
|
+
def test_have_the_correct_children
|
146
|
+
parent = @mesh_tree.find_by_tree_number('C19.053.500')
|
147
|
+
child1 = @mesh_tree.find_by_tree_number('C19.053.500.263')
|
148
|
+
child2 = @mesh_tree.find_by_tree_number('C19.053.500.270')
|
149
|
+
child3 = @mesh_tree.find_by_tree_number('C19.053.500.480')
|
150
|
+
child4 = @mesh_tree.find_by_tree_number('C19.053.500.740')
|
150
151
|
|
151
152
|
assert_equal 4, parent.children.length
|
152
153
|
assert_includes parent.children, child1
|
@@ -155,41 +156,41 @@ module MESH
|
|
155
156
|
assert_includes parent.children, child4
|
156
157
|
end
|
157
158
|
|
158
|
-
|
159
|
+
def test_have_the_correct_siblings
|
159
160
|
skip
|
160
161
|
end
|
161
162
|
|
162
|
-
|
163
|
-
mh =
|
163
|
+
def test_match_on_conditions_for_original_heading
|
164
|
+
mh = @mesh_tree.find('D001471')
|
164
165
|
assert mh.matches(original_heading: /^Barrett Esophagus$/)
|
165
166
|
end
|
166
167
|
|
167
|
-
|
168
|
-
mh =
|
168
|
+
def test_not_match_on_incorrect_condition_for_original_heading
|
169
|
+
mh = @mesh_tree.find('D001471')
|
169
170
|
refute mh.matches(original_heading: /^Foo$/)
|
170
171
|
end
|
171
172
|
|
172
|
-
|
173
|
-
mh =
|
173
|
+
def test_match_on_conditions_for_entries
|
174
|
+
mh = @mesh_tree.find('D001471')
|
174
175
|
assert mh.matches(entries: /Metaplasia/)
|
175
176
|
end
|
176
177
|
|
177
|
-
|
178
|
-
mh =
|
178
|
+
def test_not_match_on_incorrect_conditions_for_entries
|
179
|
+
mh = @mesh_tree.find('D001471')
|
179
180
|
refute mh.matches(entries: /Foo/)
|
180
181
|
end
|
181
182
|
|
182
|
-
|
183
|
-
mh =
|
183
|
+
def test_match_on_descriptor_class
|
184
|
+
mh = @mesh_tree.find('D000224')
|
184
185
|
assert mh.matches(descriptor_class: :topical_descriptor)
|
185
186
|
refute mh.matches(descriptor_class: :check_tag)
|
186
|
-
mh =
|
187
|
+
mh = @mesh_tree.find('D005260')
|
187
188
|
assert mh.matches(descriptor_class: :check_tag)
|
188
189
|
refute mh.matches(descriptor_class: :topical_descriptor)
|
189
190
|
end
|
190
191
|
|
191
|
-
|
192
|
-
mh =
|
192
|
+
def test_match_on_conditions_for_tree_numbers
|
193
|
+
mh = @mesh_tree.find('D001471')
|
193
194
|
assert mh.matches(tree_numbers: /C06\.198\.102/)
|
194
195
|
assert mh.matches(tree_numbers: /^C06\.198\.102$/)
|
195
196
|
assert mh.matches(tree_numbers: /^C06/)
|
@@ -197,23 +198,23 @@ module MESH
|
|
197
198
|
assert mh.matches(tree_numbers: /^C06\.405\.117\.102$/)
|
198
199
|
end
|
199
200
|
|
200
|
-
|
201
|
-
mh =
|
201
|
+
def test_not_match_on_incorrect_conditions_for_tree_numbers
|
202
|
+
mh = @mesh_tree.find('D001471')
|
202
203
|
refute mh.matches(tree_numbers: /Foo/)
|
203
204
|
end
|
204
205
|
|
205
|
-
|
206
|
-
mh =
|
206
|
+
def test_match_on_conditions_for_summary
|
207
|
+
mh = @mesh_tree.find('D001471')
|
207
208
|
assert mh.matches(summary: /the lower ESOPHAGUS resulting from chronic acid reflux \(ESOPHAGITIS, REFLUX\)\./)
|
208
209
|
end
|
209
210
|
|
210
|
-
|
211
|
-
mh =
|
211
|
+
def test_not_match_on_incorrect_conditions_for_summary
|
212
|
+
mh = @mesh_tree.find('D001471')
|
212
213
|
refute mh.matches(summary: /Foo/)
|
213
214
|
end
|
214
215
|
|
215
|
-
|
216
|
-
mh =
|
216
|
+
def test_match_on_conditions_for_useful
|
217
|
+
mh = @mesh_tree.find('D001471')
|
217
218
|
begin
|
218
219
|
mh.useful = true
|
219
220
|
assert mh.matches(useful: true)
|
@@ -226,88 +227,88 @@ module MESH
|
|
226
227
|
end
|
227
228
|
end
|
228
229
|
|
229
|
-
|
230
|
-
mh =
|
230
|
+
def test_match_on_multiple_conditions
|
231
|
+
mh = @mesh_tree.find('D001471')
|
231
232
|
assert mh.matches(original_heading: /^Barrett Esophagus$/, summary: /the lower ESOPHAGUS/)
|
232
233
|
end
|
233
234
|
|
234
|
-
|
235
|
-
mh =
|
235
|
+
def test_not_match_on_incorrect_multiple_conditions
|
236
|
+
mh = @mesh_tree.find('D001471')
|
236
237
|
refute mh.matches(original_heading: /^Barrett Esophagus$/, summary: /Foo/)
|
237
238
|
refute mh.matches(original_heading: /^Foo/, summary: /the lower ESOPHAGUS/)
|
238
239
|
end
|
239
240
|
|
240
|
-
|
241
|
+
def test_match_headings_that_occur_in_given_text
|
241
242
|
expected_ids = %w(D001491 D001769 D001792 D001853 D002470 D002477 D002648 D002965 D002999 D003561 D003593 D003643 D004194 D004314 D004813 D004912 D005091 D005123 D005293 D005333 D005385 D005544 D005796 D006128 D006225 D006309 D006321 D006331 D006405 D007107 D007223 D007231 D007239 D007246 D007938 D007947 D008099 D008168 D008214 D008423 D008533 D008607 D008722 D009035 D009055 D009132 D009154 D009190 D009196 D009369 D009666 D010372 D010641 D011153 D012008 D012106 D012146 D012306 D012307 D012380 D012680 D012867 D013534 D013601 D013812 D013921 D013961 D014034 D014157 D014171 D014960 D015032 D015470 D015994 D015995 D016424 D016433 D017584 D017668 D018387 D018388 D019021 D019070 D019368 D019369 D032882 D036801 D038042 D041905 D052016 D054198 D055016)
|
242
|
-
expected = expected_ids.map { |id|
|
243
|
-
matches =
|
243
|
+
expected = expected_ids.map { |id| @mesh_tree.find(id) }
|
244
|
+
matches = @mesh_tree.match_in_text(@example_text)
|
244
245
|
actual = matches.map { |match| match[:heading] }.uniq
|
245
246
|
assert_equal expected.sort, actual.sort
|
246
247
|
end
|
247
248
|
|
248
|
-
|
249
|
+
def test_sort_based_on_unique_id
|
249
250
|
skip
|
250
251
|
end
|
251
252
|
|
252
|
-
|
253
|
-
expected =
|
254
|
-
actual =
|
253
|
+
def test_only_match_the_most_specific_matches_in_given_text
|
254
|
+
expected = @mesh_tree.find('D054144')
|
255
|
+
actual = @mesh_tree.match_in_text('Diastolic Heart Failure')
|
255
256
|
assert_equal 1, actual.length
|
256
257
|
assert_equal expected, actual.first[:heading]
|
257
258
|
end
|
258
259
|
|
259
|
-
|
260
|
+
def test_only_match_useful_headings_that_occur_in_given_text
|
260
261
|
expected_ids = %w(D001491 D001769 D001792 D001853 D002470 D002648 D002875 D002965 D003561 D003593 D003643 D004194 D004314 D004813 D004912 D005091 D005123 D005293 D005333 D005385 D005544 D005796 D006128 D006225 D006309 D006321 D006331 D006405 D007107 D007231 D007239 D007938 D007947 D008099 D008168 D008214 D008423 D008607 D008722 D009035 D009055 D009132 D009154 D009190 D009196 D009369 D009666 D010372 D010641 D011153 D012008 D012106 D012146 D012306 D012307 D012380 D012680 D012867 D013534 D013601 D013812 D013921 D013961 D014034 D014157 D014171 D015032 D015470 D015994 D015995 D016424 D017584 D017668 D018387 D018388 D019021 D019070 D019368 D019369 D032882 D036801 D038042 D041905 D052016 D054198)
|
261
262
|
|
262
263
|
not_useful_ids = %w(D007246 D002477 D014960 D008533 D016433 D006664 D055016 D002999 D007223)
|
263
264
|
begin
|
264
|
-
not_useful_ids.each { |id|
|
265
|
+
not_useful_ids.each { |id| @mesh_tree.find(id).useful = false }
|
265
266
|
|
266
|
-
expected = expected_ids.map { |id|
|
267
|
-
matches =
|
267
|
+
expected = expected_ids.map { |id| @mesh_tree.find(id) }
|
268
|
+
matches = @mesh_tree.match_in_text(@example_text)
|
268
269
|
actual = matches.map { |match| match[:heading] }.uniq
|
269
270
|
assert_equal expected, actual
|
270
271
|
ensure
|
271
|
-
not_useful_ids.each { |id|
|
272
|
+
not_useful_ids.each { |id| @mesh_tree.find(id).useful = true }
|
272
273
|
end
|
273
274
|
end
|
274
275
|
|
275
|
-
|
276
|
+
def test_match_headings_at_start_of_text
|
276
277
|
text = 'Leukemia, lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium leo diam, quis adipiscing purus bibendum eu.'
|
277
|
-
matches =
|
278
|
+
matches = @mesh_tree.match_in_text(text)
|
278
279
|
assert_equal 1, matches.length
|
279
|
-
assert_equal
|
280
|
+
assert_equal @mesh_tree.find('D007938'), matches[0][:heading]
|
280
281
|
end
|
281
282
|
|
282
|
-
|
283
|
+
def test_match_headings_at_end_of_text
|
283
284
|
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium leo diam, quis adipiscing purus bibendum eu leukemia'
|
284
|
-
matches =
|
285
|
+
matches = @mesh_tree.match_in_text(text)
|
285
286
|
assert_equal 1, matches.length
|
286
|
-
assert_equal
|
287
|
+
assert_equal @mesh_tree.find('D007938'), matches[0][:heading]
|
287
288
|
end
|
288
289
|
|
289
|
-
|
290
|
-
assert_equal [],
|
290
|
+
def test_return_no_matches_when_given_nil_text
|
291
|
+
assert_equal [], @mesh_tree.match_in_text(nil)
|
291
292
|
end
|
292
293
|
|
293
|
-
|
294
|
+
def test_only_match_uppercase_entries_with_uppercase_text
|
294
295
|
text = 'Lorem amet, consectetur adipiscing elit. Donec pretium ATP leo diam, quis adipiscing purus bibendum.'
|
295
|
-
matches =
|
296
|
+
matches = @mesh_tree.match_in_text(text)
|
296
297
|
assert_equal 1, matches.length
|
297
|
-
assert_equal
|
298
|
+
assert_equal @mesh_tree.find('D000255'), matches[0][:heading]
|
298
299
|
text = 'Lorem ipsum consectetur adipiscing elit. Donec pretium atp leo diam, quis adipiscing purus bibendum.'
|
299
|
-
assert_equal [],
|
300
|
+
assert_equal [], @mesh_tree.match_in_text(text)
|
300
301
|
end
|
301
302
|
|
302
|
-
|
303
|
+
def test_match_anglicised_terms_in_text
|
303
304
|
text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pretium leo diam, quis adipiscing purus bibendum eu leukaemia'
|
304
|
-
matches =
|
305
|
+
matches = @mesh_tree.match_in_text(text)
|
305
306
|
assert_equal 1, matches.length
|
306
|
-
assert_equal
|
307
|
+
assert_equal @mesh_tree.find('D007938'), matches[0][:heading]
|
307
308
|
end
|
308
309
|
|
309
|
-
|
310
|
-
mh =
|
310
|
+
def test_allow_headings_to_be_marked_as_not_useful
|
311
|
+
mh = @mesh_tree.find('D055550')
|
311
312
|
mh.useful = true
|
312
313
|
assert mh.useful
|
313
314
|
mh.useful = false
|
@@ -316,91 +317,91 @@ module MESH
|
|
316
317
|
assert mh.useful
|
317
318
|
end
|
318
319
|
|
319
|
-
|
320
|
-
expected = [
|
321
|
-
actual =
|
320
|
+
def test_allow_headings_to_be_found_with_a_where_match_on_original_heading
|
321
|
+
expected = [@mesh_tree.find('D003561'), @mesh_tree.find('D016238')]
|
322
|
+
actual = @mesh_tree.where(original_heading: /^Cyta/)
|
322
323
|
assert_equal expected, actual
|
323
324
|
end
|
324
325
|
|
325
|
-
|
326
|
+
def test_match_on_entries_in_where
|
326
327
|
expected_ids = %w( D002397 D003064 D003400 D003532 D004284 D004289 D004555 D005412 D006054 D006196 D007059 D007497 D007695 D009990 D010473 D012091 D012487 D012758 D013215 D015027 D020410 D023721 D023761 D023781 D024541 D029961 D037401 D037462 D048251 D049832 D052656 D057096 )
|
327
|
-
expected = expected_ids.map { |id|
|
328
|
-
actual =
|
328
|
+
expected = expected_ids.map { |id| @mesh_tree.find(id) }
|
329
|
+
actual = @mesh_tree.where(entries: /fish/)
|
329
330
|
assert_equal expected, actual
|
330
331
|
end
|
331
332
|
|
332
|
-
|
333
|
+
def test_match_on_tree_numbers_in_where
|
333
334
|
expected_ids = %w( D000005 D001415 D010388 D013909 )
|
334
|
-
expected = expected_ids.map { |id|
|
335
|
-
actual =
|
335
|
+
expected = expected_ids.map { |id| @mesh_tree.find(id) }
|
336
|
+
actual = @mesh_tree.where(tree_numbers: /^A01\.923\.[0-9]{3}$/)
|
336
337
|
assert_equal expected, actual
|
337
338
|
end
|
338
339
|
|
339
|
-
|
340
|
-
expected = [
|
340
|
+
def test_match_on_useful_in_where
|
341
|
+
expected = [@mesh_tree.find('D012000'), @mesh_tree.find('D064906'), @mesh_tree.find('D064966')]
|
341
342
|
begin
|
342
343
|
expected.each { |mh| mh.useful = false }
|
343
|
-
actual =
|
344
|
+
actual = @mesh_tree.where(useful: false)
|
344
345
|
assert_equal expected, actual
|
345
346
|
ensure
|
346
347
|
expected.each { |mh| mh.useful = true }
|
347
348
|
end
|
348
349
|
end
|
349
350
|
|
350
|
-
|
351
|
-
expected = [
|
351
|
+
def test_match_on_descriptor_class_in_where
|
352
|
+
expected = [@mesh_tree.find('D012000'), @mesh_tree.find('D064906'), @mesh_tree.find('D064966')]
|
352
353
|
begin
|
353
354
|
expected.each { |mh| mh.descriptor_class = :foo }
|
354
|
-
actual =
|
355
|
+
actual = @mesh_tree.where(descriptor_class: :foo)
|
355
356
|
assert_equal expected, actual
|
356
357
|
ensure
|
357
358
|
expected.each { |mh| mh.descriptor_class = :topical_descriptor }
|
358
359
|
end
|
359
360
|
end
|
360
361
|
|
361
|
-
|
362
|
+
def test_only_include_useful_headings_in_each
|
362
363
|
begin
|
363
|
-
|
364
|
+
@mesh_tree.each do |mh|
|
364
365
|
mh.useful = false
|
365
366
|
end
|
366
|
-
|
367
|
+
@mesh_tree.where(unique_id: /^D0000/).each do |mh|
|
367
368
|
mh.useful = true
|
368
369
|
end
|
369
370
|
count = 0
|
370
|
-
|
371
|
+
@mesh_tree.each do |mh|
|
371
372
|
assert mh.useful
|
372
373
|
count += 1
|
373
374
|
end
|
374
375
|
assert_equal 95, count
|
375
376
|
ensure
|
376
|
-
|
377
|
+
@mesh_tree.where(useful: false).each do |mh|
|
377
378
|
mh.useful = true
|
378
379
|
end
|
379
380
|
end
|
380
381
|
end
|
381
382
|
|
382
|
-
|
383
|
+
def test_know_its_deepest_position_in_the_tree
|
383
384
|
#single tree numbers
|
384
|
-
assert_equal 1,
|
385
|
-
assert_equal 2,
|
386
|
-
assert_equal 3,
|
387
|
-
assert_equal 4,
|
385
|
+
assert_equal 1, @mesh_tree.find('D002319').deepest_position
|
386
|
+
assert_equal 2, @mesh_tree.find('D001808').deepest_position
|
387
|
+
assert_equal 3, @mesh_tree.find('D001158').deepest_position
|
388
|
+
assert_equal 4, @mesh_tree.find('D001981').deepest_position
|
388
389
|
end
|
389
390
|
|
390
|
-
|
391
|
+
def test_know_its_shallowest_position_in_the_tree
|
391
392
|
#single tree numbers
|
392
|
-
assert_equal 1,
|
393
|
-
assert_equal 2,
|
394
|
-
assert_equal 3,
|
395
|
-
assert_equal 4,
|
393
|
+
assert_equal 1, @mesh_tree.find('D002319').shallowest_position
|
394
|
+
assert_equal 2, @mesh_tree.find('D001808').shallowest_position
|
395
|
+
assert_equal 3, @mesh_tree.find('D001158').shallowest_position
|
396
|
+
assert_equal 4, @mesh_tree.find('D001981').shallowest_position
|
396
397
|
end
|
397
398
|
|
398
|
-
|
399
|
-
parent =
|
400
|
-
child =
|
401
|
-
grandchild =
|
402
|
-
great_grandchild =
|
403
|
-
unrelated =
|
399
|
+
def test_know_if_one_heading_is_the_descendant_of_another
|
400
|
+
parent = @mesh_tree.find('D002319')
|
401
|
+
child = @mesh_tree.find('D001808')
|
402
|
+
grandchild = @mesh_tree.find('D001158')
|
403
|
+
great_grandchild = @mesh_tree.find('D001981')
|
404
|
+
unrelated = @mesh_tree.find('D008091')
|
404
405
|
|
405
406
|
refute parent.has_descendant(parent), 'should not consider itself a desecendant'
|
406
407
|
assert parent.has_descendant(child), "should consider child #{child.inspect} a descendant of #{parent.inspect} in #{parent.children}"
|
@@ -409,12 +410,12 @@ module MESH
|
|
409
410
|
refute parent.has_descendant(unrelated), 'should not consider an unrelated heading a descendant'
|
410
411
|
end
|
411
412
|
|
412
|
-
|
413
|
-
child =
|
414
|
-
parent =
|
415
|
-
grandparent =
|
416
|
-
great_grandparent =
|
417
|
-
unrelated =
|
413
|
+
def test_know_if_one_heading_is_the_ancestor_of_another
|
414
|
+
child = @mesh_tree.find('D001981')
|
415
|
+
parent = @mesh_tree.find('D001158')
|
416
|
+
grandparent = @mesh_tree.find('D001808')
|
417
|
+
great_grandparent = @mesh_tree.find('D002319')
|
418
|
+
unrelated = @mesh_tree.find('D008091')
|
418
419
|
|
419
420
|
refute child.has_ancestor(child), 'should not consider itself an ancestor'
|
420
421
|
assert child.has_ancestor(parent), "should consider parent #{parent.inspect} an ancestor of #{child.inspect} in #{child.parents}"
|
@@ -423,13 +424,13 @@ module MESH
|
|
423
424
|
refute child.has_ancestor(unrelated), 'should not consider an unrelated heading an ancestor'
|
424
425
|
end
|
425
426
|
|
426
|
-
|
427
|
-
parent =
|
428
|
-
child1 =
|
429
|
-
child2 =
|
430
|
-
child3 =
|
431
|
-
child4 =
|
432
|
-
unrelated =
|
427
|
+
def test_know_if_headings_are_siblings_at_the_same_level_below_a_common_parent
|
428
|
+
parent = @mesh_tree.find_by_tree_number('C19.053.500')
|
429
|
+
child1 = @mesh_tree.find_by_tree_number('C19.053.500.263')
|
430
|
+
child2 = @mesh_tree.find_by_tree_number('C19.053.500.270')
|
431
|
+
child3 = @mesh_tree.find_by_tree_number('C19.053.500.480')
|
432
|
+
child4 = @mesh_tree.find_by_tree_number('C19.053.500.740')
|
433
|
+
unrelated = @mesh_tree.find('D008091')
|
433
434
|
children = [child1, child2, child3, child4]
|
434
435
|
|
435
436
|
children.each { |c| refute parent.sibling?(c) }
|
@@ -442,15 +443,17 @@ module MESH
|
|
442
443
|
children.each { |c| refute c.sibling?(unrelated) }
|
443
444
|
end
|
444
445
|
|
445
|
-
|
446
|
-
mh =
|
446
|
+
def test_override_inspect_to_prevent_issues_in_test_diagnostics
|
447
|
+
mh = @mesh_tree.find('D001471')
|
447
448
|
expected = "#{mh.unique_id}, #{mh.original_heading}, [#{mh.tree_numbers.join(',')}]"
|
448
449
|
assert_equal expected, mh.inspect
|
449
450
|
end
|
450
451
|
|
451
|
-
|
452
|
-
|
453
|
-
|
452
|
+
def setup
|
453
|
+
@@mesh_tree ||= MESH::Tree.new
|
454
|
+
@@mesh_tree.load_translation(:en_gb)
|
455
|
+
@mesh_tree = @@mesh_tree
|
456
|
+
@example_text ||= 'Leukaemia in Downs Syndrome
|
454
457
|
Overview
|
455
458
|
Downs Syndrome Leukaemia The link between Downs Syndrome and Leukaemia
|
456
459
|
Epidemiology
|
@@ -619,9 +622,6 @@ why are GATA1 mutations so relatively common in children with DS It has been po
|
|
619
622
|
thirdly, what is the second-hit We know that there must be a second genetic event, with GATA1 mutation being the first, but we do not know what this is yet.NB: GATA1 mutation is the first mutation for DS-AMKL.AML failure of treatment usually due to toxicity due to mucositis and infection. Resistant disease and relapse are rare.
|
620
623
|
ALL there is no increased sensitivity to treatment, but there is increased risk of toxicity. Cannot reduce the dose because of the high risk of relapse and so the emphasis is now on improving supportive care.
|
621
624
|
'
|
622
|
-
|
623
625
|
end
|
624
|
-
|
625
|
-
|
626
626
|
end
|
627
627
|
end
|