| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|