Debian Codegraph @

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

raw symbols SCIP
1 /*
2 * BeautiOptions.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 java.util.*;
29
30 import dr.app.beauti.components.ComponentFactory;
31 import dr.app.beauti.components.ancestralstates.AncestralStatesComponentOptions;
32 import dr.app.beauti.components.continuous.ContinuousComponentOptions;
33 import dr.app.beauti.components.discrete.DiscreteTraitsComponentOptions;
34 import dr.app.beauti.mcmcpanel.MCMCPanel;
35 import dr.app.beauti.types.OperatorSetType;
36 import dr.app.beauti.types.TreePriorType;
37 import dr.evolution.alignment.Alignment;
38 import dr.evolution.alignment.Patterns;
39 import dr.evolution.datatype.DataType;
40 import dr.evolution.datatype.Microsatellite;
41 import dr.evolution.tree.Tree;
42 import dr.evolution.util.Date;
43 import dr.evolution.util.Taxa;
44 import dr.evolution.util.Taxon;
45 import dr.evolution.util.TaxonList;
46 import dr.evolution.util.Units;
47 import dr.evoxml.util.DateUnitsType;
48 import dr.inference.operators.OperatorSchedule;
49
50 /**
51 * @author Andrew Rambaut
52 * @author Alexei Drummond
53 * @author Walter Xie
54 */
55 public class BeautiOptions extends ModelOptions {
56
57 // Switches to a dirichlet prior & delta exchange on nus
58 private static final boolean NEW_RELATIVE_RATE_PARAMETERIZATION = true;
59
60 // Switches to a dirichlet prior & delta exchange on relative rates
61 private static final boolean NEW_GTR_PARAMETERIZATION = true;
62
63 // Makes sets the initial state of PartitionClockModel.continuousQuantile
64 public static final boolean DEFAULT_QUANTILE_RELAXED_CLOCK = false;
65
66 // Uses a logit transformed random walk on pInv parameters
67 private static final boolean LOGIT_PINV_KERNEL = true;
68
69 // Switches to a dirichlet prior & delta exchange on state frequencies
70 private static final boolean FREQUENCIES_DIRICHLET_PRIOR = true;
71
72 private static final long serialVersionUID = -3676802825545741012L;
73
74 public BeautiOptions() {
75 this(new ComponentFactory[]{});
76 }
77
78 public BeautiOptions(ComponentFactory[] components) {
79
80 // Install all the component's options from the given list of factories:
81 registerComponents(components);
82 }
83
84 /**
85 * This will register the list of components if not already there...
86 * @param components
87 */
88 public void registerComponents(ComponentFactory[] components) {
89
90 // Install all the component's options from the given list of factories:
91 for (ComponentFactory component : components) {
92 if (!hasComponent(component)) {
93 addComponent(component.createOptions(this));
94 }
95 }
96 }
97
98
99 /**
100 *
101 * resets the options to the initial conditions
102 */
103 public void reset() {
104 // Data options
105 taxonList = null;
106 taxonSets.clear();
107 taxonSetsMono.clear();
108 taxonSetsIncludeStem.clear();
109 taxonSetsTreeModel.clear();
110
111 // meanDistance = 1.0;
112 datesUnits = DateUnitsType.YEARS;
113 datesDirection = DateUnitsType.FORWARDS;
114 maximumTipHeight = 0.0;
115 translation = 0;
116
117 dataPartitions.clear();
118 traits.clear();
119 // partitionModels.clear();
120 // partitionTreeModels.clear();
121 // partitionTreePriors.clear();
122 // partitionClockTreeLinks.clear();
123 // activedSameTreePrior = null;
124 // shareSameTreePrior = true;
125 userTrees.clear();
126
127 // rateOptionClockModel = FixRateType.FIX_FIRST_PARTITION;
128 // meanSubstitutionRate = 1.0;
129 unlinkPartitionRates = true;
130
131 units = Units.Type.SUBSTITUTIONS;
132
133 // Operator schedule options
134 optimizationTransform = OperatorSchedule.OptimizationTransform.DEFAULT;
135
136 // MCMC options
137 chainLength = 10000000;
138 logEvery = 1000;
139 echoEvery = 1000;
140 burnIn = 100000;
141 fileName = null;
142 autoOptimize = true;
143 performTraceAnalysis = false;
144 generateCSV = true; // until/if a button
145 samplePriorOnly = false;
146
147 fileNameStem = MCMCPanel.DEFAULT_FILE_NAME_STEM;
148 logFileName = null;
149 allowOverwriteLog = false;
150 // mapTreeLog = false;
151 // mapTreeFileName = null;
152 treeFileName.clear();
153 substTreeLog = false;
154 substTreeFileName.clear();
155 operatorAnalysis = false;
156 operatorAnalysisFileName = null;
157
158 globalModelOptions = new GlobalModelOptions(this);
159 clockModelOptions = new ClockModelOptions(this);
160 treeModelOptions = new TreeModelOptions(this);
161 // priorOptions = new PriorOptions(this);
162
163 // traitsOptions = new TraitsOptions(this);
164
165 microsatelliteOptions = new MicrosatelliteOptions(this);
166
167 parameters.clear();
168 operators.clear();
169 statistics.clear();
170
171 shareMicroSat = true;
172
173 clearDataPartitionCaches();
174 }
175
176 public void selectTaxonSetsStatistics(List<Parameter> params) {
177
178 if (taxonSets != null) {
179 for (Taxa taxa : taxonSets) {
180 params.add(updateTMRCAStatistic(taxa));
181 }
182 } else {
183 System.err.println("TaxonSets are null");
184 }
185 }
186
187 public Parameter updateTMRCAStatistic(Taxa taxa) {
188 Parameter statistic = statistics.get(taxa);
189 PartitionTreeModel treeModel = taxonSetsTreeModel.get(taxa);
190 if (statistic == null) {
191 // default scaleType = PriorScaleType.NONE; priorType = PriorType.NONE_TREE_PRIOR
192 statistic = new Parameter.Builder(taxa.getId(), "tmrca statistic for taxon set")
193 .isStatistic(true).isNodeHeight(true)
194 .partitionOptions(treeModel).initial(Double.NaN).isNonNegative(true).build();
195 statistic.setPrefix(treeModel.getPrefix());
196 statistic.taxaId = taxa.getId();
197
198 statistics.put(taxa, statistic);
199
200 } else {
201 statistic.setOptions(treeModel); // keep consistent to taxonSetsTreeModel
202 statistic.setPrefix(treeModel.getPrefix()); // keep prefix consistent after link/unlink tree
203 PartitionTreePrior treePrior = treeModel.getPartitionTreePrior();
204 statistic.isCalibratedYule = treePrior.getNodeHeightPrior() == TreePriorType.YULE_CALIBRATION
205 && taxonSetsMono.get(taxa);
206 statistic.taxaId = taxa.getId();
207 }
208 return statistic;
209 }
210
211 public boolean renameTMRCAStatistic(Taxa taxonSet) {
212 Parameter statistic = statistics.get(taxonSet);
213 if (statistic != null) {
214 PartitionTreeModel treeModel = taxonSetsTreeModel.get(taxonSet);
215 statistic.taxaId = treeModel.getPrefix() + taxonSet.getId();
216 return true;
217 } else {
218 return false;
219 }
220 }
221
222 @Override
223 public void initModelParametersAndOpererators() {
224
225 }
226
227 public List<Parameter> selectParameters() {
228 return selectParameters(new ArrayList<Parameter>());
229 }
230
231
232 /**
233 * return an list of parameters that are required
234 *
235 * @return the parameter list
236 */
237 @Override
238 public List<Parameter> selectParameters(List<Parameter> parameters) {
239
240 globalModelOptions.selectParameters(parameters);
241
242 selectTaxonSetsStatistics(parameters); // have to be before clockModelOptions.selectParameters(parameters);
243
244 for (PartitionSubstitutionModel model : getPartitionSubstitutionModels()) {
245 // parameters.addAll(model.getParameters(multiplePartitions));
246 model.selectParameters(parameters);
247 }
248
249 for (PartitionClockModel model : getPartitionClockModels()) {
250 Set<PartitionSubstitutionModel> substitutionModels = new LinkedHashSet<PartitionSubstitutionModel>();
251 for (AbstractPartitionData partition : getDataPartitions()) {
252 if (partition.getPartitionClockModel() == model) {
253 substitutionModels.add(partition.getPartitionSubstitutionModel());
254 }
255 }
256
257 // collect all the relative rate paremeters (partition rates and codon position rates)
258 ArrayList<Parameter> relativeRateParameters = new ArrayList<Parameter>();
259 for (PartitionSubstitutionModel substitutionModel : substitutionModels) {
260 relativeRateParameters.addAll(substitutionModel.getRelativeRateParameters());
261 }
262 Parameter allMuNus = model.getParameter(useNuRelativeRates() ? "allNus" : "allMus" );
263 allMuNus.clearSubParameters();
264 if (relativeRateParameters.size() > 1) {
265
266 int totalWeight = 0;
267 for (Parameter mu : relativeRateParameters) {
268 allMuNus.addSubParameter(mu);
269 totalWeight += mu.getDimensionWeight();
270 }
271 parameters.add(allMuNus);
272
273 // add the total weight of all mus/nus to the allMus parameter
274 allMuNus.setDimensionWeight(totalWeight);
275 allMuNus.maintainedSum = (useNuRelativeRates() ? 1.0 : relativeRateParameters.size());
276 allMuNus.isMaintainedSum = true;
277 }
278
279 model.selectParameters(parameters);
280 }
281 clockModelOptions.selectParameters(parameters);
282
283 for (PartitionTreeModel tree : getPartitionTreeModels()) {
284 tree.selectParameters(parameters);
285 }
286 treeModelOptions.selectParameters(parameters);
287
288 for (PartitionTreePrior prior : getPartitionTreePriors()) {
289 prior.selectParameters(parameters);
290 }
291
292 if (contains(Microsatellite.INSTANCE)) {
293 microsatelliteOptions.selectParameters(parameters);
294 }
295
296 // for (TraitData trait : getTraitsList()) { // all traits including locations
297 // if (!trait.getName().equalsIgnoreCase(TraitData.Traits.TRAIT_SPECIES.toString()))
298 // trait.gets.selectParameters(parameters);
299 // }
300
301 selectComponentParameters(this, parameters);
302
303 selectComponentStatistics(this, parameters);
304
305 // priorOptions.selectParameters(parameters);
306
307 return parameters;
308 }
309
310 /**
311 * return an list of operators that are required
312 *
313 * @return the operator list
314 */
315 public List<Operator> selectOperators() {
316 return selectOperators(new ArrayList<Operator>());
317 }
318
319 @Override
320 public List<Operator> selectOperators(List<Operator> ops) {
321 globalModelOptions.selectOperators(ops);
322
323 for (PartitionSubstitutionModel model : getPartitionSubstitutionModels()) {
324 model.selectOperators(ops);
325 }
326
327 for (PartitionClockModel model : getPartitionClockModels()) {
328 model.selectOperators(ops);
329 }
330 clockModelOptions.selectOperators(ops);
331
332 for (PartitionTreeModel tree : getPartitionTreeModels()) {
333 tree.selectOperators(ops);
334 }
335 treeModelOptions.selectOperators(ops);
336
337 for (PartitionTreePrior prior : getPartitionTreePriors()) {
338 prior.selectOperators(ops);
339 }
340
341 if (contains(Microsatellite.INSTANCE)) {
342 microsatelliteOptions.selectOperators(ops);
343 }
344
345 // for (TraitData trait : getTraitsList()) { // all traits including locations
346 // if (!trait.getName().equalsIgnoreCase(TraitData.Traits.TRAIT_SPECIES.toString()))
347 // trait.getTraitData().selectOperators(ops);
348 // }
349
350 selectComponentOperators(this, ops);
351
352 // no remove operators for parameters that are part of a joint prior...
353 List<Operator> toRemove = new ArrayList<Operator>();
354 for (Operator operator : ops) {
355 if ((operator.getParameter1() != null && operator.getParameter1().isLinked) ||
356 (operator.getParameter2() != null && operator.getParameter2().isLinked)) {
357 toRemove.add(operator);
358 }
359 }
360
361 ops.removeAll(toRemove);
362
363 return ops;
364 }
365
366 @Override
367 public String getPrefix() {
368 return "";
369 }
370
371 public Operator getOperator(Parameter parameter) {
372 for (Operator operator : selectOperators()) {
373 if (operator.getParameter1() == parameter || operator.getParameter2() == parameter) {
374 return operator;
375 }
376 }
377 return null;
378 }
379
380
381
382
383 public boolean hasData() {
384 return dataPartitions.size() > 0;
385 }
386
387 public boolean contains(DataType dataType) {
388 for (AbstractPartitionData pd : dataPartitions) {
389 if (pd.getDataType().getType() == dataType.getType()) {
390 return true;
391 }
392 }
393 return false;
394 }
395
396 public void shareMicroSat() {
397 Microsatellite microsatellite = null;
398 for (PartitionSubstitutionModel model : getPartitionSubstitutionModels(Microsatellite.INSTANCE)) {
399 if (microsatellite == null) {
400 microsatellite = model.getMicrosatellite();
401 } else {
402 model.setMicrosatellite(microsatellite);
403 }
404 }
405 }
406
407 public void unshareMicroSat() {
408 Microsatellite microsatellite = null;
409 for (PartitionSubstitutionModel model : getPartitionSubstitutionModels(Microsatellite.INSTANCE)) {
410 if (microsatellite == null) {
411 microsatellite = model.getMicrosatellite();
412 } else {
413 microsatellite = new Microsatellite(model.getName() + ".microsat",
414 microsatellite.getMin(), microsatellite.getMax(), 1);
415 model.setMicrosatellite(microsatellite);
416 }
417 }
418 }
419
420 public boolean hasPartitionData(String name) {
421 for (AbstractPartitionData pd : dataPartitions) {
422 if (name.equalsIgnoreCase(pd.getName())) {
423 return true;
424 }
425 }
426 return false;
427 }
428
429 public PartitionData getPartitionData(Alignment alignment) {
430 for (PartitionData partition : getPartitionData()) {
431 if (partition.getAlignment() == alignment)
432 return partition;
433 }
434 return null;
435 }
436
437 /**
438 * exclude microsatellite and traits
439 */
440 public List<PartitionData> getPartitionData() {
441 List<PartitionData> pdList = new ArrayList<PartitionData>();
442 for (AbstractPartitionData partition : dataPartitions) {
443 if (partition instanceof PartitionData && partition.getTraits() == null) {
444 pdList.add((PartitionData) partition);
445 }
446 }
447 return pdList;
448 }
449
450 /**
451 * exclude PartitionData and traits
452 */
453 public List<PartitionPattern> getPartitionPattern() {
454 List<PartitionPattern> pdList = new ArrayList<PartitionPattern>();
455 for (AbstractPartitionData partition : dataPartitions) {
456 if (partition instanceof PartitionPattern) {
457 pdList.add((PartitionPattern) partition);
458 }
459 }
460 return pdList;
461 }
462
463 public List<AbstractPartitionData> getDataPartitions() {
464 return dataPartitions;
465 }
466
467 public List<AbstractPartitionData> getTraitPartitions(TraitData trait) {
468 List<AbstractPartitionData> pdList = new ArrayList<AbstractPartitionData>();
469 for (AbstractPartitionData pd : dataPartitions) {
470 if (pd.getTraits() != null && pd.getTraits().contains(trait)) {
471 pdList.add(pd);
472 }
473 }
474 return pdList;
475 }
476
477 public List<AbstractPartitionData> getDataPartitions(DataType dataType) {
478 List<AbstractPartitionData> pdList = new ArrayList<AbstractPartitionData>();
479 for (AbstractPartitionData pd : dataPartitions) {
480 if (pd.getDataType().getType() == dataType.getType()) {
481 pdList.add(pd);
482 }
483 }
484 return pdList;
485 }
486
487 public List<AbstractPartitionData> getDataPartitions(PartitionOptions model) {
488 if (model instanceof PartitionSubstitutionModel) {
489 return getDataPartitions((PartitionSubstitutionModel) model);
490 } else if (model instanceof PartitionClockModel) {
491 return getDataPartitions((PartitionClockModel) model);
492 } else if (model instanceof PartitionTreeModel) {
493 return getDataPartitions((PartitionTreeModel) model);
494 } else if (model instanceof PartitionTreePrior) {
495 return getDataPartitions((PartitionTreePrior) model);
496 } else {
497 return null;
498 }
499 }
500
501 private final Map<PartitionSubstitutionModel, List<AbstractPartitionData>> psmCache = new HashMap<PartitionSubstitutionModel, List<AbstractPartitionData>>();
502
503 public List<AbstractPartitionData> getDataPartitions(PartitionSubstitutionModel model) {
504 List<AbstractPartitionData> pdList = psmCache.get(model);
505
506 if (pdList == null) {
507 pdList = new ArrayList<AbstractPartitionData>();
508
509 for (AbstractPartitionData pd : dataPartitions) {
510 if (pd.getPartitionSubstitutionModel() == model) {
511 pdList.add(pd);
512 }
513 }
514
515 psmCache.put(model, pdList);
516 }
517 return pdList;
518 }
519
520 private final Map<PartitionClockModel, List<AbstractPartitionData>> pcmCache = new HashMap<PartitionClockModel, List<AbstractPartitionData>>();
521 private final Map<PartitionTreeModel, List<AbstractPartitionData>> ptmCache = new HashMap<PartitionTreeModel, List<AbstractPartitionData>>();
522
523 public List<AbstractPartitionData> getDataPartitions(PartitionTreeModel model) {
524 List<AbstractPartitionData> pdList = ptmCache.get(model);
525
526 if (pdList == null) {
527 pdList = new ArrayList<AbstractPartitionData>();
528
529 for (AbstractPartitionData pd : dataPartitions) {
530 if (pd.getPartitionTreeModel() == model) {
531 pdList.add(pd);
532 }
533 }
534
535 ptmCache.put(model, pdList);
536 }
537 return pdList;
538 }
539
540 private final Map<PartitionTreePrior, List<AbstractPartitionData>> ptpCache = new HashMap<PartitionTreePrior, List<AbstractPartitionData>>();
541
542 public List<AbstractPartitionData> getDataPartitions(PartitionTreePrior prior) {
543 List<AbstractPartitionData> pdList = ptpCache.get(prior);
544
545 if (pdList == null) {
546 pdList = new ArrayList<AbstractPartitionData>();
547
548 for (AbstractPartitionData pd : dataPartitions) {
549 if (pd.getPartitionTreeModel().getPartitionTreePrior() == prior) {
550 pdList.add(pd);
551 }
552 }
553
554 ptpCache.put(prior, pdList);
555 }
556 return pdList;
557 }
558
559 public List<AbstractPartitionData> getDataPartitions(PartitionClockModel clockModel) {
560 List<AbstractPartitionData> pdList = pcmCache.get(clockModel);
561
562 if (pdList == null) {
563 pdList = new ArrayList<AbstractPartitionData>();
564
565 for (AbstractPartitionData pd : dataPartitions) {
566 if (pd.getPartitionClockModel() != null && pd.getPartitionClockModel() == clockModel) {
567 pdList.add(pd);
568 }
569 }
570
571 pcmCache.put(clockModel, pdList);
572 }
573 return pdList;
574 }
575
576 public void clearDataPartitionCaches() {
577 psmCache.clear();
578 pcmCache.clear();
579 ptmCache.clear();
580 ptpCache.clear();
581 psmlCache.clear();
582 ptmlCache.clear();
583 pcmlCache.clear();
584 }
585
586 public boolean isEBSPSharingSamePrior() {
587 return getPartitionTreePriors().size() >= 1 &&
588 (isShareSameTreePrior() && getPartitionTreePriors().get(0).getNodeHeightPrior() == TreePriorType.EXTENDED_SKYLINE);
589 }
590
591 // ++++++++++++++ Partition Substitution Model ++++++++++++++
592 // public void addPartitionSubstitutionModel(PartitionSubstitutionModel model) {
593 // if (!partitionModels.contains(model)) {
594 // partitionModels.add(model);
595 // }
596 // }
597
598 // public List<PartitionSubstitutionModel> getPartitionSubstitutionModels() {
599 // return partitionModels;
600 // }
601
602 public List<PartitionSubstitutionModel> getPartitionSubstitutionModels(DataType dataType) {
603 List<PartitionSubstitutionModel> models = new ArrayList<PartitionSubstitutionModel>();
604 for (PartitionSubstitutionModel model : getPartitionSubstitutionModels(dataPartitions)) {
605 if (model.getDataType().getType() == dataType.getType()) {
606 models.add(model);
607 }
608 }
609 return models;
610 }
611
612 private final Map<List<? extends AbstractPartitionData>, List<PartitionSubstitutionModel>> psmlCache = new HashMap<List<? extends AbstractPartitionData>, List<PartitionSubstitutionModel>>();
613
614 public List<PartitionSubstitutionModel> getPartitionSubstitutionModels(List<? extends AbstractPartitionData> givenDataPartitions) {
615 List<PartitionSubstitutionModel> psmList = psmlCache.get(givenDataPartitions);
616
617 if (psmList == null) {
618 Set<PartitionSubstitutionModel> activeModels = new LinkedHashSet<PartitionSubstitutionModel>();
619
620 for (AbstractPartitionData partition : givenDataPartitions) {
621 PartitionSubstitutionModel model = partition.getPartitionSubstitutionModel();
622 if (model != null) {
623 activeModels.add(model);
624 }
625 }
626
627 psmList = new ArrayList<PartitionSubstitutionModel>(activeModels);
628
629 psmlCache.put(givenDataPartitions, psmList);
630 }
631
632 return psmList;
633 }
634
635 public List<PartitionSubstitutionModel> getPartitionSubstitutionModels() {
636 return getPartitionSubstitutionModels(dataPartitions);
637 }
638
639 // public List<PartitionSubstitutionModel> getPartitionTraitsSubstitutionModels() {
640 // return getPartitionSubstitutionModels(getTraitsList());
641 // }
642 //
643 // public List<PartitionSubstitutionModel> getPartitionNonTraitsSubstitutionModels() {
644 // return getPartitionSubstitutionModels(getNonTraitsDataList());
645 // }
646
647
648 // ++++++++++++++ Partition Clock Model ++++++++++++++
649
650 private final Map<List<? extends AbstractPartitionData>, List<PartitionClockModel>> pcmlCache = new HashMap<List<? extends AbstractPartitionData>, List<PartitionClockModel>>();
651
652 public List<PartitionClockModel> getPartitionClockModels(List<? extends AbstractPartitionData> givenDataPartitions) {
653 List<PartitionClockModel> pcmList = pcmlCache.get(givenDataPartitions);
654
655 if (pcmList == null) {
656 Set<PartitionClockModel> activeModels = new LinkedHashSet<PartitionClockModel>();
657
658 for (AbstractPartitionData partition : givenDataPartitions) {
659 PartitionClockModel model = partition.getPartitionClockModel();
660 if (model != null && !(partition.getDataType().getType() == DataType.CONTINUOUS)) {
661 activeModels.add(model);
662 }
663 }
664
665 pcmList = new ArrayList<PartitionClockModel>(activeModels);
666
667 pcmlCache.put(givenDataPartitions, pcmList);
668 }
669
670 return pcmList;
671 }
672
673 public List<PartitionClockModel> getPartitionClockModels(DataType dataType) {
674 List<PartitionClockModel> models = new ArrayList<PartitionClockModel>();
675 for (PartitionClockModel model : getPartitionClockModels()) {
676 if (model.getDataType().getType() == dataType.getType()) {
677 models.add(model);
678 }
679 }
680 return models;
681 }
682
683 public List<PartitionClockModel> getPartitionClockModels() {
684 return getPartitionClockModels(dataPartitions);
685 }
686
687 // ++++++++++++++ Partition Tree Model ++++++++++++++
688 // public void addPartitionTreeModel(PartitionTreeModel tree) {
689 //
690 // if (!partitionTreeModels.contains(tree)) {
691 // partitionTreeModels.add(tree);
692 // }
693 // }
694
695 // public List<PartitionTreeModel> getPartitionTreeModels() {
696 // return partitionTreeModels;
697 // }
698
699 private final Map<List<? extends AbstractPartitionData>, List<PartitionTreeModel>> ptmlCache = new HashMap<List<? extends AbstractPartitionData>, List<PartitionTreeModel>>();
700
701 public List<PartitionTreeModel> getPartitionTreeModels(List<? extends AbstractPartitionData> givenDataPartitions) {
702 List<PartitionTreeModel> ptmList = ptmlCache.get(givenDataPartitions);
703
704 if (ptmList == null) {
705 Set<PartitionTreeModel> activeTrees = new LinkedHashSet<PartitionTreeModel>();
706
707 for (AbstractPartitionData partition : givenDataPartitions) {
708 if (partition.getPartitionTreeModel() != null) {
709 activeTrees.add(partition.getPartitionTreeModel());
710 }
711 }
712
713 ptmList = new ArrayList<PartitionTreeModel>(activeTrees);
714
715 ptmlCache.put(givenDataPartitions, ptmList);
716 }
717 return ptmList;
718 }
719
720 public List<PartitionTreeModel> getPartitionTreeModels() {
721 return getPartitionTreeModels(dataPartitions);
722 }
723
724 // public List<PartitionTreeModel> getNonTraitPartitionTreeModels() {
725 // return getPartitionTreeModels(getNonTraitsDataList());
726 // }
727
728
729 // ++++++++++++++ Partition Tree Prior ++++++++++++++
730
731 public List<PartitionTreePrior> getPartitionTreePriors() {
732
733 List<PartitionTreePrior> activeTrees = new ArrayList<PartitionTreePrior>();
734
735 // # tree prior = 1 or # tree model
736 for (PartitionTreeModel model : getPartitionTreeModels()) {
737 PartitionTreePrior prior = model.getPartitionTreePrior();
738 if (prior != null && (!activeTrees.contains(prior))) {
739 activeTrees.add(prior);
740 }
741 }
742
743 return activeTrees;
744 }
745
746 public List<PartitionTreeModel> getPartitionTreeModels(PartitionTreePrior treePrior) {
747
748 List<PartitionTreeModel> activeTrees = new ArrayList<PartitionTreeModel>();
749
750 for (PartitionTreeModel model : getPartitionTreeModels()) {
751 PartitionTreePrior prior = model.getPartitionTreePrior();
752 if (prior != null && model.getPartitionTreePrior() == treePrior && (!activeTrees.contains(model))) {
753 activeTrees.add(model);
754 }
755 }
756
757 return activeTrees;
758 }
759
760 /**
761 * unlink all and copy the tree prior in selectedTreeModel to others
762 * currently, tree prior name cannot be changed, but tree model name can, so that we have to use instance
763 *
764 * @param selectedTreeModel the selected tree model whose tree prior copied to others
765 */
766 public void unLinkTreePriors(PartitionTreeModel selectedTreeModel) {
767 for (PartitionTreeModel model : getPartitionTreeModels()) {
768 // because # tree prior = 1 or # tree model, prior here will be a same instance through all tree models
769 PartitionTreePrior prior = model.getPartitionTreePrior();
770 if (model == selectedTreeModel) {
771 prior.setName(model.getName()); // keep name same as its tree model
772 } else {
773 PartitionTreePrior ptp = new PartitionTreePrior(this, model.getName(), prior);
774 model.setPartitionTreePrior(ptp);
775 }
776 }
777 clearDataPartitionCaches();
778 }
779
780 // link all to given treePrior
781 public void linkTreePriors(PartitionTreePrior treePrior) {
782 if (treePrior == null) treePrior = new PartitionTreePrior(this, getPartitionTreeModels().get(0));
783 for (PartitionTreeModel model : getPartitionTreeModels()) {
784 model.setPartitionTreePrior(treePrior);
785 }
786 clearDataPartitionCaches();
787 }
788
789 public boolean isShareSameTreePrior() {
790 return getPartitionTreePriors().size() <= 1;
791 }
792
793 // ++++++++++++++ Partition Clock Model ++++++++++++++
794
795 // public List<PartitionClockModelTreeModelLink> getPartitionClockTreeLinks() {
796 // return partitionClockTreeLinks;
797 // }
798 //
799 // public List<PartitionClockModelSubstModelLink> getTraitClockSubstLinks() {
800 // return partitionClockSubstLinks;
801 // }
802 //
803 // public PartitionClockModelTreeModelLink getPartitionClockTreeLink(PartitionClockModel model, PartitionTreeModel tree) {
804 // for (PartitionClockModelTreeModelLink clockTree : getPartitionClockTreeLinks()) {
805 // if (clockTree.getPartitionClockModel().equals(model) && clockTree.getPartitionTreeTree().equals(tree)) {
806 // return clockTree;
807 // }
808 // }
809 //
810 // return null;
811 // }
812 //
813 // public void updatePartitionAllLinks() {
814 // clearDataPartitionCaches();
815 // partitionClockTreeLinks.clear();
816 // partitionClockSubstLinks.clear();
817 //
818 // for (PartitionClockModel model : getPartitionClockModels()) {
819 // for (PartitionTreeModel tree : getPartitionTreeModels(getDataPartitions(model))) {
820 // PartitionClockModelTreeModelLink clockTree = new PartitionClockModelTreeModelLink(this, model, tree);
821 //
822 // if (!partitionClockTreeLinks.contains(clockTree)) {
823 // partitionClockTreeLinks.add(clockTree);
824 // }
825 // }
826 // }
827 //
828 // }
829
830 // public void updateAll() {
831 // updatePartitionAllLinks();
832 // for (ClockModelGroup clockModelGroup : clockModelOptions.getClockModelGroups()) {
833 // if (clockModelGroup.contain(Microsatellite.INSTANCE, this)) {
834 // if (getPartitionClockModels(clockModelGroup).size() == 1) {
835 // clockModelOptions.fixRateOfFirstClockPartition(clockModelGroup);
836 // getPartitionClockModels(clockModelGroup).get(0).setEstimatedRate(true);
837 // } else {
838 // clockModelOptions.fixMeanRate(clockModelGroup);
839 // }
840 // } else if (!(clockModelGroup.getRateTypeOption() == FixRateType.TIP_CALIBRATED
841 // || clockModelGroup.getRateTypeOption() == FixRateType.NODE_CALIBRATED
842 // || clockModelGroup.getRateTypeOption() == FixRateType.RATE_CALIBRATED)) {
843 // //TODO correct?
844 // clockModelOptions.fixRateOfFirstClockPartition(clockModelGroup);
845 // }
846 // }
847 // }
848
849 // update links (e.g List<PartitionData> allPartitionData), after use (e.g partition.setPartitionSubstitutionModel(model))
850
851 // public void updateLinksBetweenPDPCMPSMPTMPTPP() {
852 // for (PartitionSubstitutionModel model : getPartitionSubstitutionModels()) {
853 // model.clearAllPartitionData();
854 // }
855 //
856 // for (PartitionClockModel model : getPartitionClockModels()) {
857 // model.clearAllPartitionData();
858 // }
859 //
860 // for (PartitionTreeModel tree : getPartitionTreeModels()) {
861 // tree.clearAllPartitionData();
862 // }
863 //
864 // //TODO update PartitionTreePrior ?
865 //
866 // for (PartitionData partition : dataPartitions) {
867 // PartitionSubstitutionModel psm = partition.getPartitionSubstitutionModel();
868 // if (!psm.getDataPartitions().contains(partition)) {
869 // psm.addPartitionData(partition);
870 // }
871 //
872 // PartitionClockModel pcm = partition.getPartitionClockModel();
873 // if (!pcm.getDataPartitions().contains(partition)) {
874 // pcm.addPartitionData(partition);
875 // }
876 //
877 // PartitionTreeModel ptm = partition.getPartitionTreeModel();
878 // if (!ptm.getDataPartitions().contains(partition)) {
879 // ptm.addPartitionData(partition);
880 // }
881 // }
882 //
883 // }
884
885 public double getAveWeightedMeanDistance(List<AbstractPartitionData> partitions) {
886 double meanDistance = 0;
887 double totalSite = 0;
888 for (AbstractPartitionData partition : partitions) {
889 meanDistance = meanDistance + partition.getMeanDistance() * partition.getSiteCount();
890 totalSite = totalSite + partition.getSiteCount();
891 }
892
893 if (totalSite == 0) {
894 return 0;
895 } else {
896 return meanDistance / totalSite;
897 }
898 }
899
900 // public boolean hasDifferentTaxa(List<AbstractPartitionData> partitionDataList) {
901 // if (partitionDataList.size() < 2)
902 // return false;
903 //
904 // TaxonList ref = null;
905 // boolean hasDiff = false;
906 // for (AbstractPartitionData partition : partitionDataList) {
907 // final TaxonList a = partition.getTaxonList();
908 // if (ref == null) {
909 // ref = a;
910 // } else {
911 // if (a.getTaxonCount() != ref.getTaxonCount()) {
912 // hasDiff = true;
913 // } else {
914 // for (int k = 0; k < a.getTaxonCount(); ++k) {
915 // if (ref.getTaxonIndex(a.getTaxonId(k)) == -1) {
916 // hasDiff = true;
917 // }
918 // }
919 // }
920 // }
921 // }
922 // return hasDiff;
923 // }
924
925 /**
926 * check if all taxa are same across partitions.
927 */
928 public boolean hasIdenticalTaxa(List<AbstractPartitionData> partitionDataList) {
929 TaxonList taxa = null;
930 for (AbstractPartitionData partition : partitionDataList) {
931 if (taxa == null) {
932 taxa = partition.getTaxonList();
933 } else {
934 final TaxonList taxa1 = partition.getTaxonList();
935 if (taxa1 != null) {
936 // Trait partitions are assumed to have the same taxon list as the
937 // tree they are using and so will return null.
938 if (taxa1.getTaxonCount() != taxa.getTaxonCount()) {
939 return false;
940 }
941 for (int k = 0; k < taxa1.getTaxonCount(); ++k) {
942 if (taxa.getTaxonIndex(taxa1.getTaxonId(k)) == -1) {
943 // for (Taxon taxon : taxa1) {
944 // if (taxa.getTaxonIndex(taxon) == -1) { // this is wrong code
945 return false;
946 }
947 }
948 }
949 }
950 }
951 return true;
952 }
953
954 public boolean hasIdenticalTaxa() {
955 return hasIdenticalTaxa(dataPartitions);
956 }
957
958 public void updateTaxonList() {
959 taxonList.removeAllTaxa();
960 for (AbstractPartitionData partition : dataPartitions) {
961 if (!partition.isCreatedFromTrait()) {
962 for (Taxon taxon : partition.getTaxonList()) {
963 if (!taxonList.contains(taxon)) {
964 taxonList.addTaxon(taxon);
965 }
966 }
967 }
968 }
969 }
970
971 /**
972 * given a list of BEAUti AbstractPartitionData, take the union of taxon list from them
973 * but if partition instanceof PartitionPattern and taxon is masked in Patterns class, then not count.
974 * @param partitionDataList can be BEAUti PartitionData or PartitionPattern or both
975 * @return num of taxon
976 */
977 public int getTaxonCount(List<AbstractPartitionData> partitionDataList) {
978 if (partitionDataList == null || partitionDataList.size() == 0) return 0;
979
980 List<String> taxonNameList = new ArrayList<String>();
981 for (AbstractPartitionData partition : partitionDataList) {
982 if (partition.getTaxonList() != null) { // not a trait partition
983 for (Taxon t : partition.getTaxonList()) {
984 if (!taxonNameList.contains(t.getId())) {
985 if (partition instanceof PartitionPattern) {
986 Patterns patterns = ((PartitionPattern) partition).getPatterns();
987 if (!patterns.isMasked(patterns.getTaxonIndex(t)))
988 taxonNameList.add(t.getId());
989 } else {
990 taxonNameList.add(t.getId());
991 }
992 }
993 }
994 }
995 }
996 return taxonNameList.size();
997 }
998
999 // +++++++++++++ Traits +++++++++++++
1000
1001 // public List<PartitionData> getNonTraitsDataList() {
1002 // List<PartitionData> nonTraitsData = new ArrayList<PartitionData>();
1003 // for (PartitionData partition : dataPartitions) {
1004 // if (partition.getTraitType() == null) {
1005 // nonTraitsData.add(partition);
1006 // }
1007 // }
1008 // return nonTraitsData;
1009 // }
1010 //
1011 // public List<TraitData> getTraitsList() {
1012 // List<TraitData> traits = new ArrayList<TraitData>();
1013 // for (PartitionData partition : dataPartitions) {
1014 // if (partition.getTraitType() != null) {
1015 // traits.add((TraitData) partition);
1016 // }
1017 // }
1018 // return traits;
1019 // }
1020 //
1021 // public List<TraitData> getDiscreteIntegerTraits() {
1022 // List<TraitData> traits = new ArrayList<TraitData>();
1023 // for (PartitionData partition : dataPartitions) {
1024 // if (partition.getTraitType() != null && partition.getTraitType() != TraitData.TraitType.CONTINUOUS) {
1025 // traits.add((TraitData) partition);
1026 // }
1027 // }
1028 // return traits;
1029 // }
1030 //
1031 // public boolean hasDiscreteIntegerTraitsExcludeSpecies() { // exclude species at moment
1032 // return getDiscreteIntegerTraits().size() > 1
1033 // || (getDiscreteIntegerTraits().size() > 0 && (!traitExists(TraitData.TRAIT_SPECIES)));
1034 // }
1035
1036 public int getIndexOfTrait(String traitName) {
1037 int i = 0;
1038 for (TraitData trait : traits) {
1039 if (trait.getName().equalsIgnoreCase(traitName)) {
1040 return i;
1041 }
1042 i++;
1043 }
1044 return -1;
1045 }
1046
1047 public boolean traitExists(String traitName) {
1048 return getIndexOfTrait(traitName) != -1;
1049 }
1050
1051 public int addTrait(TraitData newTrait) {
1052 int selRow = getIndexOfTrait(newTrait.getName());
1053
1054 if (selRow == -1) {
1055 traits.add(newTrait);
1056 selRow = traits.size() - 1; // start 0
1057 }
1058
1059 return selRow; // only for trait panel
1060 }
1061
1062 public int createPartitionForTraits(String name, TraitData trait) {
1063 List<TraitData> traits = new ArrayList<TraitData>();
1064 traits.add(trait);
1065 return createPartitionForTraits(name, traits);
1066 }
1067
1068 public int createPartitionForTraits(String name, List<TraitData> traits) {
1069 int selRow = -1;
1070
1071 PartitionData partition = new PartitionData(this, name, traits.get(0).getFileName(), traits);
1072 dataPartitions.add(partition);
1073 selRow = dataPartitions.size() - 1;
1074
1075 if (partition.getPartitionSubstitutionModel() == null) {
1076 PartitionSubstitutionModel substModel = new PartitionSubstitutionModel(this, partition.getName(),
1077 partition);
1078 partition.setPartitionSubstitutionModel(substModel);
1079 }
1080
1081 if (partition.getPartitionTreeModel() == null) {
1082 partition.setPartitionTreeModel(getPartitionTreeModels().get(0));// always use 1st tree
1083 // getPartitionTreeModels().get(0).addPartitionData(newTrait);
1084 }
1085
1086 if (partition.getPartitionClockModel() == null && partition.getDataType().getType() != DataType.CONTINUOUS) {
1087 // PartitionClockModel based on PartitionData
1088 PartitionClockModel pcm = new PartitionClockModel(this, partition.getName(), partition, partition.getPartitionTreeModel());
1089 partition.setPartitionClockModel(pcm);
1090 }
1091
1092 updateTraitParameters(partition);
1093
1094 return selRow; // only for trait panel
1095 }
1096
1097 private void updateTraitParameters(AbstractPartitionData partition) {
1098 if (partition.isCreatedFromTrait()) {
1099 ContinuousComponentOptions comp = (ContinuousComponentOptions) getComponentOptions(ContinuousComponentOptions.class);
1100 comp.createParameters(this);
1101
1102 DiscreteTraitsComponentOptions comp2 = (DiscreteTraitsComponentOptions) getComponentOptions(DiscreteTraitsComponentOptions.class);
1103 comp2.createParameters(this);
1104
1105 AncestralStatesComponentOptions comp3 = (AncestralStatesComponentOptions) getComponentOptions(AncestralStatesComponentOptions.class);
1106 comp3.setReconstructAtNodes(partition, true);
1107 comp3.setReconstructAtMRCA(partition, false);
1108 }
1109 }
1110
1111 public void renamePartition(AbstractPartitionData partition, String newName) {
1112 partition.setName(newName);
1113 updateTraitParameters(partition);
1114 }
1115
1116 public void removeTrait(String traitName) {
1117 if (traitExists(traitName)) {
1118 clearTraitValues(traitName); // Clear trait values
1119 traits.remove(getTrait(traitName));
1120 }
1121 }
1122
1123 public void clearTraitValues(String traitName) {
1124 for (int i = 0; i < taxonList.getTaxonCount(); i++) {
1125 taxonList.getTaxon(i).setAttribute(traitName, "");
1126 }
1127 }
1128
1129 public TraitData getTrait(String traitName) {
1130 for (TraitData trait : traits) {
1131 if (trait.getName().equalsIgnoreCase(traitName))
1132 return trait;
1133 }
1134 return null;
1135 }
1136
1137 // public boolean hasAlignmentPartition() {
1138 // for (AbstractPartitionData partition : dataPartitions) {
1139 // if (partition instanceof PartitionData) {
1140 // if (((PartitionData) partition).getAlignment() != null) {
1141 // return true;
1142 // }
1143 // }
1144 // }
1145 // return false;
1146 // }
1147
1148
1149 public boolean hasDiscreteTrait() {
1150 for (TraitData traitData : traits) {
1151 if (traitData.getTraitType() == TraitData.TraitType.DISCRETE) {
1152 return true;
1153 }
1154 }
1155 return false;
1156 }
1157
1158 public boolean hasDiscreteTraitPartition() {
1159 for (AbstractPartitionData partition : dataPartitions) {
1160 if (partition.getTraits() != null && partition.getTraits().get(0).getTraitType() == TraitData.TraitType.DISCRETE) {
1161 return true;
1162 }
1163 }
1164 return false;
1165 }
1166
1167 public boolean hasContinuousTrait() {
1168 for (TraitData traitData : traits) {
1169 if (traitData.getTraitType() == TraitData.TraitType.CONTINUOUS) {
1170 return true;
1171 }
1172 }
1173 return false;
1174 }
1175
1176 public boolean hasContinuousTraitPartition() {
1177 for (AbstractPartitionData partition : dataPartitions) {
1178 if (partition.getTraits() != null && partition.getTraits().get(0).getTraitType() == TraitData.TraitType.CONTINUOUS) {
1179 return true;
1180 }
1181 }
1182 return false;
1183 }
1184
1185 public Set<String> getStatesForDiscreteModel(PartitionSubstitutionModel model) {
1186 Set<String> states = new TreeSet<String>();
1187 for (AbstractPartitionData partition : getDataPartitions(model)) {
1188 Set<String> newStates = partition.getTraits().get(0).getStatesOfTrait(taxonList);
1189
1190 if (states.size() > 0) {
1191 Set<String> shared = new HashSet<String>(states);
1192 shared.retainAll(newStates);
1193 if (shared.size() == 0) {
1194 throw new IllegalArgumentException("For discrete trait partitions to have a linked model they must share states");
1195 }
1196 }
1197
1198 states.addAll(newStates);
1199 }
1200
1201 if (states.size() < 1) throw new IllegalArgumentException("The number of states must be greater than 1");
1202
1203 return states;
1204 }
1205
1206 public static TraitData.TraitType guessTraitType(TaxonList taxa, String name) {
1207 TraitData.TraitType type = TraitData.TraitType.DISCRETE;
1208 return type;
1209 }
1210
1211 // ++++++++++++++++++++ message bar +++++++++++++++++
1212
1213 public String statusMessage() {
1214 // String message = "<html><p>";
1215 String message = "";
1216 if (hasData()) {
1217 message += "Data: " + taxonList.getTaxonCount() + " taxa, ";
1218 message += dataPartitions.size() + (dataPartitions.size() > 1 ? " partitions" : " partition");
1219
1220 if (userTrees.size() > 0) {
1221 message += ", " + userTrees.size() + " user" +
1222 (userTrees.size() > 1 ? " trees" : " tree");
1223 }
1224
1225 // if (hasPhylogeographic()) {
1226 // message += "; Phylogeographic Analysis";
1227 // }
1228
1229 // message += "; " + clockModelOptions.statusMessageClockModel();
1230
1231 } else if (userTrees.size() > 0) { // TODO
1232 message += "Trees only : " + userTrees.size() +
1233 (userTrees.size() > 1 ? " trees, " : " tree, ") +
1234 taxonList.getTaxonCount() + " taxa";
1235 } else if (taxonList != null && taxonList.getTaxonCount() > 0) { // TODO
1236 message += "Taxa only: " + taxonList.getTaxonCount() + " taxa";
1237 } else {
1238 message += "No data loaded - select 'Import Data...' from the 'File' menu.";
1239 }
1240 // message += "</p></html>";
1241 return message;
1242 }
1243
1244 public List<Object> getKeysFromValue(Map<?, ?> hm, Object value) {
1245 List<Object> list = new ArrayList<Object>();
1246 for (Object o : hm.keySet()) {
1247 if (hm.get(o).equals(value)) {
1248 list.add(o);
1249 }
1250 }
1251 return list;
1252 }
1253
1254 public Taxa getTaxa(String taxaName) {
1255 for (Taxa taxa : taxonSets) {
1256 if (taxa.getId().equalsIgnoreCase(taxaName)) return taxa;
1257 }
1258 return null;
1259 }
1260
1261 public int getTaxaIndex(String taxaName) {
1262 for (int i = 0; i < taxonSets.size(); i++) {
1263 if (taxonSets.get(i).getId().equalsIgnoreCase(taxaName)) return i;
1264 }
1265 return -1;
1266 }
1267
1268 //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1269 // Data options
1270 public Taxa taxonList = null; // union set of all taxa in all partitions. todo change to List<Taxa> regarding data type?
1271
1272 public List<Taxa> taxonSets = new ArrayList<Taxa>();
1273 public Map<Taxa, Boolean> taxonSetsMono = new HashMap<Taxa, Boolean>();
1274 public Map<Taxa, Double> taxonSetsHeights = new HashMap<Taxa, Double>();
1275 public Map<Taxa, Boolean> taxonSetsIncludeStem = new HashMap<Taxa, Boolean>();
1276 public Map<Taxa, PartitionTreeModel> taxonSetsTreeModel = new HashMap<Taxa, PartitionTreeModel>();
1277
1278 public boolean useTipDates = false;
1279
1280 public DateUnitsType datesUnits = DateUnitsType.YEARS;
1281 public DateUnitsType datesDirection = DateUnitsType.FORWARDS;
1282 public double maximumTipHeight = 0.0;
1283 public int translation = 0;
1284
1285 public Date originDate = null;
1286
1287
1288 public DateGuesser dateGuesser = new DateGuesser();
1289 // public TraitGuesser traitGuesser = new TraitGuesser();
1290 //
1291 // public List<String> selecetedTraits = new ArrayList<String>();
1292 // public Map<String, TraitGuesser.TraitType> traitTypes = new HashMap<String, TraitGuesser.TraitType>();
1293
1294 // Data
1295 public List<AbstractPartitionData> dataPartitions = new ArrayList<AbstractPartitionData>();
1296 public List<TraitData> traits = new ArrayList<TraitData>();
1297
1298 public List<List<PartitionData>> multiPartitionLists = new ArrayList<List<PartitionData>>();
1299 public List<AbstractPartitionData> otherPartitions = new ArrayList<AbstractPartitionData>();
1300
1301 // list of starting tree from user import
1302 public List<Tree> userTrees = new ArrayList<Tree>();
1303
1304 public boolean unlinkPartitionRates = true;
1305
1306 public Units.Type units = Units.Type.YEARS;
1307
1308 // Operator schedule options
1309 public OperatorSchedule.OptimizationTransform optimizationTransform = OperatorSchedule.OptimizationTransform.DEFAULT;
1310
1311 // MCMC options
1312 public int chainLength = 10000000;
1313 public int logEvery = 1000;
1314 public int echoEvery = 1000;
1315 public int burnIn = 100000;
1316 public String fileName = null;
1317 public boolean autoOptimize = true;
1318 public boolean performTraceAnalysis = false;
1319 public boolean generateCSV = true; // until/if a button
1320 public boolean samplePriorOnly = false;
1321
1322 public String fileNameStem = MCMCPanel.DEFAULT_FILE_NAME_STEM;
1323 public String logFileName = null;
1324
1325 public boolean generateDemographicLogFile = false;
1326 public String demographicModelName = null;
1327 public String demographicLogFileName = null;
1328
1329 public boolean allowOverwriteLog = false;
1330 // public boolean mapTreeLog = false;
1331 // public String mapTreeFileName = null;
1332 public List<String> treeFileName = new ArrayList<String>();
1333 public boolean substTreeLog = false;
1334 public List<String> substTreeFileName = new ArrayList<String>();
1335 public boolean operatorAnalysis = true;
1336 public String operatorAnalysisFileName = null;
1337
1338 public GlobalModelOptions globalModelOptions = new GlobalModelOptions(this);
1339 public ClockModelOptions clockModelOptions = new ClockModelOptions(this);
1340 public TreeModelOptions treeModelOptions = new TreeModelOptions(this);
1341
1342 public boolean useClassicOperatorsAndPriors = false;
1343
1344 public OperatorSetType operatorSetType = OperatorSetType.DEFAULT;
1345
1346 public boolean useClassicOperatorsAndPriors() {
1347 return useClassicOperatorsAndPriors;
1348 }
1349
1350 public boolean useNuRelativeRates() {
1351 return !useClassicOperatorsAndPriors() || !NEW_RELATIVE_RATE_PARAMETERIZATION;
1352 }
1353
1354 public boolean useNewGTR() {
1355 return !useClassicOperatorsAndPriors() || !NEW_GTR_PARAMETERIZATION;
1356 }
1357
1358 public boolean usePInvRandomWalk() {
1359 return !useClassicOperatorsAndPriors() || !LOGIT_PINV_KERNEL;
1360 }
1361
1362 public boolean useNewFrequenciesPrior() {
1363 return !useClassicOperatorsAndPriors() || !FREQUENCIES_DIRICHLET_PRIOR;
1364 }
1365
1366 public MicrosatelliteOptions microsatelliteOptions = new MicrosatelliteOptions(this);
1367
1368 public boolean shareMicroSat = true;
1369
1370 public boolean logCoalescentEventsStatistic = false;
1371
1372 }