Debian Codegraph @

src/dr/oldevomodel/treelikelihood/HiddenLinkageLikelihood.java

raw symbols SCIP
1 /*
2 * HiddenLinkageLikelihood.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.oldevomodel.treelikelihood;
27
28 import dr.evolution.LinkedGroup;
29 import dr.evolution.util.Taxon;
30 import dr.evolution.util.TaxonList;
31 import dr.evomodel.tree.HiddenLinkageModel;
32 import dr.evomodel.tree.TreeModel;
33 import dr.inference.model.AbstractModelLikelihood;
34 import dr.inference.model.Model;
35 import dr.inference.model.Variable;
36 import dr.inference.model.Variable.ChangeType;
37
38 import java.util.ArrayList;
39 import java.util.Set;
40
41 /**
42 * @author Aaron Darling
43 */
44 @Deprecated // Switching to BEAGLE
45 public class HiddenLinkageLikelihood extends AbstractModelLikelihood
46 {
47
48 TreeModel tree;
49 HiddenLinkageModel hlm;
50
51
52 public HiddenLinkageLikelihood(HiddenLinkageModel hlm, TreeModel tree)
53 {
54 super("HiddenLinkageLikelihood");
55 this.hlm = hlm;
56 this.tree = tree;
57 }
58
59
60
61 protected void acceptState() {
62 // nothing to do
63 }
64
65
66
67 protected void handleModelChangedEvent(Model model, Object object, int index) {
68 // nothing to do
69 }
70
71
72
73 protected void handleVariableChangedEvent(Variable variable, int index,
74 ChangeType type) {
75 // nothing to do
76 }
77
78
79
80 protected void restoreState() {
81 // nothing to do
82 }
83
84
85
86 protected void storeState() {
87 // nothing to do
88 }
89
90
91
92 public double getLogLikelihood() {
93 double logL = 0;
94 // first check whether the reads are linked together
95 // according to the linkage constraints provided as data in the
96 // input file
97 ArrayList<LinkedGroup> linkedGroups = hlm.getData().getConstraints();
98 for( LinkedGroup lg : linkedGroups ){
99 TaxonList tl = lg.getLinkedReads();
100 int found = 0;
101 for( int l=0; l<hlm.getLinkageGroupCount(); l++ ){
102 Set<Taxon> group = hlm.getGroup(l);
103 for(int i=0; i<tl.getTaxonCount(); i++){
104 if(group.contains(tl.getTaxon(i)))
105 found++;
106 }
107 if(found==tl.getTaxonCount()){
108 logL += Math.log(lg.getLinkageProbability());
109 break;
110 }else if(found>0){
111 logL += Math.log(1.0-lg.getLinkageProbability());
112 break;
113 }
114 }
115 }
116
117 // then check whether the topology of reference taxa is consistent with the fixed
118 // reference tree topology
119 if(hlm.getData().getFixedReferenceTree()){
120 logL += Double.NEGATIVE_INFINITY; // not yet implemented.
121 }
122 return logL;
123 }
124
125
126
127 public Model getModel() {
128 return this;
129 }
130
131
132
133 public void makeDirty() {
134 // nothing to do
135 }
136
137 }