rgfa 1.2.1 → 1.3.1
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/bin/{gfadiff.rb → gfadiff} +0 -0
- data/bin/{rgfa-findcrisprs.rb → rgfa-findcrisprs} +0 -0
- data/bin/{rgfa-mergelinear.rb → rgfa-mergelinear} +0 -0
- data/bin/{rgfa-simdebruijn.rb → rgfa-simdebruijn} +0 -0
- data/lib/rgfa/cigar.rb +5 -5
- data/lib/rgfa/field_parser.rb +7 -1
- data/lib/rgfa/field_validator.rb +14 -0
- data/lib/rgfa/line.rb +7 -1
- data/lib/rgfa/line/comment.rb +13 -0
- data/lib/rgfa/line/containment.rb +10 -6
- data/lib/rgfa/line/link.rb +59 -68
- data/lib/rgfa/line/path.rb +15 -15
- data/lib/rgfa/lines.rb +3 -0
- data/lib/rgfa/links.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492cbcdfb283859725e35bc0586bbdebe1db4efb
|
4
|
+
data.tar.gz: 1a23616c8b8c3f00384fac70c2d147cfa84ba6d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4498bd2b97520366f5bfa537cce2874ec0ccceb72ee3222fcddcdda1de4899ffd14397ae0ac2a9a0ac9b2bb3df9951519f3c57e8e8e183f01c9a09e9216749f
|
7
|
+
data.tar.gz: c955e4647ecc1b250f62bf2f1d5246a48fcd097b6cf0d6ce76426971701643143e7a7dd78ba2ecf4f303132b939596433632493cd4dbbb32032c831b7010a113
|
data/bin/{gfadiff.rb → gfadiff}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/rgfa/cigar.rb
CHANGED
@@ -4,11 +4,11 @@ require_relative "error.rb"
|
|
4
4
|
# Represents the contents of a CIGAR string.
|
5
5
|
class RGFA::CIGAR < Array
|
6
6
|
|
7
|
-
# Compute the CIGAR for the segments
|
7
|
+
# Compute the CIGAR for the segments when these are switched.
|
8
8
|
#
|
9
|
-
# @example
|
9
|
+
# @example Computing the complement CIGAR
|
10
10
|
#
|
11
|
-
# RGFA::CIGAR.from_string("2M1D3M").
|
11
|
+
# RGFA::CIGAR.from_string("2M1D3M").complement.to_s
|
12
12
|
# # => "3M1I2M"
|
13
13
|
#
|
14
14
|
# # S1 + S2 + 2M1D3M
|
@@ -22,8 +22,8 @@ class RGFA::CIGAR < Array
|
|
22
22
|
# # S2 - S1 - 3M1I2M
|
23
23
|
#
|
24
24
|
# @return [RGFA::CIGAR] (empty if CIGAR string is *)
|
25
|
-
def
|
26
|
-
|
25
|
+
def complement
|
26
|
+
reverse.map do |op|
|
27
27
|
if op.code == :I
|
28
28
|
op.code = :D
|
29
29
|
elsif op.code == :D
|
data/lib/rgfa/field_parser.rb
CHANGED
@@ -19,11 +19,17 @@ module RGFA::FieldParser
|
|
19
19
|
fieldname: nil,
|
20
20
|
frozen: false)
|
21
21
|
case datatype
|
22
|
+
when :cmt
|
23
|
+
return self
|
22
24
|
when :A, :Z, :seq
|
23
25
|
validate_gfa_field!(datatype, fieldname: fieldname) if validate_strings
|
24
26
|
self.freeze if frozen
|
25
27
|
return self
|
26
|
-
when :lbl
|
28
|
+
when :lbl
|
29
|
+
validate_segment_name!
|
30
|
+
validate_gfa_field!(datatype, fieldname: fieldname) if validate_strings
|
31
|
+
return to_sym.freeze
|
32
|
+
when :orn
|
27
33
|
validate_gfa_field!(datatype, fieldname: fieldname) if validate_strings
|
28
34
|
return to_sym.freeze
|
29
35
|
when :i
|
data/lib/rgfa/field_validator.rb
CHANGED
@@ -27,6 +27,7 @@ module RGFA::FieldValidator
|
|
27
27
|
:cig => /^(\*|(([0-9]+[MIDNSHPX=])+))$/, # CIGAR string
|
28
28
|
:cgs => /^(\*|(([0-9]+[MIDNSHPX=])+))(,(\*|(([0-9]+[MIDNSHPX=])+)))*$/,
|
29
29
|
# multiple CIGARs, comma-sep
|
30
|
+
:cmt => /.*/, # content of comment line, everything is allowed
|
30
31
|
}
|
31
32
|
|
32
33
|
# Validates the string according to the provided datatype
|
@@ -49,6 +50,19 @@ module RGFA::FieldValidator
|
|
49
50
|
end
|
50
51
|
end
|
51
52
|
|
53
|
+
# Validates segment names, to check that they do not contain + or -
|
54
|
+
# followed by comma
|
55
|
+
# @raise [RGFA::FieldParser::FormatError] if the segment name is invalid
|
56
|
+
# @return [void]
|
57
|
+
# @api private
|
58
|
+
def validate_segment_name!
|
59
|
+
if self =~ /.*[+-],.*/
|
60
|
+
raise RGFA::FieldParser::FormatError,
|
61
|
+
"Segment names are not allowed to contain +/- followed by comma "+
|
62
|
+
"(found: #{self})"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
52
66
|
end
|
53
67
|
|
54
68
|
class String
|
data/lib/rgfa/line.rb
CHANGED
@@ -126,6 +126,7 @@ class RGFA::Line
|
|
126
126
|
when :L then RGFA::Line::Link
|
127
127
|
when :C then RGFA::Line::Containment
|
128
128
|
when :P then RGFA::Line::Path
|
129
|
+
when :"#" then RGFA::Line::Comment
|
129
130
|
else
|
130
131
|
raise RGFA::Line::UnknownRecordTypeError,
|
131
132
|
"Record type unknown: '#{record_type}'"
|
@@ -684,6 +685,7 @@ require_relative "line/segment.rb"
|
|
684
685
|
require_relative "line/path.rb"
|
685
686
|
require_relative "line/link.rb"
|
686
687
|
require_relative "line/containment.rb"
|
688
|
+
require_relative "line/comment.rb"
|
687
689
|
|
688
690
|
# Extensions to the String core class.
|
689
691
|
#
|
@@ -696,7 +698,11 @@ class String
|
|
696
698
|
# @param validate [Integer] <i>(defaults to: 2)</i>
|
697
699
|
# see RGFA::Line#initialize
|
698
700
|
def to_rgfa_line(validate: 2)
|
699
|
-
|
701
|
+
if self[0] == "#"
|
702
|
+
return RGFA::Line::Comment.new([self[1..-1]], validate: 0)
|
703
|
+
else
|
704
|
+
split(RGFA::Line::SEPARATOR).to_rgfa_line(validate: validate)
|
705
|
+
end
|
700
706
|
end
|
701
707
|
|
702
708
|
end
|
@@ -56,11 +56,15 @@ class RGFA::Line::Containment < RGFA::Line
|
|
56
56
|
return rpos
|
57
57
|
end
|
58
58
|
|
59
|
-
# Returns true if the containment is
|
59
|
+
# Returns true if the containment is canonical, false otherwise
|
60
60
|
#
|
61
|
-
#
|
61
|
+
# == Definition of canonical containment
|
62
62
|
#
|
63
|
-
#
|
63
|
+
# A containment is canonical if the from orientation is +
|
64
|
+
#
|
65
|
+
# === Details
|
66
|
+
#
|
67
|
+
# Each containment has an equivalent complement containment.
|
64
68
|
# Consider a containment of B (length:8) in A (length:100) at position 9 of A
|
65
69
|
# with a cigar 1M1I2M3D4M (i.e. rpos = 19).
|
66
70
|
#
|
@@ -69,18 +73,18 @@ class RGFA::Line::Containment < RGFA::Line
|
|
69
73
|
# A- B+ 1M1I2M3D4M 9 == A+ B- 4M3D2M1I1M 80
|
70
74
|
# A- B- 1M1I2M3D4M 9 == A+ B+ 4M3D2M1I1M 80
|
71
75
|
#
|
72
|
-
# Pos in the
|
76
|
+
# Pos in the complement is equal to the length of A minus the right pos
|
73
77
|
# of B before reversing.
|
74
78
|
#
|
75
79
|
# We require here that A != B as A == B makes no sense for containments.
|
76
80
|
# Thus it is always possible to express the containment using a positive
|
77
81
|
# from orientation.
|
78
82
|
#
|
79
|
-
# For this reason the
|
83
|
+
# For this reason the canon is simply defined as + from orientation.
|
80
84
|
#
|
81
85
|
# @return [Boolean]
|
82
86
|
#
|
83
|
-
def
|
87
|
+
def canonical?
|
84
88
|
from_orient == :+
|
85
89
|
end
|
86
90
|
|
data/lib/rgfa/line/link.rb
CHANGED
@@ -112,108 +112,99 @@ class RGFA::Line::Link < RGFA::Line
|
|
112
112
|
to.to_sym
|
113
113
|
end
|
114
114
|
|
115
|
-
# Returns true if the link is
|
115
|
+
# Returns true if the link is canonical, false otherwise
|
116
116
|
#
|
117
|
-
# == Definition of
|
117
|
+
# == Definition of canonical link
|
118
118
|
#
|
119
|
-
#
|
120
|
-
#
|
119
|
+
# A link if canonical if:
|
120
|
+
# - from != to and from < to (lexicographically); or
|
121
|
+
# - from == to and at least one of from_orient or to_orient is +
|
121
122
|
#
|
122
|
-
#
|
123
|
-
# from- to to- (1M1I2M) == to+ to from+ (2M1D1M)
|
124
|
-
# from+ to to- (1M1I2M) == to+ to from- (2M1D1M)
|
125
|
-
# from- to to+ (1M1I2M) == to- to from+ (2M1D1M)
|
123
|
+
# === Details
|
126
124
|
#
|
127
|
-
#
|
128
|
-
#
|
125
|
+
# In the special case in which from == to (== s) we have the
|
126
|
+
# following equivalences:
|
129
127
|
#
|
130
|
-
#
|
131
|
-
#
|
132
|
-
#
|
133
|
-
#
|
128
|
+
# s + s + == s - s -
|
129
|
+
# s - s - == s + s + (same as previous case)
|
130
|
+
# s + s - == s + s - (equivalent to itself)
|
131
|
+
# s - s + == s - s + (equivalent to itself)
|
134
132
|
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
133
|
+
# Considering the values on the left, the first one can be taken as
|
134
|
+
# canonical, the second not, because it can be transformed in the first
|
135
|
+
# one; the other two values are canonical, as they are only equivalent
|
136
|
+
# to themselves.
|
139
137
|
#
|
140
138
|
# @return [Boolean]
|
141
139
|
#
|
142
|
-
def
|
140
|
+
def canonical?
|
143
141
|
if from_name < to_name
|
144
142
|
return true
|
145
143
|
elsif from_name > to_name
|
146
144
|
return false
|
147
145
|
else
|
148
|
-
|
149
|
-
reverse_overlap_s = reverse_overlap.to_s
|
150
|
-
if overlap_s < reverse_overlap_s
|
151
|
-
return true
|
152
|
-
elsif overlap_s > reverse_overlap_s
|
153
|
-
return false
|
154
|
-
else
|
155
|
-
return [from_orient, to_orient].include?(:+)
|
156
|
-
end
|
146
|
+
return [from_orient, to_orient].include?(:+)
|
157
147
|
end
|
158
148
|
end
|
159
149
|
|
160
|
-
# Returns the unchanged link if the link is
|
161
|
-
# otherwise
|
150
|
+
# Returns the unchanged link if the link is canonical,
|
151
|
+
# otherwise complements the link and returns it.
|
162
152
|
#
|
163
153
|
# @note The path references are not corrected by this method; therefore
|
164
154
|
# the method shall be used before the link is embedded in a graph.
|
165
155
|
#
|
166
156
|
# @return [RGFA::Line::Link] self
|
167
|
-
def
|
168
|
-
|
157
|
+
def canonicize!
|
158
|
+
complement! if !canonical?
|
169
159
|
end
|
170
160
|
|
171
|
-
# Creates
|
161
|
+
# Creates the equivalent link with from/to inverted.
|
162
|
+
#
|
172
163
|
# The CIGAR operations (order/type) are inverted as well.
|
173
164
|
# Optional fields are left unchanged.
|
174
165
|
#
|
175
|
-
# @note The path references are not copied to the
|
166
|
+
# @note The path references are not copied to the complement link.
|
176
167
|
#
|
177
168
|
# @note This method shall be overridden if custom optional fields
|
178
|
-
# are defined, which have a ``
|
179
|
-
# their value in the equivalent
|
169
|
+
# are defined, which have a ``complementation'' operation which determines
|
170
|
+
# their value in the equivalent complement link.
|
180
171
|
#
|
181
172
|
# @return [RGFA::Line::Link] the inverted link.
|
182
|
-
def
|
173
|
+
def complement
|
183
174
|
l = self.clone
|
184
175
|
l.from = to
|
185
176
|
l.from_orient = (to_orient == :+ ? :- : :+)
|
186
177
|
l.to = from
|
187
178
|
l.to_orient = (from_orient == :+ ? :- : :+)
|
188
|
-
l.overlap =
|
179
|
+
l.overlap = complement_overlap
|
189
180
|
l
|
190
181
|
end
|
191
182
|
|
192
|
-
#
|
183
|
+
# Complements the link inplace, i.e. sets:
|
193
184
|
# from = to
|
194
185
|
# from_orient = other_orient(to_orient)
|
195
186
|
# to = from
|
196
187
|
# to_orient = other_orient(from_orient)
|
197
|
-
# overlap =
|
188
|
+
# overlap = complement_overlap.
|
198
189
|
#
|
199
190
|
# The optional fields are left unchanged.
|
200
191
|
#
|
201
|
-
# @note The path references are not
|
192
|
+
# @note The path references are not complemented by this method; therefore
|
202
193
|
# the method shall be used before the link is embedded in a graph.
|
203
194
|
#
|
204
195
|
# @note This method shall be overridden if custom optional fields
|
205
|
-
# are defined, which have a ``
|
206
|
-
# their value in the
|
196
|
+
# are defined, which have a ``complementation'' operation which determines
|
197
|
+
# their value in the complement link.
|
207
198
|
#
|
208
199
|
# @return [RGFA::Line::Link] self
|
209
|
-
def
|
200
|
+
def complement!
|
210
201
|
tmp = self.from
|
211
202
|
self.from = self.to
|
212
203
|
self.to = tmp
|
213
204
|
tmp = self.from_orient
|
214
205
|
self.from_orient = (self.to_orient == :+) ? :- : :+
|
215
206
|
self.to_orient = (tmp == :+) ? :- : :+
|
216
|
-
self.overlap = self.
|
207
|
+
self.overlap = self.complement_overlap
|
217
208
|
return self
|
218
209
|
end
|
219
210
|
|
@@ -224,7 +215,7 @@ class RGFA::Line::Link < RGFA::Line
|
|
224
215
|
#
|
225
216
|
# Otherwise, an array of tuples path/boolean is returned.
|
226
217
|
# The boolean value tells
|
227
|
-
# if the link is used
|
218
|
+
# if the link is used (true) or its complement (false)
|
228
219
|
# in the path.
|
229
220
|
# @return [Array<Array<(RGFA::Line::Path, Boolean)>>]
|
230
221
|
def paths
|
@@ -235,8 +226,8 @@ class RGFA::Line::Link < RGFA::Line
|
|
235
226
|
# Compute the overlap when the strand of both sequences is inverted.
|
236
227
|
#
|
237
228
|
# @return [RGFA::CIGAR]
|
238
|
-
def
|
239
|
-
self.overlap.
|
229
|
+
def complement_overlap
|
230
|
+
self.overlap.to_cigar.complement
|
240
231
|
end
|
241
232
|
|
242
233
|
#
|
@@ -244,23 +235,23 @@ class RGFA::Line::Link < RGFA::Line
|
|
244
235
|
# Thereby, optional fields are not considered.
|
245
236
|
#
|
246
237
|
# @note Inverting the strand of both links and reversing
|
247
|
-
# the CIGAR operations (order/type), one obtains
|
248
|
-
#
|
238
|
+
# the CIGAR operations (order/type), one obtains an
|
239
|
+
# equivalent complement link.
|
249
240
|
#
|
250
241
|
# @param other [RGFA::Line::Link] a link
|
251
242
|
# @return [Boolean] are self and other equivalent?
|
252
243
|
# @see #==
|
253
244
|
# @see #same?
|
254
|
-
# @see #
|
245
|
+
# @see #complement?
|
255
246
|
def eql?(other)
|
256
|
-
same?(other) or
|
247
|
+
same?(other) or complement?(other)
|
257
248
|
end
|
258
249
|
|
259
250
|
# Compares the optional fields of two links.
|
260
251
|
#
|
261
252
|
# @note This method shall be overridden if custom optional fields
|
262
|
-
# are defined, which have a ``
|
263
|
-
# their value in the equivalent but
|
253
|
+
# are defined, which have a ``complementation'' operation which determines
|
254
|
+
# their value in the equivalent but complement link.
|
264
255
|
#
|
265
256
|
# @param other [RGFA::Line::Link] a link
|
266
257
|
# @return [Boolean] are self and other equivalent?
|
@@ -291,7 +282,7 @@ class RGFA::Line::Link < RGFA::Line
|
|
291
282
|
# @param other [RGFA::Line::Link] a link
|
292
283
|
# @return [Boolean] are self and other equivalent?
|
293
284
|
# @see #eql?
|
294
|
-
# @see #
|
285
|
+
# @see #complement?
|
295
286
|
# @see #==
|
296
287
|
def same?(other)
|
297
288
|
(from_end == other.from_end and
|
@@ -299,37 +290,37 @@ class RGFA::Line::Link < RGFA::Line
|
|
299
290
|
overlap == other.overlap)
|
300
291
|
end
|
301
292
|
|
302
|
-
# Compares the
|
293
|
+
# Compares the link to the complement of another link
|
303
294
|
# and determine their equivalence.
|
304
295
|
# Thereby, optional fields are not considered.
|
305
296
|
#
|
306
297
|
# @param other [RGFA::Line::Link] the other link
|
307
|
-
# @return [Boolean] are the
|
298
|
+
# @return [Boolean] are self and the complement of other equivalent?
|
308
299
|
# @see #eql?
|
309
300
|
# @see #same?
|
310
301
|
# @see #==
|
311
|
-
def
|
302
|
+
def complement?(other)
|
312
303
|
(from_end == other.to_end and
|
313
304
|
to_end == other.from_end and
|
314
|
-
overlap == other.
|
305
|
+
overlap == other.complement_overlap)
|
315
306
|
end
|
316
307
|
|
317
308
|
# Computes an hash for including a link in an Hash tables,
|
318
|
-
# so that the hash of a link and its
|
309
|
+
# so that the hash of a link and its complement is the same.
|
319
310
|
# Thereby, optional fields are not considered.
|
320
311
|
# @see #eql?
|
321
312
|
def hash
|
322
|
-
from_end.hash + to_end.hash + overlap.hash +
|
313
|
+
from_end.hash + to_end.hash + overlap.hash + complement_overlap.to_s.hash
|
323
314
|
end
|
324
315
|
|
325
|
-
# Compares a link and optionally the
|
316
|
+
# Compares a link and optionally the complement link,
|
326
317
|
# with two oriented_segments and optionally an overlap.
|
327
318
|
# @param [RGFA::OrientedSegment] other_oriented_from
|
328
319
|
# @param [RGFA::OrientedSegment] other_oriented_to
|
329
|
-
# @param equivalent [Boolean] shall the
|
320
|
+
# @param equivalent [Boolean] shall the complement link also be considered?
|
330
321
|
# @param [RGFA::CIGAR] other_overlap compared only if not empty
|
331
322
|
# @return [Boolean] does the link or, if +equivalent+,
|
332
|
-
# the
|
323
|
+
# the complement link go from the first
|
333
324
|
# oriented segment to the second with an overlap equal to the provided one
|
334
325
|
# (if not empty)?
|
335
326
|
def compatible?(other_oriented_from, other_oriented_to, other_overlap = [],
|
@@ -340,7 +331,7 @@ class RGFA::Line::Link < RGFA::Line
|
|
340
331
|
if is_direct
|
341
332
|
return true
|
342
333
|
elsif equivalent
|
343
|
-
return
|
334
|
+
return compatible_complement?(other_oriented_from, other_oriented_to,
|
344
335
|
other_overlap)
|
345
336
|
else
|
346
337
|
return false
|
@@ -361,15 +352,15 @@ class RGFA::Line::Link < RGFA::Line
|
|
361
352
|
(overlap.empty? or other_overlap.empty? or (overlap == other_overlap))
|
362
353
|
end
|
363
354
|
|
364
|
-
# Compares the
|
355
|
+
# Compares the complement link with two oriented segments and optionally an
|
365
356
|
# overlap.
|
366
357
|
# @param [RGFA::OrientedSegment] other_oriented_from
|
367
358
|
# @param [RGFA::OrientedSegment] other_oriented_to
|
368
359
|
# @param [RGFA::CIGAR] other_overlap compared only if not empty
|
369
|
-
# @return [Boolean] does the
|
360
|
+
# @return [Boolean] does the complement link go from the first
|
370
361
|
# oriented segment to the second with an overlap equal to the provided one
|
371
362
|
# (if not empty)?
|
372
|
-
def
|
363
|
+
def compatible_complement?(other_oriented_from, other_oriented_to,
|
373
364
|
other_overlap = [])
|
374
365
|
(oriented_to == other_oriented_from.invert_orient and
|
375
366
|
oriented_from == other_oriented_to.invert_orient) and
|
data/lib/rgfa/line/path.rb
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
class RGFA::Line::Path < RGFA::Line
|
3
3
|
|
4
4
|
RECORD_TYPE = :P
|
5
|
-
REQFIELDS = [:path_name, :segment_names, :
|
5
|
+
REQFIELDS = [:path_name, :segment_names, :overlaps]
|
6
6
|
PREDEFINED_OPTFIELDS = []
|
7
7
|
DATATYPE = {
|
8
8
|
:path_name => :lbl,
|
9
9
|
:segment_names => :lbs,
|
10
|
-
:
|
10
|
+
:overlaps => :cgs,
|
11
11
|
}
|
12
12
|
|
13
13
|
define_field_methods!
|
@@ -30,7 +30,7 @@ class RGFA::Line::Path < RGFA::Line
|
|
30
30
|
# equal to the number of segments.
|
31
31
|
# @return [Boolean]
|
32
32
|
def circular?
|
33
|
-
self.
|
33
|
+
self.overlaps.size == self.segment_names.size
|
34
34
|
end
|
35
35
|
|
36
36
|
# Is the path linear? This is the case when the number of CIGARs
|
@@ -40,11 +40,11 @@ class RGFA::Line::Path < RGFA::Line
|
|
40
40
|
!circular?
|
41
41
|
end
|
42
42
|
|
43
|
-
# Are the
|
43
|
+
# Are the overlaps a single "*"? This is a compact representation of
|
44
44
|
# a linear path where all CIGARs are "*"
|
45
45
|
# @return [Boolean]
|
46
|
-
def
|
47
|
-
self.
|
46
|
+
def undef_overlaps?
|
47
|
+
self.overlaps.size == 1 and self.overlaps[0].empty?
|
48
48
|
end
|
49
49
|
|
50
50
|
# The links to which the path refers; it can be an empty array
|
@@ -62,14 +62,14 @@ class RGFA::Line::Path < RGFA::Line
|
|
62
62
|
# an array, which elements are 3-tuples (from oriented segment,
|
63
63
|
# to oriented segment, cigar)
|
64
64
|
def required_links
|
65
|
-
|
65
|
+
has_undef_overlaps = self.undef_overlaps?
|
66
66
|
retval = []
|
67
67
|
self.segment_names.size.times do |i|
|
68
68
|
j = i+1
|
69
69
|
if j == self.segment_names.size
|
70
70
|
circular? ? j = 0 : break
|
71
71
|
end
|
72
|
-
cigar =
|
72
|
+
cigar = has_undef_overlaps ? [] : self.overlaps[i]
|
73
73
|
retval << [self.segment_names[i], self.segment_names[j], cigar]
|
74
74
|
end
|
75
75
|
retval
|
@@ -78,20 +78,20 @@ class RGFA::Line::Path < RGFA::Line
|
|
78
78
|
private
|
79
79
|
|
80
80
|
def validate_lists_size!
|
81
|
-
|
81
|
+
n_overlaps = self.overlaps.size
|
82
82
|
n_segments = self.segment_names.size
|
83
|
-
if
|
83
|
+
if n_overlaps == n_segments - 1
|
84
84
|
# case 1: linear path
|
85
85
|
return true
|
86
|
-
elsif
|
87
|
-
# case 2: linear path, single "*" to represent
|
86
|
+
elsif n_overlaps == 1 and self.overlaps[0].empty?
|
87
|
+
# case 2: linear path, single "*" to represent overlaps which are all "*"
|
88
88
|
return true
|
89
|
-
elsif
|
89
|
+
elsif n_overlaps == n_segments
|
90
90
|
# case 3: circular path
|
91
91
|
else
|
92
92
|
raise RGFA::Line::Path::ListLengthsError,
|
93
93
|
"Path has #{n_segments} oriented segments, "+
|
94
|
-
"but #{
|
94
|
+
"but #{n_overlaps} overlaps"
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -102,5 +102,5 @@ class RGFA::Line::Path < RGFA::Line
|
|
102
102
|
|
103
103
|
end
|
104
104
|
|
105
|
-
# Error raised if number of segments and
|
105
|
+
# Error raised if number of segments and overlaps are not consistent
|
106
106
|
class RGFA::Line::Path::ListLengthsError < RGFA::Error; end
|
data/lib/rgfa/lines.rb
CHANGED
@@ -28,6 +28,9 @@ module RGFA::Lines
|
|
28
28
|
add_containment(gfa_line)
|
29
29
|
when :P
|
30
30
|
add_path(gfa_line)
|
31
|
+
when :"#"
|
32
|
+
# do nothing, as the spec says these shall be ignored
|
33
|
+
# maybe we want to store them and output them again in a future version
|
31
34
|
else
|
32
35
|
raise # this never happens, as already catched by gfa_line init
|
33
36
|
end
|
data/lib/rgfa/links.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Giorgio Gonnella
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |2
|
14
14
|
The Graphical Fragment Assembly (GFA) is a proposed format which allow
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/rgfa/field_parser.rb
|
40
40
|
- lib/rgfa/field_validator.rb
|
41
41
|
- lib/rgfa/headers.rb
|
42
|
+
- lib/rgfa/line/comment.rb
|
42
43
|
- lib/rgfa/line/containment.rb
|
43
44
|
- lib/rgfa/line/header.rb
|
44
45
|
- lib/rgfa/line/link.rb
|
@@ -65,10 +66,10 @@ files:
|
|
65
66
|
- lib/rgfatools/superfluous_links.rb
|
66
67
|
- lib/rgfatools/linear_paths.rb
|
67
68
|
- lib/rgfatools/p_bubbles.rb
|
68
|
-
- bin/gfadiff
|
69
|
-
- bin/rgfa-mergelinear
|
70
|
-
- bin/rgfa-simdebruijn
|
71
|
-
- bin/rgfa-findcrisprs
|
69
|
+
- bin/gfadiff
|
70
|
+
- bin/rgfa-mergelinear
|
71
|
+
- bin/rgfa-simdebruijn
|
72
|
+
- bin/rgfa-findcrisprs
|
72
73
|
homepage: http://github.com/ggonnella/rgfa
|
73
74
|
licenses:
|
74
75
|
- CC-BY-SA
|