Debian Codegraph @

src/dr/evomodel/alloppnet/speciation/BirthDeathCollapseNClustersStatistic.java

raw symbols SCIP
1 /*
2 * BirthDeathCollapseNClustersStatistic.java
3 *
4 * Copyright (c) 2002-2017 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 /*
27 This file is part of BEAST.
28
29 BEAST is free software: you can redistribute it and/or modify
30 it under the terms of the GNU General Public License as published by
31 the Free Software Foundation, either version 3 of the License, or
32 (at your option) any later version.
33
34 BEAST is distributed in the hope that it will be useful,
35 but WITHOUT ANY WARRANTY; without even the implied warranty of
36 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37 GNU General Public License for more details.
38
39 You should have received a copy of the GNU General Public License
40 along with DISSECT. If not, see <http://www.gnu.org/licenses/>.
41 */
42
43 package dr.evomodel.alloppnet.speciation;
44
45
46 import dr.evomodel.speciation.SpeciesTreeModel;
47 import dr.evomodel.alloppnet.parsers.BirthDeathCollapseNClustersStatisticParser;
48 import dr.inference.model.Statistic;
49
50 /**
51 * @author Graham Jones
52 * Date: 01/10/2013
53 */
54 public class BirthDeathCollapseNClustersStatistic extends Statistic.Abstract {
55 private SpeciesTreeModel spptree;
56 private BirthDeathCollapseModel bdcm;
57
58
59 public BirthDeathCollapseNClustersStatistic(SpeciesTreeModel spptree, BirthDeathCollapseModel bdcm) {
60 super(BirthDeathCollapseNClustersStatisticParser.BDC_NCLUSTERS_STATISTIC);
61 this.spptree = spptree;
62 this.bdcm = bdcm;
63 }
64
65 @Override
66 public int getDimension() {
67 return 1;
68 }
69
70 @Override
71 public double getStatisticValue(int dim) {
72 int ninodes = spptree.getInternalNodeCount();
73 int n = 0;
74 for (int i = 0; i < ninodes; i++) {
75 double h = spptree.getNodeHeight(spptree.getInternalNode(i));
76 if (!BirthDeathCollapseModel.belowCollapseHeight(h, bdcm.getCollapseHeight())) {
77 n++;
78 }
79 }
80 return n+1;
81 }
82 }