Debian Codegraph @

src/dr/evomodel/coalescent/ExpansionModel.java

raw symbols SCIP
1 /*
2 * ExpansionModel.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.DemographicFunction;
29 import dr.evolution.coalescent.Expansion;
30 import dr.evomodelxml.coalescent.ExpansionModelParser;
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: ExpansionModel.java,v 1.5 2005/05/24 20:25:57 rambaut Exp $
45 */
46 public class ExpansionModel extends DemographicModel implements Citable {
47
48 //
49 // Public stuff
50 //
51
52 /**
53 * Construct demographic model with default settings
54 */
55 public ExpansionModel(Parameter N0Parameter, Parameter N1Parameter,
56 Parameter growthRateParameter, Type units, boolean usingGrowthRate) {
57
58 this(ExpansionModelParser.EXPANSION_MODEL, N0Parameter, N1Parameter, growthRateParameter, units, usingGrowthRate);
59 }
60
61 /**
62 * Construct demographic model with default settings
63 */
64 public ExpansionModel(String name, Parameter N0Parameter, Parameter N1Parameter,
65 Parameter growthRateParameter, Type units, boolean usingGrowthRate) {
66
67 super(name);
68
69 expansion = new Expansion(units);
70
71 this.N0Parameter = N0Parameter;
72 addVariable(N0Parameter);
73 N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
74
75 this.N1Parameter = N1Parameter;
76 addVariable(N1Parameter);
77 N1Parameter.addBounds(new Parameter.DefaultBounds(1.0, 0.0, 1));
78
79 this.growthRateParameter = growthRateParameter;
80 addVariable(growthRateParameter);
81 growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1));
82
83 this.usingGrowthRate = usingGrowthRate;
84
85 setUnits(units);
86 }
87
88
89 // general functions
90
91 public DemographicFunction getDemographicFunction() {
92
93 double N0 = N0Parameter.getParameterValue(0);
94 double N1 = N1Parameter.getParameterValue(0);
95 double growthRate = growthRateParameter.getParameterValue(0);
96
97 if (usingGrowthRate) {
98 expansion.setGrowthRate(growthRate);
99 } else {
100 double doublingTime = growthRate;
101 growthRate = Math.log(2) / doublingTime;
102 expansion.setDoublingTime(doublingTime);
103 }
104
105 expansion.setN0(N0);
106 expansion.setProportion(N1);
107
108 return expansion;
109 }
110
111 //
112 // protected stuff
113 //
114
115 Parameter N0Parameter = null;
116 Parameter N1Parameter = null;
117 Parameter growthRateParameter = null;
118 Expansion expansion = null;
119 boolean usingGrowthRate = true;
120
121 @Override
122 public Citation.Category getCategory() {
123 return Citation.Category.TREE_PRIORS;
124 }
125
126 @Override
127 public String getDescription() {
128 return "Expansion Coalescent";
129 }
130
131 @Override
132 public List<Citation> getCitations() {
133 return Collections.singletonList(CITATION);
134 }
135
136 public static Citation CITATION = new Citation(
137 new Author[]{
138 new Author("OG", "Pybus"),
139 new Author("A", "Rambaut")
140 },
141 "GENIE: estimating demographic history from molecular phylogenies",
142 2001,
143 "Bioinformatics",
144 18, 1404, 1405
145 );
146 }