Class: RGFA::Line::Path
- Inherits:
-
RGFA::Line
- Object
- RGFA::Line
- RGFA::Line::Path
- Defined in:
- lib/rgfa/line/path.rb
Overview
A path line of a RGFA file
Defined Under Namespace
Classes: ListLengthsError
Constant Summary collapse
- RECORD_TYPE =
:P
- REQFIELDS =
[:path_name, :segment_names, :overlaps]
- PREDEFINED_OPTFIELDS =
[]
- DATATYPE =
{ :path_name => :lbl, :segment_names => :lbs, :overlaps => :cgs, }
Constants inherited from RGFA::Line
DELAYED_PARSING_DATATYPES, DIRECTION, FIELD_DATATYPE, OPTFIELD_DATATYPE, ORIENTATION, RECORD_TYPES, RECORD_TYPE_LABELS, REQFIELD_DATATYPE, SEPARATOR
Instance Method Summary collapse
-
#circular? ⇒ Boolean
Is the path circular? In this case the number of CIGARs must be equal to the number of segments.
-
#linear? ⇒ Boolean
Is the path linear? This is the case when the number of CIGARs is equal to the number of segments minus 1, or the CIGARs are represented by a single “*”.
-
#links ⇒ Array<RGFA::Line::Link, Boolean>
The links to which the path refers; it can be an empty array (e.g. from a line which is not embedded in a graph); the boolean is true if the equivalent reverse link is used.
-
#required_links ⇒ Array<[RGFA::OrientedSegment, RGFA::OrientedSegment, RGFA::Cigar]>
computes the list of links which are required to support the path.
-
#to_sym ⇒ Symbol
Name of the path as symbol.
-
#undef_overlaps? ⇒ Boolean
Are the overlaps a single “*”? This is a compact representation of a linear path where all CIGARs are “*”.
Methods inherited from RGFA::Line
#==, #clone, #delete, #field_to_s, #fieldnames, #get, #get!, #get_datatype, #initialize, #method_missing, #optional_fieldnames, #real!, #record_type, #required_fieldnames, #respond_to?, #set, #set_datatype, subclass, #tags, #to_a, #to_rgfa_line, #to_s, #validate!, #validate_field!, #virtual?
Constructor Details
This class inherits a constructor from RGFA::Line
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class RGFA::Line
Instance Method Details
#circular? ⇒ Boolean
Is the path circular? In this case the number of CIGARs must be equal to the number of segments.
32 33 34 |
# File 'lib/rgfa/line/path.rb', line 32 def circular? self.overlaps.size == self.segment_names.size end |
#linear? ⇒ Boolean
Is the path linear? This is the case when the number of CIGARs is equal to the number of segments minus 1, or the CIGARs are represented by a single “*”.
39 40 41 |
# File 'lib/rgfa/line/path.rb', line 39 def linear? !circular? end |
#links ⇒ Array<RGFA::Line::Link, Boolean>
The links to which the path refers; it can be an empty array (e.g. from a line which is not embedded in a graph); the boolean is true if the equivalent reverse link is used.
54 55 56 57 |
# File 'lib/rgfa/line/path.rb', line 54 def links @links ||= [] @links end |
#required_links ⇒ Array<[RGFA::OrientedSegment, RGFA::OrientedSegment, RGFA::Cigar]>
computes the list of links which are required to support the path
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rgfa/line/path.rb', line 64 def required_links has_undef_overlaps = self.undef_overlaps? retval = [] self.segment_names.size.times do |i| j = i+1 if j == self.segment_names.size circular? ? j = 0 : break end cigar = has_undef_overlaps ? [] : self.overlaps[i] retval << [self.segment_names[i], self.segment_names[j], cigar] end retval end |
#to_sym ⇒ Symbol
Returns name of the path as symbol.
25 26 27 |
# File 'lib/rgfa/line/path.rb', line 25 def to_sym name.to_sym end |
#undef_overlaps? ⇒ Boolean
Are the overlaps a single “*”? This is a compact representation of a linear path where all CIGARs are “*”
46 47 48 |
# File 'lib/rgfa/line/path.rb', line 46 def undef_overlaps? self.overlaps.size == 1 and self.overlaps[0].empty? end |