| 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.DemographicFunction; |
| 29 |
import dr.evolution.coalescent.LogisticGrowth; |
| 30 |
import dr.evomodelxml.coalescent.LogisticGrowthModelParser; |
| 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 LogisticGrowthModel extends DemographicModel implements Citable { |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
public LogisticGrowthModel(Parameter N0Parameter, Parameter growthRateParameter, |
| 56 |
Parameter shapeParameter, double alpha, Type units, |
| 57 |
boolean usingGrowthRate) { |
| 58 |
|
| 59 |
this(LogisticGrowthModelParser.LOGISTIC_GROWTH_MODEL, N0Parameter, growthRateParameter, shapeParameter, alpha, units, usingGrowthRate); |
| 60 |
} |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
public LogisticGrowthModel(String name, Parameter N0Parameter, Parameter growthRateParameter, Parameter shapeParameter, double alpha, Type units, boolean usingGrowthRate) { |
| 66 |
|
| 67 |
super(name); |
| 68 |
|
| 69 |
logisticGrowth = new LogisticGrowth(units); |
| 70 |
|
| 71 |
this.N0Parameter = N0Parameter; |
| 72 |
addVariable(N0Parameter); |
| 73 |
N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 74 |
|
| 75 |
this.growthRateParameter = growthRateParameter; |
| 76 |
addVariable(growthRateParameter); |
| 77 |
growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 78 |
|
| 79 |
this.shapeParameter = shapeParameter; |
| 80 |
addVariable(shapeParameter); |
| 81 |
shapeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 82 |
|
| 83 |
this.alpha = alpha; |
| 84 |
this.usingGrowthRate = usingGrowthRate; |
| 85 |
|
| 86 |
setUnits(units); |
| 87 |
} |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
public DemographicFunction getDemographicFunction() { |
| 93 |
|
| 94 |
logisticGrowth.setN0(N0Parameter.getParameterValue(0)); |
| 95 |
|
| 96 |
if (usingGrowthRate) { |
| 97 |
double r = growthRateParameter.getParameterValue(0); |
| 98 |
logisticGrowth.setGrowthRate(r); |
| 99 |
} else { |
| 100 |
double doublingTime = growthRateParameter.getParameterValue(0); |
| 101 |
logisticGrowth.setDoublingTime(doublingTime); |
| 102 |
} |
| 103 |
|
| 104 |
logisticGrowth.setTime50(shapeParameter.getParameterValue(0)); |
| 105 |
|
| 106 |
return logisticGrowth; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
Parameter N0Parameter = null; |
| 114 |
Parameter growthRateParameter = null; |
| 115 |
Parameter shapeParameter = null; |
| 116 |
double alpha = 0.5; |
| 117 |
LogisticGrowth logisticGrowth = null; |
| 118 |
boolean usingGrowthRate = true; |
| 119 |
|
| 120 |
@Override |
| 121 |
public Citation.Category getCategory() { |
| 122 |
return Citation.Category.TREE_PRIORS; |
| 123 |
} |
| 124 |
|
| 125 |
@Override |
| 126 |
public String getDescription() { |
| 127 |
return "Logistic Growth Coalescent"; |
| 128 |
} |
| 129 |
|
| 130 |
@Override |
| 131 |
public List<Citation> getCitations() { |
| 132 |
return Collections.singletonList(CITATION); |
| 133 |
} |
| 134 |
|
| 135 |
public static Citation CITATION = new Citation( |
| 136 |
new Author[]{ |
| 137 |
new Author("OG", "Pybus"), |
| 138 |
new Author("A", "Rambaut") |
| 139 |
}, |
| 140 |
"GENIE: estimating demographic history from molecular phylogenies", |
| 141 |
2001, |
| 142 |
"Bioinformatics", |
| 143 |
18, 1404, 1405 |
| 144 |
); |
| 145 |
} |