1 package fr.orsay.lri.varna.models.treealign;
2 import java.util.ArrayList;
8 * In this model, nodes are either:
9 * 1. a couple of paired bases, and in that case they may have children,
10 * in this case singleNode is true
11 * 2. a single base that comes from a broken base pair
12 * (broken during planarization), without children,
13 * in this case singleNode is true
14 * 3. a list of consecutive non-paired bases, without children.
15 * in this case singleNode is false
16 * Note that case 2 happens only if original sequences contained
17 * pseudoknots, otherwise this case can be ignored.
19 * @author Raphael Champeimont
22 public class RNANodeValue2 implements GraphvizDrawableNodeValue {
24 * Says whether we have a single node or a list of nodes.
26 private boolean singleNode = true;
29 * Defined if singleNode is true.
31 private RNANodeValue node;
34 * Defined if singleNode is false;
36 private List<RNANodeValue> nodes;
38 public RNANodeValue2(boolean singleNode) {
39 this.singleNode = singleNode;
41 node = new RNANodeValue();
43 nodes = new ArrayList<RNANodeValue>();
48 * In case of a single node, return it.
49 * Will throw RNANodeValue2WrongTypeException if singleNode = false.
51 public RNANodeValue getNode() {
55 throw (new RNANodeValue2WrongTypeException());
59 public void setNode(RNANodeValue node) {
63 throw (new RNANodeValue2WrongTypeException());
68 * In case of multiple nodes, return them.
69 * Will throw RNANodeValue2WrongTypeException if singleNode = true.
71 public List<RNANodeValue> getNodes() {
75 throw (new RNANodeValue2WrongTypeException());
79 * In case of multiple nodes, return the sequence of nucleotides.
81 public char[] computeSequence() {
83 final int n = nodes.size();
84 char[] sequence = new char[n];
85 for (int i=0; i<n; i++) {
86 sequence[i] = nodes.get(i).getLeftNucleotide().charAt(0);
90 throw (new RNANodeValue2WrongTypeException());
94 public void setNodes(List<RNANodeValue> nodes) {
98 throw (new RNANodeValue2WrongTypeException());
102 public boolean isSingleNode() {
106 public String toString() {
108 return node.toString();
111 for (RNANodeValue node: nodes) {
115 s += node.toString();
121 public String toGraphvizNodeName() {
123 return node.toGraphvizNodeName();
126 for (RNANodeValue node: nodes) {
130 s += node.toGraphvizNodeName();