Debian Codegraph @

src/dr/app/treestat/TreeStatData.java

raw symbols SCIP
1 /*
2 * TreeStatData.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.treestat;
27
28 import dr.app.treestat.statistics.SummaryStatisticDescription;
29 import org.jdom.Document;
30 import org.jdom.Element;
31
32 import java.util.ArrayList;
33 import java.util.HashSet;
34 import java.util.List;
35 import java.util.Set;
36
37 public class TreeStatData {
38 public static final String version = "1.0";
39
40 public TreeStatData() {
41 }
42
43 // Data options
44 public Set<String> allTaxa = new HashSet<String>();
45 public List<TaxonSet> taxonSets = new ArrayList<TaxonSet>();
46 public List<Character> characters = new ArrayList<Character>();
47 public List<SummaryStatisticDescription> statistics = new ArrayList<SummaryStatisticDescription>();
48
49 public static class TaxonSet {
50 String name;
51 List taxa;
52 public String toString() { return name; }
53 }
54
55 public static class Character {
56 String name;
57 List<TreeStatData.State> states;
58 public String toString() { return name; }
59 }
60
61 public static class State {
62 String name;
63 String description;
64 List<String> taxa;
65 public String toString() { return name; }
66 }
67
68 /**
69 * Read options from a file
70 */
71 public Document create() {
72
73 Element root = new Element("treeTracer");
74 root.setAttribute("version", version);
75
76 Element taxonSetsElement = new Element("taxonSets");
77 Element charactersElement = new Element("characters");
78 Element statisticsElement = new Element("statistics");
79
80 root.addContent(taxonSetsElement);
81 root.addContent(charactersElement);
82 root.addContent(statisticsElement);
83
84 return new Document(root);
85 }
86
87 /**
88 * Read options from a file
89 */
90 public void parse(Document document) throws dr.xml.XMLParseException {
91
92 Element root = document.getRootElement();
93 if (!root.getName().equals("treeTracer")) {
94 throw new dr.xml.XMLParseException("This document does not appear to be a TreeTracer file");
95 }
96 }
97 }
98