Debian Codegraph @

src/dr/evomodel/MSSD/ALSBeagleTreeLikelihood.java

raw symbols SCIP
1 /*
2 * ALSBeagleTreeLikelihood.java
3 *
4 * Copyright (c) 2002-2016 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.evomodel.MSSD;
27
28 import dr.evomodel.branchmodel.BranchModel;
29 import dr.evomodel.siteratemodel.SiteRateModel;
30 import dr.evomodel.treelikelihood.BeagleTreeLikelihood;
31 import dr.evomodel.treelikelihood.LikelihoodPartialsProvider;
32 import dr.evomodel.treelikelihood.PartialsRescalingScheme;
33 import dr.evolution.alignment.PatternList;
34 import dr.evomodel.branchratemodel.BranchRateModel;
35 import dr.evomodel.tree.TreeModel;
36 import dr.evomodel.tipstatesmodel.TipStatesModel;
37 import dr.inference.model.Model;
38 import dr.inference.model.Parameter;
39
40 import java.util.Map;
41 import java.util.Set;
42
43 /**
44 * Package: ALSTreeLikelihood
45 * Description:
46 * <p/>
47 * <p/>
48 * Created by
49 * Alexander V. Alekseyenko ([email protected])
50 * Date: Feb 13, 2008
51 * Time: 10:13:07 AM
52 */
53 public class ALSBeagleTreeLikelihood extends BeagleTreeLikelihood implements LikelihoodPartialsProvider {
54
55 protected AbstractObservationProcess observationProcess;
56
57
58 public ALSBeagleTreeLikelihood(AbstractObservationProcess observationProcess, PatternList patternList, TreeModel treeModel,
59 BranchModel branchModel,
60 SiteRateModel siteRateModel,
61 BranchRateModel branchRateModel,
62 TipStatesModel tipStatesModel,
63 boolean useAmbiguities,
64 PartialsRescalingScheme scalingScheme,
65 boolean delayScaling,
66 Map<Set<String>, Parameter> partialsRestrictions) {
67
68 super(patternList, treeModel, branchModel, siteRateModel, branchRateModel, tipStatesModel, useAmbiguities, scalingScheme, delayScaling,
69 partialsRestrictions);
70 // }
71 //
72 //
73 // public ALSBeagleTreeLikelihood(AbstractObservationProcess observationProcess, PatternList patternList, TreeModel treeModel,
74 // SiteModel siteModel, BranchRateModel branchRateModel,
75 // boolean useAmbiguities, boolean storePartials) {
76 // super(patternList, treeModel, siteModel, branchRateModel, null, useAmbiguities, false, storePartials, false, false);
77
78 this.observationProcess = observationProcess;
79 addModel(observationProcess);
80
81 // // TreeLikelihood does not initialize the partials for tips, we'll do it ourselves
82 // int extNodeCount = treeModel.getExternalNodeCount();
83 // for (int i = 0; i < extNodeCount; i++) {
84 // String id = treeModel.getTaxonId(i);
85 // int index = patternList.getTaxonIndex(id);
86 // setPartials(likelihoodCore, patternList, categoryCount, index, i);
87 // }
88
89 /* //Examine the tree
90 double totalTime=0.0;
91 double realTime = 0.0;
92 for(int i=0; i<treeModel.getNodeCount();++i){
93 NodeRef node = treeModel.getNode(i);
94 double branchRate = branchRateModel.getBranchRate(treeModel,node);
95 double branchTime = treeModel.getBranchLength(node);
96 totalTime+=branchRate*branchTime;
97 realTime += branchTime;
98 System.err.println("Node "+node.toString()+ " time: "+branchTime+ " rate "+branchRate+" together "+branchTime*branchRate);
99 }
100 System.err.println("TotalTime: "+totalTime);
101 System.err.println("RealTime: "+realTime);*/
102 // scaleFactorsHelper = new ScaleFactorsHelper(this, this,
103 // treeModel, stateCount, patternCount, categoryCount);
104 }
105
106 protected double calculateLogLikelihood() {
107 throw new UnsupportedOperationException("Not implemented for BEAGLE");
108 // // Calculate the partial likelihoods
109 // super.calculateLogLikelihood();
110 // // get the frequency model
111 // double[] freqs = substitutionModelDelegate.getRootStateFrequencies();
112 // // let the observationProcess handle the rest
113 // scaleFactorsHelper.resetScaleFactors();
114 // return observationProcess.nodePatternLikelihood(freqs, this, scaleFactorsHelper);
115 }
116
117 protected void handleModelChangedEvent(Model model, Object object, int index) {
118 if (model == observationProcess) {
119 likelihoodKnown = false;
120 } else {
121 super.handleModelChangedEvent(model, object, index);
122 }
123 }
124
125 // final private ScaleFactorsHelper scaleFactorsHelper;
126 }