simple_bioc 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 74a3d6d3513cdaa61df2b88050b9a44cf0852ed1
4
- data.tar.gz: 8c14726b89b7d2f79ffc63b8db0ac5427d38640a
3
+ metadata.gz: 38665d005a277e7bd83304fe0773618a2f242d54
4
+ data.tar.gz: 7101cfef679db82fbebc46d209b132a5a0952b6b
5
5
  SHA512:
6
- metadata.gz: 2559a63848b14f15b0a26a745ae7d1a58d677fbfd520b7f42467e76a2b69bdffda4eeedf73319c79a3d13abcbf7ad008f87899c36111dd6ae1e6591767a0e281
7
- data.tar.gz: c25c91ce425ed2b1a4050898ae61415507c4720c9c54b660461d0ebb7535ffe1d821142cc0db9dc66d18e74c9153c3d74a7590395f4fa3c574958e06ba4332f6
6
+ metadata.gz: 9b57ddecef7b4ed0654736a34dbf64af7a9096cb7a7b10bef11ed48bf4caa01540053177e9ae39c30bfe68c5eab81e8f755ee7030c5cfec2fe1cae4afed8f4da
7
+ data.tar.gz: e306a112cf15ccc092e93478226e35ce9f391fc456371791e4f0e74838efcfe05a7f26c0216ebd5e1a0fd93dbef1ee469c5479596189003e5bc1d12be56c4e0a
@@ -128,32 +128,78 @@ module BioCMerger
128
128
  end
129
129
  end
130
130
  def copy_relation(doc, dest, relation, id_map)
131
- new_r = SimpleBioC::Relation.new(dest)
132
- new_r.id = choose_id(doc, relation.id, id_map)
131
+ new_r = nil
132
+ need_add = true
133
+ dest.relations.each do |r|
134
+ if r.id == relation.id
135
+ new_r = r
136
+ need_add = false
137
+ break
138
+ end
139
+ end
140
+ if new_r.nil?
141
+ new_r = SimpleBioC::Relation.new(dest)
142
+ new_r.id = choose_id(doc, relation.id, id_map)
143
+ new_r.original = relation
144
+ end
145
+
133
146
  relation.nodes.each do |n|
134
- node = SimpleBioC::Node.new(new_r)
135
- node.refid = n.refid
136
- node.role = n.role
137
- new_r.nodes << node
147
+ found = false
148
+ new_r.nodes.each do |old_n|
149
+ if n.refid == old_n.refid && n.role == old_n.role
150
+ found = true
151
+ break
152
+ end
153
+ end
154
+ unless found
155
+ node = SimpleBioC::Node.new(new_r)
156
+ node.refid = n.refid
157
+ node.role = n.role
158
+ new_r.nodes << node
159
+ end
138
160
  end
139
161
  copy_infons(new_r, relation)
140
- new_r.original = relation
141
- dest.relations << new_r
162
+ if need_add
163
+ dest.relations << new_r
164
+ end
142
165
  end
143
166
 
144
167
  def copy_annotation(doc, dest, annotation, id_map)
145
- new_a = SimpleBioC::Annotation.new(dest)
146
- new_a.id = choose_id(doc, annotation.id, id_map)
147
- new_a.text = annotation.text
148
- new_a.locations = []
168
+ new_a = nil
169
+ need_add = true
170
+ dest.annotations.each do |a|
171
+ if a.id == annotation.id && a.text == annotation.text
172
+ new_a = a
173
+ need_add = false
174
+ break
175
+ end
176
+ end
177
+ if new_a.nil?
178
+ new_a = SimpleBioC::Annotation.new(dest)
179
+ new_a.id = choose_id(doc, annotation.id, id_map)
180
+ new_a.text = annotation.text
181
+ new_a.locations = []
182
+ end
183
+
149
184
  annotation.locations.each do |l|
150
- new_l = SimpleBioC::Location.new(new_a)
151
- new_l.offset = l.offset
152
- new_l.length = l.length
153
- new_a.locations << new_l
185
+ found = false
186
+ new_a.locations.each do |old_l|
187
+ if l.offset == old_l.offset && l.length == old_l.length
188
+ found = true
189
+ break
190
+ end
191
+ end
192
+ unless found
193
+ new_l = SimpleBioC::Location.new(new_a)
194
+ new_l.offset = l.offset
195
+ new_l.length = l.length
196
+ new_a.locations << new_l
197
+ end
154
198
  end
155
199
  copy_infons(new_a, annotation)
156
- dest.annotations << new_a
200
+ if need_add
201
+ dest.annotations << new_a
202
+ end
157
203
  end
158
204
 
159
205
  def choose_id(doc, id, id_map)
@@ -1,3 +1,3 @@
1
1
  module SimpleBioC
2
- VERSION = "0.0.9"
2
+ VERSION = "0.0.10"
3
3
  end
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.9
4
+ version: 0.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dongseop Kwon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-14 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri