Debian Codegraph @

src/dr/evomodel/operators/MoveLinkageGroup.java

raw symbols SCIP
1 /*
2 * MoveLinkageGroup.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.evomodel.operators;
27
28 import dr.evolution.util.Taxon;
29 import dr.evomodel.tree.HiddenLinkageModel;
30 import dr.evomodelxml.operators.MoveLinkageGroupParser;
31 import dr.inference.operators.SimpleMCMCOperator;
32 import dr.math.MathUtils;
33
34 /**
35 * @author Aaron Darling
36 */
37 public class MoveLinkageGroup extends SimpleMCMCOperator {
38
39 HiddenLinkageModel hlm;
40 int readCount;
41 int groupCount;
42
43 public MoveLinkageGroup(HiddenLinkageModel hlm, double weight){
44 this.hlm = hlm;
45 readCount = hlm.getData().getReadsTaxa().getTaxonCount();
46 groupCount = hlm.getLinkageGroupCount();
47 setWeight(weight);
48 }
49
50 public double doOperation() {
51 // pick a read uniformly at random, add it to a linkage group uniformly at random
52 int r = MathUtils.nextInt(readCount);
53 Taxon read = hlm.getData().getReadsTaxa().getTaxon(r);
54 int g=hlm.getLinkageGroupId(read);
55
56 int newGroup = MathUtils.nextInt(groupCount);
57 hlm.moveReadGroup(read, g, newGroup);
58
59 // moves are symmetric -- same forward and backward proposal probabilities
60 double logHastings = 0.0;
61 return logHastings;
62 }
63
64 public String getOperatorName() {
65 return MoveLinkageGroupParser.MOVE_LINKAGE_GROUP + "(" + hlm.getId() + ")";
66 }
67
68 public String getPerformanceSuggestion() {
69 return "Ask Aaron Darling to write a better operator";
70 }
71
72 }