Module: RGFA::Paths

Included in:
RGFA
Defined in:
lib/rgfa/paths.rb

Overview

Methods for the RGFA class, which allow to handle paths in the graph.

Instance Method Summary collapse

Instance Method Details

#delete_path(pt) ⇒ RGFA

Delete a path from the RGFA graph

Parameters:

Returns:



57
58
59
60
61
62
63
# File 'lib/rgfa/paths.rb', line 57

def delete_path(pt)
  pt = path!(pt)
  pt.segment_names.each {|sn, o| segment!(sn).paths[o].delete(pt)}
  pt.links.each {|l, dir| l.paths.delete([pt, dir])}
  @paths.delete(pt.path_name)
  return self
end

#path(pt) ⇒ RGFA::Line::Path?

Searches the path with name equal to pt.

Parameters:

Returns:

  • (RGFA::Line::Path)

    if a path is found

  • (nil)

    if no such path exists in the RGFA instance



77
78
79
80
# File 'lib/rgfa/paths.rb', line 77

def path(pt)
  return pt if pt.kind_of?(RGFA::Line)
  @paths[pt.to_sym]
end

#path!(pt) ⇒ RGFA::Line::Path

Searches the path with name equal to pt.

Parameters:

Returns:

Raises:



84
85
86
87
88
# File 'lib/rgfa/paths.rb', line 84

def path!(pt)
  pt = path(pt)
  raise RGFA::LineMissingError, "No path has name #{pt}" if pt.nil?
  pt
end

#pathsArray<RGFA::Line::Path>

All path lines of the graph

Returns:



67
68
69
# File 'lib/rgfa/paths.rb', line 67

def paths
  @paths.values
end

#paths_with(s) ⇒ Array<RGFA::Line::Path>

Returns paths whose segment_names include the specified segment.

Parameters:

Returns:



94
95
96
# File 'lib/rgfa/paths.rb', line 94

def paths_with(s)
  segment!(s).all_paths
end