Debian Codegraph @

src/dr/evomodel/arg/RecombinationPartitionStatistic.java

raw symbols SCIP
1 /*
2 * RecombinationPartitionStatistic.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.arg;
27
28 import dr.evomodel.arg.ARGModel.Node;
29 import dr.evomodel.arg.operators.ARGAddRemoveEventOperator;
30 import dr.inference.model.CompoundParameter;
31 import dr.inference.model.Statistic;
32 import dr.xml.AbstractXMLObjectParser;
33 import dr.xml.XMLObject;
34 import dr.xml.XMLObjectParser;
35 import dr.xml.XMLParseException;
36 import dr.xml.XMLSyntaxRule;
37
38
39 public class RecombinationPartitionStatistic extends Statistic.Abstract{
40
41 public final static String RECOMBINATION_PARTITION_STATISTIC = "partitionStatistic";
42 private int dimension;
43 private ARGModel arg;
44 private String[] taxaNames;
45
46 public RecombinationPartitionStatistic(String id, ARGModel arg){
47
48 setId(id);
49
50 this.arg = arg;
51
52 this.dimension = arg.getExternalNodeCount();
53 taxaNames = new String[this.dimension];
54 for(int i = 0; i < taxaNames.length; i++){
55 taxaNames[i] = "" + ((Node)arg.getExternalNode(i)).taxon;
56 }
57 }
58
59
60 public int getDimension() {
61 return dimension;
62 }
63
64 public String getDimensionName(int dim){
65 return "Taxa" + taxaNames[dim];
66 }
67
68 public double getStatisticValue(int dim) {
69
70 Node x = (Node)arg.getExternalNode(dim);
71
72 assert x.taxon.toString().equals(taxaNames[dim]);
73
74 boolean c = x.hasReassortmentAncestor();
75
76 if(c){
77 return 1.0;
78 }
79 return 0.0;
80 }
81
82 public static XMLObjectParser PARSER = new AbstractXMLObjectParser(){
83
84 public String getParserDescription() {
85 return null;
86 }
87
88 public Class getReturnType() {
89 return RecombinationPartitionStatistic.class;
90 }
91
92 public XMLSyntaxRule[] getSyntaxRules() {
93 return null;
94 }
95
96 public Object parseXMLObject(XMLObject xo) throws XMLParseException {
97 String id = xo.getId();
98
99 ARGModel arg = (ARGModel)xo.getChild(ARGModel.class);
100
101 return new RecombinationPartitionStatistic(id,arg);
102 }
103
104 public String getParserName() {
105 return RECOMBINATION_PARTITION_STATISTIC;
106 }
107
108 };
109
110 }