Class: Bio::Velvet::Graph::Arc

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#begin_node_directionObject

true for forwards direction, false for reverse



490
491
492
# File 'lib/bio-velvet/graph.rb', line 490

def begin_node_direction
  @begin_node_direction
end

#begin_node_idObject

Returns the value of attribute begin_node_id.



487
488
489
# File 'lib/bio-velvet/graph.rb', line 487

def begin_node_id
  @begin_node_id
end

#end_node_directionObject

true for forwards direction, false for reverse



490
491
492
# File 'lib/bio-velvet/graph.rb', line 490

def end_node_direction
  @end_node_direction
end

#end_node_idObject

Returns the value of attribute end_node_id.



487
488
489
# File 'lib/bio-velvet/graph.rb', line 487

def end_node_id
  @end_node_id
end

#multiplicityObject

Returns the value of attribute multiplicity.



487
488
489
# File 'lib/bio-velvet/graph.rb', line 487

def multiplicity
  @multiplicity
end

Instance Method Details

#begin_node_forward?Boolean

Returns:

  • (Boolean)


503
504
505
# File 'lib/bio-velvet/graph.rb', line 503

def begin_node_forward?
  @begin_node_direction
end

#connects_beginning_to_beginning?(first_node_id, second_node_id) ⇒ Boolean

Returns true if this arc connects the start of the first node to the start of the second node, else false

Returns:

  • (Boolean)


534
535
536
537
538
539
# File 'lib/bio-velvet/graph.rb', line 534

def connects_beginning_to_beginning?(first_node_id, second_node_id)
  (first_node_id == @begin_node_id and second_node_id == @end_node_id and
    @begin_node_direction == false and @end_node_direction == true) or
    (first_node_id == @end_node_id and second_node_id = @begin_node_id and
    @begin_node_direction == false and @end_node_direction == true)
end

#connects_beginning_to_end?(first_node_id, second_node_id) ⇒ Boolean

Returns true if this arc connects the start of the first node to the start of the second node, else false

Returns:

  • (Boolean)


543
544
545
546
547
548
# File 'lib/bio-velvet/graph.rb', line 543

def connects_beginning_to_end?(first_node_id, second_node_id)
  (first_node_id == @begin_node_id and second_node_id == @end_node_id and
    @begin_node_direction == false and @end_node_direction == false) or
    (first_node_id == @end_node_id and second_node_id = @begin_node_id and
    @begin_node_direction == true and @end_node_direction == true)
end

#connects_end_to_beginning?(first_node_id, second_node_id) ⇒ Boolean

Returns true if this arc connects the end of the first node to the start of the second node, else false

Returns:

  • (Boolean)


513
514
515
516
517
518
519
520
521
# File 'lib/bio-velvet/graph.rb', line 513

def connects_end_to_beginning?(first_node_id, second_node_id)
  # ARC $START_NODE $END_NODE $MULTIPLICITY
  #Note: this one line implicitly represents an arc from node A to B and
  #another, with same multiplicity, from -B to -A.
  (first_node_id == @begin_node_id and second_node_id == @end_node_id and
    @begin_node_direction == true and @end_node_direction == true) or
    (first_node_id == @end_node_id and second_node_id = @begin_node_id and
    @begin_node_direction == false and @end_node_direction == false)
end

#connects_end_to_end?(first_node_id, second_node_id) ⇒ Boolean

Returns true if this arc connects the end of the first node to the end of the second node, else false

Returns:

  • (Boolean)


525
526
527
528
529
530
# File 'lib/bio-velvet/graph.rb', line 525

def connects_end_to_end?(first_node_id, second_node_id)
  (first_node_id == @begin_node_id and second_node_id == @end_node_id and
    @begin_node_direction == true and @end_node_direction == false) or
    (first_node_id == @end_node_id and second_node_id = @begin_node_id and
    @begin_node_direction == true and @end_node_direction == false)
end

#connects_to_beginning?(node_id) ⇒ Boolean

Return true if this arc connects the beginning of the node, else false

Returns:

  • (Boolean)


552
553
554
555
# File 'lib/bio-velvet/graph.rb', line 552

def connects_to_beginning?(node_id)
  (node_id == @begin_node_id and !@begin_node_direction) or
  (node_id == @end_node_id and @end_node_direction)
end

#connects_to_end?(node_id) ⇒ Boolean

Return true if this arc connects the end of the node, else false

Returns:

  • (Boolean)


559
560
561
562
# File 'lib/bio-velvet/graph.rb', line 559

def connects_to_end?(node_id)
  (node_id == @begin_node_id and @begin_node_direction) or
  (node_id == @end_node_id and !@end_node_direction)
end

#directions_opposing?Boolean

Returns:

  • (Boolean)


492
493
494
495
496
497
498
499
500
501
# File 'lib/bio-velvet/graph.rb', line 492

def directions_opposing?
  if (@begin_node_direction == true and @end_node_direction == false) or
    (@begin_node_direction == false and @end_node_direction == true)
    return true
  elsif [true,false].include?(@begin_node_direction) and [true,false].include?(@end_node_direction)
    return false
  else
    raise Exception, "Node directions not set! Cannot tell whether directions are opposing"
  end
end

#end_node_forward?Boolean

Returns:

  • (Boolean)


507
508
509
# File 'lib/bio-velvet/graph.rb', line 507

def end_node_forward?
  @end_node_forward
end

#to_sObject



564
565
566
567
568
569
570
571
572
573
574
# File 'lib/bio-velvet/graph.rb', line 564

def to_s
  str = ''
  str += '-' if @begin_node_direction == false
  str += @begin_node_id.to_s
  str += ' '
  str += '-' if @end_node_direction == false
  str += @end_node_id.to_s
  str += ' '
  str += @multiplicity.to_s
  str
end