Class: Bio::Velvet::Underground::Graph::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/bio-velvet_underground/graph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(graph, node_struct) ⇒ Node

Returns a new instance of Node.



77
78
79
80
# File 'lib/bio-velvet_underground/graph.rb', line 77

def initialize(graph, node_struct)
  @graph = graph
  @internal_node_struct = node_struct
end

Instance Attribute Details

#internal_node_structObject

Returns the value of attribute internal_node_struct.



75
76
77
# File 'lib/bio-velvet_underground/graph.rb', line 75

def internal_node_struct
  @internal_node_struct
end

Instance Method Details

#coveragesObject



90
91
92
93
94
95
# File 'lib/bio-velvet_underground/graph.rb', line 90

def coverages
  [
    @internal_node_struct[:virtualCoverage1],
    @internal_node_struct[:virtualCoverage2],
    ]
end

#ends_of_kmers_of_nodeObject



97
98
99
100
101
102
103
104
105
# File 'lib/bio-velvet_underground/graph.rb', line 97

def ends_of_kmers_of_node
  seq = []
  key = %w(A C G T)
  0.upto(length_alone-1) do |i|
    n = Bio::Velvet::Underground.getNucleotideInNode(@internal_node_struct, i)
    seq.push key[n]
  end
  return seq.join
end

#ends_of_kmers_of_twin_nodeObject



107
108
109
# File 'lib/bio-velvet_underground/graph.rb', line 107

def ends_of_kmers_of_twin_node
  twin.ends_of_kmers_of_node
end

#fwd_short_readsObject



121
122
123
124
125
126
127
128
129
130
# File 'lib/bio-velvet_underground/graph.rb', line 121

def fwd_short_reads
  array_start_pointer = Bio::Velvet::Underground.getNodeReads @internal_node_struct, @graph.internal_graph_struct
  num_short_reads = Bio::Velvet::Underground.getNodeReadCount @internal_node_struct, @graph.internal_graph_struct
  short_reads = (0...num_short_reads).collect do |i|
    # Use the fact that FFI pointers can do pointer arithmetic
    pointer = array_start_pointer+(i*Bio::Velvet::Underground::ShortReadMarker.size)
    NodedRead.new Bio::Velvet::Underground::ShortReadMarker.new(pointer), true
  end
  return short_reads
end

#length_aloneObject



86
87
88
# File 'lib/bio-velvet_underground/graph.rb', line 86

def length_alone
  @internal_node_struct[:length]
end

#node_idObject



82
83
84
# File 'lib/bio-velvet_underground/graph.rb', line 82

def node_id
  @internal_node_struct[:ID]
end

#rev_short_readsObject



132
133
134
# File 'lib/bio-velvet_underground/graph.rb', line 132

def rev_short_reads
  twin.fwd_short_reads
end

#short_readsObject



136
137
138
139
140
141
142
143
# File 'lib/bio-velvet_underground/graph.rb', line 136

def short_reads
  reads = fwd_short_reads
  rev_short_reads.each do |read|
    read.direction = false
    reads.push read
  end
  return reads
end

#twinObject



111
112
113
114
115
116
117
118
119
# File 'lib/bio-velvet_underground/graph.rb', line 111

def twin
  return @twin unless @twin.nil?

  twin_pointer = Bio::Velvet::Underground.getTwinNode(@internal_node_struct)
  @twin = Bio::Velvet::Underground::Graph::Node.new(
    @graph,
    Bio::Velvet::Underground::NodeStruct.new(twin_pointer)
    )
end