Debian Codegraph @

src/dr/app/bss/test/AncestralSequenceTrait.java

raw symbols SCIP
1 /*
2 * AncestralSequenceTrait.java
3 *
4 * Copyright (c) 2002-2015 Alexei Drummond, Andrew Rambaut and Marc Suchard
5 *
6 * This file is part of BEAST.
7 * See the NOTICE file distributed with this work for additional
8 * information regarding copyright ownership and licensing.
9 *
10 * BEAST is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU Lesser General Public License as
12 * published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
14 *
15 * BEAST is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with BEAST; if not, write to the
22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23 * Boston, MA 02110-1301 USA
24 */
25
26 package dr.app.bss.test;
27
28 import java.util.LinkedHashMap;
29
30 import dr.app.beagle.tools.BeagleSequenceSimulator;
31 import dr.app.bss.Utils;
32 import dr.evolution.datatype.DataType;
33 import dr.evolution.tree.NodeRef;
34 import dr.evolution.tree.Tree;
35 import dr.evolution.tree.TreeTrait;
36 import dr.evolution.tree.TreeTraitProvider;
37 import dr.evolution.util.Taxon;
38
39 public class AncestralSequenceTrait implements TreeTraitProvider {
40
41 public static String ANCESTRAL_SEQUENCE = "ancestralSequence";
42 private Helper helper;
43
44 public AncestralSequenceTrait(
45 final LinkedHashMap<NodeRef, int[]> sequenceMap,
46 final DataType dataType) {
47
48 helper = new Helper();
49
50 TreeTrait<String> nodeSequence = new TreeTrait.S() {
51
52 @Override
53 public String getTraitName() {
54 return ANCESTRAL_SEQUENCE;
55 }// END: getTraitName
56
57 @Override
58 public String getTrait(Tree tree, NodeRef node) {
59
60 int[] intSequence = sequenceMap.get(node);
61
62 // System.out.println(intSequence.length);
63 // Utils.printArray(intSequence);
64
65 // System.exit(-1);
66
67 //TODO: null pointer
68 String sequence = "AAA";
69 // Utils.intArray2Sequence(new Taxon("fake"), //
70 // intSequence, //
71 // BeagleSequenceSimulator.gapFlag, //
72 // dataType).getSequenceString();
73
74 return sequence;
75 }// END: getTrait
76
77 @Override
78 public Intent getIntent() {
79 return Intent.NODE;
80 }
81
82 };
83
84 helper.addTrait(nodeSequence);
85
86 }// END: Constructor
87
88 @Override
89 public TreeTrait[] getTreeTraits() {
90
91 return helper.getTreeTraits();
92 }// END: getTreeTraits
93
94 @Override
95 public TreeTrait getTreeTrait(String key) {
96
97 return helper.getTreeTrait(key);
98 }// END: getTreeTrait
99
100 }// END: class