Debian Codegraph @

src/dr/evomodel/substmodel/OldGLMSubstitutionModel.java

raw symbols SCIP
1 /*
2 * OldGLMSubstitutionModel.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.substmodel;
27
28 import dr.evolution.datatype.DataType;
29 import dr.inference.distribution.LogLinearModel;
30 import dr.inference.loggers.LogColumn;
31 import dr.inference.model.BayesianStochasticSearchVariableSelection;
32 import dr.inference.model.Model;
33 import dr.util.Citation;
34 import dr.util.CommonCitations;
35
36 import java.util.Collections;
37 import java.util.List;
38
39 /**
40 * @author Marc A. Suchard
41 */
42 @Deprecated
43 public class OldGLMSubstitutionModel extends ComplexSubstitutionModel {
44
45 public OldGLMSubstitutionModel(String name, DataType dataType, FrequencyModel rootFreqModel,
46 LogLinearModel glm) {
47
48 super(name, dataType, rootFreqModel, null);
49 this.glm = glm;
50 addModel(glm);
51 testProbabilities = new double[stateCount*stateCount];
52
53 }
54
55 protected void setupRelativeRates(double[] rates) {
56 System.arraycopy(glm.getXBeta(),0,rates,0,rates.length);
57 }
58
59 protected void handleModelChangedEvent(Model model, Object object, int index) {
60 if (model == glm) {
61 updateMatrix = true;
62 fireModelChanged();
63 }
64 else
65 super.handleModelChangedEvent(model,object,index);
66 }
67
68 public LogColumn[] getColumns() {
69 //Aggregate columns from ComplexSubstitutionModel with glm.columns
70 LogColumn[] aggregated = new LogColumn[glm.getColumns().length + 2];
71 int index = 0;
72 for (LogColumn col : glm.getColumns()) {
73 aggregated[index] = col;
74 index++;
75 }
76 aggregated[index++] = new LikelihoodColumn(getId() + ".L");
77 aggregated[index++] = new NormalizationColumn(getId() + ".Norm");
78
79 return aggregated;
80 //return glm.getColumns();
81 }
82
83 public double getLogLikelihood() {
84 double logL = super.getLogLikelihood();
85 if (logL == 0 &&
86 BayesianStochasticSearchVariableSelection.Utils.connectedAndWellConditioned(testProbabilities,this)) { // Also check that graph is connected
87 return 0;
88 }
89 return Double.NEGATIVE_INFINITY;
90 }
91
92 @Override
93 public String getDescription() {
94 return "Generalized linear (model, GLM) substitution model"; // TODO Horrible; fix
95 }
96
97 @Override
98 public List<Citation> getCitations() {
99
100 return Collections.singletonList(CommonCitations.LEMEY_2014_UNIFYING);
101 }
102
103 private LogLinearModel glm;
104 private double[] testProbabilities;
105 }