| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 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 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
public class ConstExpConstModel extends DemographicModel implements Citable { |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
} |