| 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.beauti.options; |
| 27 |
|
| 28 |
import dr.evolution.alignment.Patterns; |
| 29 |
import dr.evolution.datatype.DataType; |
| 30 |
import dr.evolution.distance.DistanceMatrix; |
| 31 |
import dr.evolution.distance.JukesCantorDistanceMatrix; |
| 32 |
import dr.evolution.util.TaxonList; |
| 33 |
|
| 34 |
import java.io.Serializable; |
| 35 |
import java.util.List; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public abstract class AbstractPartitionData implements Serializable { |
| 43 |
|
| 44 |
protected String fileName; |
| 45 |
protected String name; |
| 46 |
protected List<TraitData> traits; |
| 47 |
|
| 48 |
protected BeautiOptions options; |
| 49 |
protected PartitionSubstitutionModel model; |
| 50 |
protected PartitionClockModel clockModel; |
| 51 |
protected PartitionTreeModel treeModel; |
| 52 |
|
| 53 |
protected double meanDistance; |
| 54 |
|
| 55 |
protected DistanceMatrix distances; |
| 56 |
|
| 57 |
public AbstractPartitionData(BeautiOptions options, String name, String fileName) { |
| 58 |
this.options = options; |
| 59 |
this.name = name; |
| 60 |
this.fileName = fileName; |
| 61 |
} |
| 62 |
|
| 63 |
protected void calculateMeanDistance(Patterns patterns) { |
| 64 |
if (patterns != null) { |
| 65 |
distances = new JukesCantorDistanceMatrix(patterns); |
| 66 |
meanDistance = distances.getMeanDistance(); |
| 67 |
} else { |
| 68 |
distances = null; |
| 69 |
meanDistance = 1.0; |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
public String getFileName() { |
| 74 |
return fileName; |
| 75 |
} |
| 76 |
|
| 77 |
public String getName() { |
| 78 |
return name; |
| 79 |
} |
| 80 |
|
| 81 |
public void setName(String name) { |
| 82 |
this.name = name; |
| 83 |
} |
| 84 |
|
| 85 |
public String toString() { |
| 86 |
return getName(); |
| 87 |
} |
| 88 |
|
| 89 |
public List<TraitData> getTraits() { |
| 90 |
return traits; |
| 91 |
} |
| 92 |
|
| 93 |
public double getMeanDistance() { |
| 94 |
return meanDistance; |
| 95 |
} |
| 96 |
|
| 97 |
public DistanceMatrix getDistances() { |
| 98 |
return distances; |
| 99 |
} |
| 100 |
|
| 101 |
public void setPartitionSubstitutionModel(PartitionSubstitutionModel model) { |
| 102 |
options.clearDataPartitionCaches(); |
| 103 |
this.model = model; |
| 104 |
} |
| 105 |
|
| 106 |
public PartitionSubstitutionModel getPartitionSubstitutionModel() { |
| 107 |
return this.model; |
| 108 |
} |
| 109 |
|
| 110 |
public void setPartitionClockModel(PartitionClockModel clockModel) { |
| 111 |
options.clearDataPartitionCaches(); |
| 112 |
this.clockModel = clockModel; |
| 113 |
} |
| 114 |
|
| 115 |
public PartitionClockModel getPartitionClockModel() { |
| 116 |
return clockModel; |
| 117 |
} |
| 118 |
|
| 119 |
public PartitionTreeModel getPartitionTreeModel() { |
| 120 |
return treeModel; |
| 121 |
} |
| 122 |
|
| 123 |
public void setPartitionTreeModel(PartitionTreeModel treeModel) { |
| 124 |
options.clearDataPartitionCaches(); |
| 125 |
this.treeModel = treeModel; |
| 126 |
} |
| 127 |
|
| 128 |
public int getTaxonCount() { |
| 129 |
return getPartitionTreeModel().getTaxonCount(); |
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
} |
| 136 |
|
| 137 |
public boolean isCreatedFromTrait() { |
| 138 |
return traits != null; |
| 139 |
} |
| 140 |
|
| 141 |
public abstract String getPrefix(); |
| 142 |
|
| 143 |
public abstract TaxonList getTaxonList(); |
| 144 |
|
| 145 |
public abstract int getSiteCount(); |
| 146 |
|
| 147 |
public abstract DataType getDataType(); |
| 148 |
|
| 149 |
public abstract String getDataDescription(); |
| 150 |
|
| 151 |
} |