Class: Bio::Velvet::Underground::Graph
- Inherits:
-
Object
- Object
- Bio::Velvet::Underground::Graph
- Defined in:
- lib/bio-velvet_underground/graph.rb
Defined Under Namespace
Classes: ArcArray, Node, NodeArray, NodedRead
Instance Attribute Summary collapse
-
#internal_graph_struct ⇒ Object
Returns the value of attribute internal_graph_struct.
Class Method Summary collapse
-
.parse_from_file(path) ⇒ Object
Read in a graph from a file.
Instance Method Summary collapse
- #hash_length ⇒ Object
-
#initialize(graph_struct) ⇒ Graph
constructor
Use parse_from_file, not #new.
- #node_count ⇒ Object
- #nodes ⇒ Object
Constructor Details
#initialize(graph_struct) ⇒ Graph
Use parse_from_file, not #new
10 11 12 |
# File 'lib/bio-velvet_underground/graph.rb', line 10 def initialize(graph_struct) @internal_graph_struct = graph_struct end |
Instance Attribute Details
#internal_graph_struct ⇒ Object
Returns the value of attribute internal_graph_struct.
7 8 9 |
# File 'lib/bio-velvet_underground/graph.rb', line 7 def internal_graph_struct @internal_graph_struct end |
Class Method Details
.parse_from_file(path) ⇒ Object
Read in a graph from a file
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bio-velvet_underground/graph.rb', line 15 def self.parse_from_file(path) # First read the first line of the file to determine which underground velvet library to load hash_length = nil CSV.foreach(path, :col_sep => "\t") do |row| raise "Badly formatted graph file" if row.length < 3 hash_length = row[2].to_i if hash_length < 1 or hash_length > Bio::Velvet::Underground.max_kmers.max raise "unable to load velvet shared library for kmer length `#{hash_length}'" end break end raise "No lines in graph file `#{path}', is it really a velvet LastGraph-type file?" if hash_length.nil? # setup FFI in the underground base class with the correct kmer length Bio::Velvet::Underground.attach_shared_library(:kmer => hash_length) # Using the loaded velvet library, do the actual import of the graph pointer = Bio::Velvet::Underground.importGraph path struct = Bio::Velvet::Underground::GraphStruct.new pointer Graph.new struct end |
Instance Method Details
#hash_length ⇒ Object
45 46 47 |
# File 'lib/bio-velvet_underground/graph.rb', line 45 def hash_length @internal_graph_struct[:wordLength] end |
#node_count ⇒ Object
41 42 43 |
# File 'lib/bio-velvet_underground/graph.rb', line 41 def node_count @internal_graph_struct[:nodeCount] end |