Debian Codegraph @

src/dr/evomodel/coalescent/ConstExpConstModel.java

raw symbols SCIP
1 /*
2 * ConstExpConstModel.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.coalescent;
27
28 import dr.evolution.coalescent.ConstExpConst;
29 import dr.evolution.coalescent.DemographicFunction;
30 import dr.evomodelxml.coalescent.ConstExpConstModelParser;
31 import dr.inference.model.Parameter;
32 import dr.util.Author;
33 import dr.util.Citable;
34 import dr.util.Citation;
35
36 import java.util.Collections;
37 import java.util.List;
38
39 /**
40 * Exponential growth from a constant ancestral population size.
41 *
42 * @author Alexei Drummond
43 * @author Andrew Rambaut
44 * @version $Id: ConstantExponentialModel.java,v 1.8 2005/10/28 02:49:17 alexei Exp $
45 */
46 public class ConstExpConstModel extends DemographicModel implements Citable {
47
48 //
49 // Public stuff
50 //
51
52 /**
53 * Construct demographic model with default settings
54 */
55 public ConstExpConstModel(Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter timeParameter,
56 Parameter epochParameter, boolean useNumericalIntegrator, Type units) {
57
58 this(ConstExpConstModelParser.CONST_EXP_CONST_MODEL, N0Parameter, N1Parameter, growthRateParameter, timeParameter, epochParameter, useNumericalIntegrator, units);
59 }
60
61 /**
62 * Construct demographic model with default settings
63 */
64 public ConstExpConstModel(String name, Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter timeParameter,
65 Parameter epochParameter, boolean useNumericalIntegrator, Type units) {
66
67 super(name);
68
69 if (N1Parameter != null && growthRateParameter != null) {
70 throw new RuntimeException("Only one of N1 and growthRate can be specified");
71 }
72
73 constExpConst = new ConstExpConst(
74 (N1Parameter != null ? ConstExpConst.Parameterization.ANCESTRAL_POPULATION_SIZE : ConstExpConst.Parameterization.GROWTH_RATE),
75 useNumericalIntegrator, units);
76
77 this.N0Parameter = N0Parameter;
78 addVariable(N0Parameter);
79 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
80
81 this.N1Parameter = N1Parameter;
82 this.growthRateParameter = growthRateParameter;
83
84 if (N1Parameter != null) {
85 addVariable(N1Parameter);
86 N1Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
87 } else {
88 addVariable(growthRateParameter);
89 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 1));
90 }
91
92 this.timeParameter = timeParameter;
93 addVariable(timeParameter);
94 timeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
95
96 this.epochParameter = epochParameter;
97 addVariable(epochParameter);
98 epochParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
99
100 setUnits(units);
101 }
102
103
104 // general functions
105
106 public DemographicFunction getDemographicFunction() {
107
108 constExpConst.setEpochTime(epochParameter.getParameterValue(0));
109 constExpConst.setN0(N0Parameter.getParameterValue(0));
110 constExpConst.setTime1(timeParameter.getParameterValue(0));
111
112 if (N1Parameter != null) {
113 constExpConst.setN1(N1Parameter.getParameterValue(0));
114 } else {
115 constExpConst.setGrowthRate(growthRateParameter.getParameterValue(0));
116 }
117
118 return constExpConst;
119 }
120
121 //
122 // protected stuff
123 //
124
125 private final Parameter N0Parameter;
126 private final Parameter N1Parameter;
127 private final Parameter growthRateParameter;
128 private final Parameter timeParameter;
129 private final Parameter epochParameter;
130 private final ConstExpConst constExpConst;
131
132
133 @Override
134 public Citation.Category getCategory() {
135 return Citation.Category.TREE_PRIORS;
136 }
137
138 @Override
139 public String getDescription() {
140 return "Constant-Exponential-Constant Coalescent";
141 }
142
143 @Override
144 public List<Citation> getCitations() {
145 return Collections.singletonList(CITATION);
146 }
147
148 public static Citation CITATION = new Citation(
149 new Author[]{
150 new Author("OG", "Pybus"),
151 new Author("A", "Rambaut")
152 },
153 "GENIE: estimating demographic history from molecular phylogenies",
154 2001,
155 "Bioinformatics",
156 18, 1404, 1405
157 );
158 }