Class: RGFA::Line::Path

Inherits:
RGFA::Line show all
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

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.

Returns:

  • (Boolean)


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 “*”.

Returns:

  • (Boolean)


39
40
41
# File 'lib/rgfa/line/path.rb', line 39

def linear?
  !circular?
end

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.

Returns:



54
55
56
57
# File 'lib/rgfa/line/path.rb', line 54

def links
  @links ||= []
  @links
end

computes the list of links which are required to support the path

Returns:



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_symSymbol

Returns name of the path as symbol.

Returns:

  • (Symbol)

    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 “*”

Returns:

  • (Boolean)


46
47
48
# File 'lib/rgfa/line/path.rb', line 46

def undef_overlaps?
  self.overlaps.size == 1 and self.overlaps[0].empty?
end