| 1 | #!/usr/bin/perl | ||
| 2 | # | ||
| 3 | # @File Predicate.pm | ||
| 4 | # @Author Andriy Mulyar | ||
| 5 | # @Created Jun 27, 2016 1:17:38 PM | ||
| 6 | # | ||
| 7 | |||
| 8 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | package Predicate; | ||
| 11 | |||
| 12 | #A predicate will be treated as an edge on the graph. This object takes 4 | ||
| 13 | # paramters | ||
| 14 | #Source CUI | ||
| 15 | #Predicate Type (ie. ISA, TREATS, CAUSES, etc) | ||
| 16 | #Destination CUI | ||
| 17 | #Edge Weight | ||
| 18 | # | ||
| 19 | sub new { | ||
| 20 | 0 | ▶ | my $class = shift; |
|
Subroutine
new: not called CC=1 SCAR=6.9
| |||
| 21 | 0 | my $self = { | |
| 22 | _source => shift, | ||
| 23 | _predicate => shift, | ||
| 24 | _destination => shift, | ||
| 25 | _weight => shift, | ||
| 26 | |||
| 27 | }; | ||
| 28 | 0 | bless $self, $class; | |
| 29 | 0 | return $self; | |
| 30 | } | ||
| 31 | |||
| 32 | #returns source vertex | ||
| 33 | sub getSource{ | ||
| 34 | return shift->{_source} | ||
| 35 | 0 | ▶ | } |
|
Subroutine
getSource: not called CC=1 SCAR=6.9
| |||
| 36 | |||
| 37 | #returns predicate name | ||
| 38 | sub getPredicate{ | ||
| 39 | 0 | ▶ | return shift->{_predicate}; |
|
Subroutine
getPredicate: not called CC=1 SCAR=6.9
| |||
| 40 | } | ||
| 41 | |||
| 42 | #returns destination vertex | ||
| 43 | sub getDestination{ | ||
| 44 | return shift->{_destination} | ||
| 45 | 0 | ▶ | } |
|
Subroutine
getDestination: not called CC=1 SCAR=6.9
| |||
| 46 | |||
| 47 | #returns weight associated with the edge | ||
| 48 | sub getWeight{ | ||
| 49 | 0 | ▶ | return shift->{_weight}; |
|
Subroutine
getWeight: not called CC=1 SCAR=6.9
| |||
| 50 | } | ||
| 51 | |||
| 52 | #test print | ||
| 53 | sub _print{ | ||
| 54 | 0 | ▶ | my $self = shift; |
|
Subroutine
_print: not called CC=1 SCAR=6.9
| |||
| 55 | 0 | print $self->{_source}->getPreferredName()." ". $self->{_predicate} ." ".$self->{_destination}->getPreferredName()." ".$self->{_weight}."\n"; | |
| 56 | #print "$self->{_source} $self->{_predicate} $self->{_destination}"; | ||
| 57 | } | ||
| 58 | 1 | 1; | |