applied LGPLv3 and source code formatting.
[vamsas.git] / src / uk / ac / vamsas / objects / utils / trees / SequenceNode.java
1 /*\r
2  * This file is part of the Vamsas Client version 0.1. \r
3  * Copyright 2009 by Jim Procter, Iain Milne, Pierre Marguerite, \r
4  *  Andrew Waterhouse and Dominik Lindner.\r
5  * \r
6  * Earlier versions have also been incorporated into Jalview version 2.4 \r
7  * since 2008, and TOPALi version 2 since 2007.\r
8  * \r
9  * The Vamsas Client is free software: you can redistribute it and/or modify\r
10  * it under the terms of the GNU Lesser General Public License as published by\r
11  * the Free Software Foundation, either version 3 of the License, or\r
12  * (at your option) any later version.\r
13  *  \r
14  * The Vamsas Client is distributed in the hope that it will be useful,\r
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  * GNU Lesser General Public License for more details.\r
18  * \r
19  * You should have received a copy of the GNU Lesser General Public License\r
20  * along with the Vamsas Client.  If not, see <http://www.gnu.org/licenses/>.\r
21  */\r
22 package uk.ac.vamsas.objects.utils.trees;\r
23 \r
24 import uk.ac.vamsas.client.Vobject;\r
25 import uk.ac.vamsas.client.VorbaId;\r
26 \r
27 public class SequenceNode extends BinaryNode {\r
28   /** DOCUMENT ME!! */\r
29   public float dist;\r
30 \r
31   /** DOCUMENT ME!! */\r
32   public boolean dummy = false;\r
33 \r
34   private boolean placeholder = false;\r
35 \r
36   /**\r
37    * Creates a new SequenceNode object.\r
38    */\r
39   public SequenceNode() {\r
40     super();\r
41   }\r
42 \r
43   /**\r
44    * Creates a new SequenceNode object.\r
45    * \r
46    * @param val\r
47    *          DOCUMENT ME!\r
48    * @param parent\r
49    *          DOCUMENT ME!\r
50    * @param dist\r
51    *          DOCUMENT ME!\r
52    * @param name\r
53    *          DOCUMENT ME!\r
54    */\r
55   public SequenceNode(Vobject val, SequenceNode parent, float dist, String name) {\r
56     super(val, parent, name);\r
57     this.dist = dist;\r
58   }\r
59 \r
60   /**\r
61    * Creates a new SequenceNode object.\r
62    * \r
63    * @param val\r
64    *          DOCUMENT ME!\r
65    * @param parent\r
66    *          DOCUMENT ME!\r
67    * @param name\r
68    *          DOCUMENT ME!\r
69    * @param dist\r
70    *          DOCUMENT ME!\r
71    * @param bootstrap\r
72    *          DOCUMENT ME!\r
73    * @param dummy\r
74    *          DOCUMENT ME!\r
75    */\r
76   public SequenceNode(Vobject val, SequenceNode parent, String name,\r
77       float dist, int bootstrap, boolean dummy) {\r
78     super(val, parent, name);\r
79     this.dist = dist;\r
80     this.bootstrap = bootstrap;\r
81     this.dummy = dummy;\r
82   }\r
83 \r
84   /**\r
85    * @param dummy\r
86    *          true if node is created for the representation of polytomous trees\r
87    */\r
88   public boolean isDummy() {\r
89     return dummy;\r
90   }\r
91 \r
92   /*\r
93    * @param placeholder is true if the sequence referred to in the element node\r
94    * is not actually present in the associated alignment\r
95    */\r
96   public boolean isPlaceholder() {\r
97     return placeholder;\r
98   }\r
99 \r
100   /**\r
101    * DOCUMENT ME!\r
102    * \r
103    * @param newstate\r
104    *          DOCUMENT ME!\r
105    * \r
106    * @return DOCUMENT ME!\r
107    */\r
108   public boolean setDummy(boolean newstate) {\r
109     boolean oldstate = dummy;\r
110     dummy = newstate;\r
111 \r
112     return oldstate;\r
113   }\r
114 \r
115   /**\r
116    * DOCUMENT ME!\r
117    * \r
118    * @param Placeholder\r
119    *          DOCUMENT ME!\r
120    */\r
121   public void setPlaceholder(boolean Placeholder) {\r
122     this.placeholder = Placeholder;\r
123   }\r
124 \r
125   /**\r
126    * ascends the tree but doesn't stop until a non-dummy node is discovered.\r
127    * This will probably break if the tree is a mixture of BinaryNodes and\r
128    * SequenceNodes.\r
129    */\r
130   public SequenceNode AscendTree() {\r
131     SequenceNode c = this;\r
132 \r
133     do {\r
134       c = (SequenceNode) c.parent();\r
135     } while ((c != null) && c.dummy);\r
136 \r
137     return c;\r
138   }\r
139 \r
140 }\r