3b26b4717e544850b5de990de4798ba08841a679
[jalview.git] / src2 / fr / orsay / lri / varna / models / treealign / RNANodeValue.java
1 package fr.orsay.lri.varna.models.treealign;
2
3 /**
4  * We use the following convention: If the node is marked by a couple (n,m)
5  * these integers are stored in leftBasePosition and rightBasePosition
6  * (ie. we have a pair of bases), if only
7  * one value is present, it is stored in leftBasePosition and rightBasePosition
8  * contains -1 (ie. we have a non-paired base).
9  * The right and left nucleotides follow the same rule, but are optional,
10  * and '_' is used as undefined instead of -1.
11  * Note that it is part of the contract of this class that default
12  * values are -1 and _.
13  * 
14  * @author Raphael Champeimont
15  */
16 public class RNANodeValue implements GraphvizDrawableNodeValue {
17         private int leftBasePosition = -1;
18         private int rightBasePosition = -1;
19         
20         private String leftNucleotide = "_";
21         private String rightNucleotide = "_";
22         
23         public enum Origin {
24                 BASE_PAIR_FROM_HELIX,
25                 BASE_FROM_HELIX_STRAND5,
26                 BASE_FROM_HELIX_STRAND3,
27                 BASE_FROM_UNPAIRED_REGION;
28         }
29         
30         /**
31          * Used to store the origin of this base / base pair.
32          */
33         private Origin origin = null;
34         
35         public Origin getOrigin() {
36                 return origin;
37         }
38         public void setOrigin(Origin comesFromAnHelix) {
39                 this.origin = comesFromAnHelix;
40         }
41         
42         
43         
44         public String getLeftNucleotide() {
45                 return leftNucleotide;
46         }
47         public void setLeftNucleotide(String leftNucleotide) {
48                 this.leftNucleotide = leftNucleotide;
49         }
50         public String getRightNucleotide() {
51                 return rightNucleotide;
52         }
53         public void setRightNucleotide(String rightNucleotide) {
54                 this.rightNucleotide = rightNucleotide;
55         }
56         public int getLeftBasePosition() {
57                 return leftBasePosition;
58         }
59         public void setLeftBasePosition(int leftBasePosition) {
60                 this.leftBasePosition = leftBasePosition;
61         }
62         public int getRightBasePosition() {
63                 return rightBasePosition;
64         }
65         public void setRightBasePosition(int rightBasePosition) {
66                 this.rightBasePosition = rightBasePosition;
67         }
68         
69         public String toGraphvizNodeName() {
70                 if (rightNucleotide.equals("_")) {
71                         if (leftNucleotide.equals("_")) {
72                                 if (rightBasePosition == -1) {
73                                         if (leftBasePosition == -1) {
74                                                 return super.toString();
75                                         } else {
76                                                 return Integer.toString(leftBasePosition);
77                                         }
78                                 } else {
79                                         return "(" + leftBasePosition + "," + rightBasePosition + ")";
80                                 }
81                         } else {
82                                 return leftNucleotide;
83                         }
84                 } else {
85                         return "(" + leftNucleotide + "," + rightNucleotide + ")";
86                 }
87         }
88         
89         public String toString() {
90                 if (rightBasePosition == -1) {
91                         if (leftBasePosition == -1) {
92                                 return super.toString();
93                         } else {
94                                 return Integer.toString(leftBasePosition);
95                         }
96                 } else {
97                         return "(" + leftBasePosition + "," + rightBasePosition + ")";
98                 }
99         }
100         
101
102 }