@@ -31,16 +31,14 @@ public class Edge {
3131 ArrayList <String > componentIDs ;
3232
3333 ArrayList <String > componentRoles ;
34-
35- String orientation ;
34+
35+ Orientation orientation ;
3636
3737 double weight ;
3838
3939 private static final Logger LOG = LoggerFactory .getLogger (Edge .class );
4040
41- public Edge () {
42-
43- }
41+ public Edge () {}
4442
4543 public Edge (Node tail , Node head ) {
4644 this .tail = tail ;
@@ -51,13 +49,13 @@ public Edge(Node tail, Node head) {
5149
5250 componentRoles = new ArrayList <String >();
5351
54- orientation = Orientation .NONE . getValue () ;
52+ orientation = Orientation .NONE ;
5553
5654 weight = 1.0 ;
5755 }
5856
5957 public Edge (Node tail , Node head , ArrayList <String > componentIDs ,
60- ArrayList <String > componentRoles ) {
58+ ArrayList <String > componentRoles ) {
6159 this .tail = tail ;
6260
6361 this .head = head ;
@@ -67,16 +65,16 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
6765 this .componentRoles = componentRoles ;
6866
6967 if (!this .componentIDs .isEmpty () || !this .componentRoles .isEmpty ()) {
70- orientation = Orientation .INLINE . getValue () ;
68+ orientation = Orientation .INLINE ;
7169 } else {
72- orientation = Orientation .NONE . getValue () ;
70+ orientation = Orientation .NONE ;
7371 }
7472
7573 weight = 1.0 ;
7674 }
7775
7876 public Edge (Node tail , Node head , ArrayList <String > componentIDs ,
79- ArrayList <String > componentRoles , String orientation ) {
77+ ArrayList <String > componentRoles , Orientation orientation ) {
8078 this .tail = tail ;
8179
8280 this .head = head ;
@@ -88,14 +86,14 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
8886 if (!this .componentIDs .isEmpty () || !this .componentRoles .isEmpty ()) {
8987 this .orientation = orientation ;
9088 } else {
91- this .orientation = Orientation .NONE . getValue () ;
89+ this .orientation = Orientation .NONE ;
9290 }
9391
9492 weight = 1.0 ;
9593 }
9694
9795 public Edge (Node tail , Node head , ArrayList <String > componentIDs ,
98- ArrayList <String > componentRoles , String orientation , double weight ) {
96+ ArrayList <String > componentRoles , Orientation orientation , double weight ) {
9997 this .tail = tail ;
10098
10199 this .head = head ;
@@ -107,40 +105,40 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
107105 if (!this .componentIDs .isEmpty () || !this .componentRoles .isEmpty ()) {
108106 this .orientation = orientation ;
109107 } else {
110- this .orientation = Orientation .NONE . getValue () ;
108+ this .orientation = Orientation .NONE ;
111109 }
112110
113111 this .weight = weight ;
114112 }
115113
116- public Edge (ArrayList <String > componentIDs , ArrayList <String > componentRoles , String orientation ,
117- double weight ) {
114+ public Edge (ArrayList <String > componentIDs , ArrayList <String > componentRoles ,
115+ Orientation orientation , double weight ) {
118116 this .componentIDs = componentIDs ;
119117
120118 this .componentRoles = componentRoles ;
121119
122120 if (!this .componentIDs .isEmpty () || !this .componentRoles .isEmpty ()) {
123121 this .orientation = orientation ;
124122 } else {
125- this .orientation = Orientation .NONE . getValue () ;
123+ this .orientation = Orientation .NONE ;
126124 }
127125
128126 this .weight = weight ;
129127 }
130128
131129 public Edge copy () {
132130 return new Edge (new ArrayList <String >(componentIDs ),
133- new ArrayList <String >(componentRoles ), orientation , weight );
131+ new ArrayList <>(componentRoles ), orientation , weight );
134132 }
135133
136134 public Edge copy (Node head ) {
137135 return new Edge (tail , head , new ArrayList <String >(componentIDs ),
138- new ArrayList <String >(componentRoles ), orientation , weight );
136+ new ArrayList <>(componentRoles ), orientation , weight );
139137 }
140138
141139 public Edge copy (Node tail , Node head ) {
142140 return new Edge (tail , head , new ArrayList <String >(componentIDs ),
143- new ArrayList <String >(componentRoles ), orientation , weight );
141+ new ArrayList <>(componentRoles ), orientation , weight );
144142 }
145143
146144 public void delete () {
@@ -335,14 +333,6 @@ public boolean hasComponentRoles() {
335333 return componentRoles != null && !componentRoles .isEmpty ();
336334 }
337335
338- public boolean hasOrientation () {
339- return isInline () || isReverseComplement ();
340- }
341-
342- public boolean hasOrientation (String orientation ) {
343- return hasOrientation () && this .orientation .equals (orientation );
344- }
345-
346336 public void intersectWithEdge (Edge edge , int tolerance ) {
347337 // Map other component IDs to roles and other component roles to IDs
348338
@@ -503,14 +493,6 @@ public boolean hasSharedComponentRoles(Edge edge, Set<String> roles) {
503493 }
504494 }
505495
506- public boolean isInline () {
507- return orientation .equals (Orientation .INLINE .getValue ());
508- }
509-
510- public boolean isReverseComplement () {
511- return orientation .equals (Orientation .REVERSE_COMPLEMENT .getValue ());
512- }
513-
514496 public boolean isBlank () {
515497 return !hasComponentIDs () && !hasComponentRoles () && !hasOrientation ();
516498 }
@@ -526,10 +508,6 @@ public void setHead(Node head) {
526508 public void setTail (Node tail ) {
527509 this .tail = tail ;
528510 }
529-
530- public String getOrientation () {
531- return orientation ;
532- }
533511
534512 public void setWeight (double weight ) {
535513 this .weight = weight ;
@@ -547,20 +525,56 @@ public String toString() {
547525 }
548526
549527 }
550-
528+
551529 public enum Orientation {
552530 INLINE ("inline" ),
553531 REVERSE_COMPLEMENT ("reverseComplement" ),
532+ UNDECLARED ("undeclared" ), //means it can be inline or reverse
554533 NONE ("none" );
555534
556535 private final String value ;
557-
558- Orientation (String value ) {
536+
537+ Orientation (String value ) {
559538 this .value = value ;
560539 }
561540
562541 public String getValue () {
563- return value ;
542+ return value ;
543+ }
544+ }
545+
546+ public Orientation getOrientation () {
547+ return orientation ;
548+ }
549+
550+ public void setOrientation (Orientation orientation ){
551+ this .orientation = orientation ;
552+ }
553+
554+ public boolean hasOrientation () {
555+ return isInline () || isReverseComplement ();
556+ }
557+
558+
559+ public boolean hasOrientation (Orientation orientation ) {
560+ return hasOrientation () && this .orientation .equals (orientation );
561+ }
562+
563+ public boolean isInline () {
564+ return orientation .equals (Orientation .INLINE );
565+ }
566+
567+ public boolean isReverseComplement () {
568+ return orientation .equals (Orientation .REVERSE_COMPLEMENT );
569+ }
570+
571+ public void reverseOrientation (){
572+ if (isInline ()){
573+ setOrientation (Orientation .REVERSE_COMPLEMENT );
574+ }
575+
576+ else if (isReverseComplement ()){
577+ setOrientation (Orientation .INLINE );
564578 }
565579 }
566580}
0 commit comments