| 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.bss; |
| 27 |
|
| 28 |
import java.io.Serializable; |
| 29 |
|
| 30 |
import dr.evolution.tree.Tree; |
| 31 |
import dr.evolution.util.Taxa; |
| 32 |
|
| 33 |
@SuppressWarnings("serial") |
| 34 |
public class TreesTableRecord implements Serializable { |
| 35 |
|
| 36 |
private String name = ""; |
| 37 |
private Taxa taxa = null; |
| 38 |
private Tree tree = null; |
| 39 |
|
| 40 |
private boolean treeSet = false; |
| 41 |
private boolean taxaSet = false; |
| 42 |
|
| 43 |
public TreesTableRecord() { |
| 44 |
} |
| 45 |
|
| 46 |
public TreesTableRecord(String name, Tree tree) { |
| 47 |
this.name = name; |
| 48 |
this.tree = tree; |
| 49 |
|
| 50 |
treeSet = true; |
| 51 |
applyTreeName(); |
| 52 |
} |
| 53 |
|
| 54 |
public TreesTableRecord(String name, Taxa taxa) { |
| 55 |
this.name = name; |
| 56 |
this.taxa = taxa; |
| 57 |
|
| 58 |
taxaSet = true; |
| 59 |
applyTaxaName(); |
| 60 |
} |
| 61 |
|
| 62 |
private void applyTaxaName() { |
| 63 |
|
| 64 |
if (taxaSet && name != null) { |
| 65 |
|
| 66 |
for (int i = 0; i < taxa.getTaxonCount(); i++) { |
| 67 |
taxa.setTaxonAttribute(i, Utils.TREE_FILENAME, name); |
| 68 |
} |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
private void applyTreeName() { |
| 73 |
|
| 74 |
if (treeSet && name != null) { |
| 75 |
|
| 76 |
for (int i = 0; i < tree.getTaxonCount(); i++) { |
| 77 |
tree.getTaxon(i).setAttribute(Utils.TREE_FILENAME, name); |
| 78 |
} |
| 79 |
} |
| 80 |
} |
| 81 |
|
| 82 |
public int getTaxaCount() { |
| 83 |
|
| 84 |
int taxaCount = 0; |
| 85 |
|
| 86 |
if (taxaSet) { |
| 87 |
|
| 88 |
taxaCount = taxa.getTaxonCount(); |
| 89 |
|
| 90 |
} else if (treeSet) { |
| 91 |
|
| 92 |
taxaCount = tree.getTaxonCount(); |
| 93 |
|
| 94 |
} else { |
| 95 |
|
| 96 |
} |
| 97 |
|
| 98 |
return taxaCount; |
| 99 |
} |
| 100 |
|
| 101 |
public String getName() { |
| 102 |
return name; |
| 103 |
} |
| 104 |
|
| 105 |
public Tree getTree() { |
| 106 |
return tree; |
| 107 |
} |
| 108 |
|
| 109 |
public Taxa getTaxa() { |
| 110 |
return taxa; |
| 111 |
} |
| 112 |
|
| 113 |
public String toString() { |
| 114 |
return getName(); |
| 115 |
} |
| 116 |
|
| 117 |
public boolean isTreeSet() { |
| 118 |
return this.treeSet; |
| 119 |
} |
| 120 |
|
| 121 |
public boolean isTaxaSet() { |
| 122 |
return this.taxaSet; |
| 123 |
} |
| 124 |
|
| 125 |
} |