Class: Bio::Velvet::Graph::Arc
- Inherits:
-
Object
- Object
- Bio::Velvet::Graph::Arc
- Defined in:
- lib/bio-velvet/graph.rb
Instance Attribute Summary collapse
-
#begin_node_direction ⇒ Object
true for forwards direction, false for reverse.
-
#begin_node_id ⇒ Object
Returns the value of attribute begin_node_id.
-
#end_node_direction ⇒ Object
true for forwards direction, false for reverse.
-
#end_node_id ⇒ Object
Returns the value of attribute end_node_id.
-
#multiplicity ⇒ Object
Returns the value of attribute multiplicity.
Instance Method Summary collapse
- #begin_node_forward? ⇒ Boolean
-
#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.
-
#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.
-
#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.
-
#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.
-
#connects_to_beginning?(node_id) ⇒ Boolean
Return true if this arc connects the beginning of the node, else false.
-
#connects_to_end?(node_id) ⇒ Boolean
Return true if this arc connects the end of the node, else false.
- #directions_opposing? ⇒ Boolean
- #end_node_forward? ⇒ Boolean
- #to_s ⇒ Object
Instance Attribute Details
#begin_node_direction ⇒ Object
true for forwards direction, false for reverse
480 481 482 |
# File 'lib/bio-velvet/graph.rb', line 480 def begin_node_direction @begin_node_direction end |
#begin_node_id ⇒ Object
Returns the value of attribute begin_node_id.
477 478 479 |
# File 'lib/bio-velvet/graph.rb', line 477 def begin_node_id @begin_node_id end |
#end_node_direction ⇒ Object
true for forwards direction, false for reverse
480 481 482 |
# File 'lib/bio-velvet/graph.rb', line 480 def end_node_direction @end_node_direction end |
#end_node_id ⇒ Object
Returns the value of attribute end_node_id.
477 478 479 |
# File 'lib/bio-velvet/graph.rb', line 477 def end_node_id @end_node_id end |
#multiplicity ⇒ Object
Returns the value of attribute multiplicity.
477 478 479 |
# File 'lib/bio-velvet/graph.rb', line 477 def multiplicity @multiplicity end |
Instance Method Details
#begin_node_forward? ⇒ Boolean
493 494 495 |
# File 'lib/bio-velvet/graph.rb', line 493 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
524 525 526 527 528 529 |
# File 'lib/bio-velvet/graph.rb', line 524 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
533 534 535 536 537 538 |
# File 'lib/bio-velvet/graph.rb', line 533 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
503 504 505 506 507 508 509 510 511 |
# File 'lib/bio-velvet/graph.rb', line 503 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
515 516 517 518 519 520 |
# File 'lib/bio-velvet/graph.rb', line 515 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
542 543 544 545 |
# File 'lib/bio-velvet/graph.rb', line 542 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
549 550 551 552 |
# File 'lib/bio-velvet/graph.rb', line 549 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
482 483 484 485 486 487 488 489 490 491 |
# File 'lib/bio-velvet/graph.rb', line 482 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
497 498 499 |
# File 'lib/bio-velvet/graph.rb', line 497 def end_node_forward? @end_node_forward end |
#to_s ⇒ Object
554 555 556 557 558 559 560 561 562 563 564 |
# File 'lib/bio-velvet/graph.rb', line 554 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 |