Debian Codegraph @

src/dr/app/beauti/options/AbstractPartitionData.java

raw symbols SCIP
1 /*
2 * AbstractPartitionData.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.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 * @author Alexei Drummond
39 * @author Andrew Rambaut
40 * @author Walter Xie
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 // if (getTaxonList() != null) {
131 // return getTaxonList().getTaxonCount();
132 // } else {
133 // return getPartitionTreeModel().getTaxonCount();
134 // }
135 }
136
137 public boolean isCreatedFromTrait() {
138 return traits != null;
139 }
140
141 public abstract String getPrefix(); // be careful of microsatellite PartitionPattern
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 }