Changeset 1579 for branches/ralph/src
- Timestamp:
- 06/25/14 22:02:05 (10 years ago)
- Location:
- branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees
- Files:
-
- 10 deleted
- 7 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/misc/Identifier.java
r1573 r1579 8 8 package de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc; 9 9 10 import java.io.Serializable;11 10 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.util.Comparable; 12 11 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/FengDoolittleNode.java
r1577 r1579 14 14 import de.ugoe.cs.autoquest.tasktrees.alignment.algorithms.NumberSequence; 15 15 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 16 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.LabelMapping;17 16 18 17 … … 89 88 } 90 89 91 public FengDoolittleNode(Node n, boolean keepIds) {92 init(n, keepIds);93 for (int i = 0; i < n.getChildCount(); i++) {94 addChild(new FengDoolittleNode(n.getChild(i), keepIds));95 }96 }97 98 public FengDoolittleNode(Node n, LabelMapping lm) {99 init(n, true, lm);100 for (int i = 0; i < n.getChildCount(); i++) {101 addChild(new FengDoolittleNode(n.getChild(i), lm));102 }103 }104 105 106 /** constructor used to clone a node and all children */107 public FengDoolittleNode(Node n)108 {109 this(n, true);110 }111 112 113 114 protected void init(Node n) {115 init(n, true);116 }117 /**118 * Initialized node instance variables based on given Node.119 * children are ignored.120 */121 protected void init(Node n, boolean keepId) {122 init(n,keepId,null);123 }124 /**125 * Initialized node instance variables based on given Node.126 * children are ignored.127 * @param lm - may be null128 */129 protected void init(Node n, boolean keepId, LabelMapping lm) {130 parent = null;131 length = n.getBranchLength();132 lengthSE = n.getBranchLengthSE();133 height = n.getNodeHeight();134 if (keepId) {135 if(lm!=null) {136 identifier = lm.getLabelIdentifier(n.getIdentifier());137 } else {138 identifier = n.getIdentifier();139 }140 } else { identifier = Identifier.ANONYMOUS; }141 142 number = n.getNumber();143 sequences = n.getSequences();144 child = null;145 }146 90 147 91 /** -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/NodeFactory.java
r1573 r1579 31 31 return new FengDoolittleNode(); 32 32 } 33 34 /** constructor used to clone a node and all children */35 public static Node createNode(Node node)36 {37 return new FengDoolittleNode(node);38 }39 33 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/NodeUtils.java
r1573 r1579 12 12 13 13 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.io.FormattedOutput; 14 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.BranchLimits;15 14 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 16 15 … … 119 118 } 120 119 121 /** 122 * determines branch lengths of this and all descendent nodes 123 * from heights 124 */ 125 public static void heights2Lengths(Node node) { 126 heights2Lengths(node, true); //respect minimum 127 } 128 129 /** 130 * determines branch lengths of this and all descendent nodes 131 * from heights 132 */ 133 public static void heights2Lengths(Node node, boolean respectMinimum) { 134 135 for (int i = 0; i < node.getChildCount(); i++) { 136 heights2Lengths(node.getChild(i)); 137 } 138 139 if (node.isRoot()) { 140 node.setBranchLength(0.0); 141 } 142 else { 143 node.setBranchLength(node.getParent().getNodeHeight() - node.getNodeHeight()); 144 if (respectMinimum && (node.getBranchLength() < BranchLimits.MINARC)) 145 { 146 node.setBranchLength(BranchLimits.MINARC); 147 } 148 } 149 } 150 151 /** 152 * determines branch lengths of this node and its immediate descendent nodes 153 * from heights. 154 */ 155 public static void localHeights2Lengths(Node node, boolean respectMinimum) { 156 157 for (int i = 0; i < node.getChildCount(); i++) { 158 Node child = node.getChild(i); 159 160 child.setBranchLength(node.getNodeHeight() - child.getNodeHeight()); 161 } 162 163 if (node.isRoot()) { 164 node.setBranchLength(0.0); 165 } 166 else { 167 node.setBranchLength(node.getParent().getNodeHeight() - node.getNodeHeight()); 168 if (respectMinimum && (node.getBranchLength() < BranchLimits.MINARC)) 169 { 170 node.setBranchLength(BranchLimits.MINARC); 171 } 172 } 173 } 120 174 121 175 122 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/SimpleTree.java
r1573 r1579 10 10 11 11 import java.io.PrintWriter; 12 import java.io.Serializable;13 12 import java.io.StringWriter; 14 import java.util.Hashtable; 13 15 14 16 15 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.Identifier; 17 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.misc.LabelMapping; 16 18 17 19 18 … … 56 55 private int numExternalNodes; 57 56 58 /** attributes attached to this tree. */59 private Hashtable[] attributes = null;60 61 62 63 57 /** constructor tree consisting solely of root node */ 64 58 public SimpleTree() { … … 77 71 createNodeList(); 78 72 } 79 80 /** clone constructor */81 public SimpleTree(Tree tree)82 {83 root = new FengDoolittleNode(tree.getRoot());84 createNodeList();85 }86 87 /** clone constructor */88 public SimpleTree(Tree tree, boolean keepIdentifiers)89 {90 root = new FengDoolittleNode(tree.getRoot(), keepIdentifiers);91 createNodeList();92 }93 /**94 * clone constructor95 * @param lm - a label mapping use for translating the original label names into something else96 */97 public SimpleTree(Tree tree, LabelMapping lm)98 {99 root = new FengDoolittleNode(tree.getRoot(), lm);100 createNodeList();101 }102 103 73 104 74 … … 225 195 } 226 196 227 private int getIndex(Node node) { 228 if (node.isLeaf()) return node.getNumber(); 229 return getExternalNodeCount() + node.getNumber(); 230 } 231 232 /** 233 * Sets an named attribute for a given node. 234 * @param node the node whose attribute is being set. 235 * @param name the name of the attribute. 236 * @param value the new value of the attribute. 237 */ 238 public void setAttribute(Node node, String name, Object value) { 239 if (node instanceof AttributeNode) { 240 ((AttributeNode)node).setAttribute(name, value); 241 } else { 242 int index = getIndex(node); 243 if (attributes == null) { 244 attributes = new Hashtable[getExternalNodeCount() + getInternalNodeCount()]; 245 } 246 if (attributes[index] == null) { 247 attributes[index] = new Hashtable(); 248 } 249 attributes[index].put(name, value); 250 } 251 } 197 198 252 199 253 200 public String toString() { … … 258 205 } 259 206 260 /**261 * @return an object representing the named attributed for the numbered node.262 * @param node the node being interrogated.263 * @param name the name of the attribute of interest.264 */265 public Object getAttribute(Node node, String name) {266 if (node instanceof AttributeNode) {267 return ((AttributeNode)node).getAttribute(name);268 } else {269 int index = getIndex(node);270 if (attributes == null || attributes[index] == null) {271 return null;272 }273 return attributes[index].get(name);274 }275 }276 207 277 208 -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/Tree.java
r1573 r1579 59 59 void createNodeList(); 60 60 61 /**62 * Sets an named attribute for a given node.63 * @param node the node whose attribute is being set.64 * @param name the name of the attribute.65 * @param value the new value of the attribute.66 */67 void setAttribute(Node node, String name, Object value);68 61 69 /**70 * @return an object representing the named attributed for the numbered node.71 * @param node the node being interrogated.72 * @param name the name of the attribute of interest.73 */74 Object getAttribute(Node node, String name);75 62 } -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/alignment/pal/tree/UPGMAAligningTree.java
r1578 r1579 29 29 * @author Alexei Drummond 30 30 */ 31 public class UPGMA Tree extends SimpleTree31 public class UPGMAAligningTree extends SimpleTree 32 32 { 33 33 // … … 41 41 * @param m distance matrix 42 42 */ 43 public UPGMA Tree(ArrayList<NumberSequence> numberseqs, UPGMAMatrix m)43 public UPGMAAligningTree(ArrayList<NumberSequence> numberseqs, UPGMAMatrix m) 44 44 { 45 45 if (m.size() < 2) -
branches/ralph/src/main/java/de/ugoe/cs/autoquest/tasktrees/temporalrelation/SequenceForTaskDetectionRuleAlignment.java
r1578 r1579 31 31 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.ObjectDistanceSubstitionMatrix; 32 32 import de.ugoe.cs.autoquest.tasktrees.alignment.matrix.UPGMAMatrix; 33 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.tree.UPGMA Tree;33 import de.ugoe.cs.autoquest.tasktrees.alignment.pal.tree.UPGMAAligningTree; 34 34 import de.ugoe.cs.autoquest.tasktrees.taskequality.TaskEquality; 35 35 import de.ugoe.cs.autoquest.tasktrees.treeifc.IIteration; … … 207 207 } 208 208 //System.out.println(sequenceDistances.toString()); 209 UPGMA Tree guidetree = new UPGMATree(numberseqs, sequenceDistances);209 UPGMAAligningTree guidetree = new UPGMAAligningTree(numberseqs, sequenceDistances); 210 210 211 211
Note: See TracChangeset
for help on using the changeset viewer.