| 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.CataclysmicDemographic; |
| 29 |
import dr.evolution.coalescent.DemographicFunction; |
| 30 |
import dr.evomodelxml.coalescent.CataclysmicDemographicModelParser; |
| 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 |
|
| 47 |
|
| 48 |
public class CataclysmicDemographicModel extends DemographicModel implements Citable { |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public CataclysmicDemographicModel(Parameter N0Parameter, Parameter N1Parameter, Parameter growthRateParameter, Parameter timeParameter, |
| 54 |
Type units, boolean useSpike) { |
| 55 |
|
| 56 |
this(CataclysmicDemographicModelParser.CATACLYSM_MODEL, N0Parameter, N1Parameter, growthRateParameter, timeParameter, units, useSpike); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public CataclysmicDemographicModel(String name, Parameter N0Parameter, Parameter secondParam, Parameter growthRateParameter, |
| 63 |
Parameter timeParameter, Type units, boolean useSpike) { |
| 64 |
|
| 65 |
super(name); |
| 66 |
|
| 67 |
cataclysm = new CataclysmicDemographic(units); |
| 68 |
|
| 69 |
this.N0Parameter = N0Parameter; |
| 70 |
addVariable(N0Parameter); |
| 71 |
N0Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 72 |
|
| 73 |
if (useSpike) { |
| 74 |
this.N1Parameter = secondParam; |
| 75 |
N1Parameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, 0.0, 1)); |
| 76 |
addVariable(N1Parameter); |
| 77 |
} else { |
| 78 |
this.declineRateParameter = secondParam; |
| 79 |
addVariable(declineRateParameter); |
| 80 |
} |
| 81 |
|
| 82 |
this.growthRateParameter = growthRateParameter; |
| 83 |
addVariable(growthRateParameter); |
| 84 |
growthRateParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1)); |
| 85 |
|
| 86 |
this.timeParameter = timeParameter; |
| 87 |
addVariable(timeParameter); |
| 88 |
timeParameter.addBounds(new Parameter.DefaultBounds(Double.POSITIVE_INFINITY, Double.MIN_VALUE, 1)); |
| 89 |
|
| 90 |
|
| 91 |
setUnits(units); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public DemographicFunction getDemographicFunction() { |
| 98 |
cataclysm.setN0(N0Parameter.getParameterValue(0)); |
| 99 |
cataclysm.setGrowthRate(growthRateParameter.getParameterValue(0)); |
| 100 |
cataclysm.setCataclysmTime(timeParameter.getParameterValue(0)); |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
double t = timeParameter.getParameterValue(0); |
| 111 |
double declineRate = (declineRateParameter == null) ? Math.log(N1Parameter.getParameterValue(0)) / t : |
| 112 |
declineRateParameter.getParameterValue(0); |
| 113 |
cataclysm.setDeclineRate(declineRate); |
| 114 |
|
| 115 |
return cataclysm; |
| 116 |
} |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
Parameter N0Parameter = null; |
| 123 |
Parameter N1Parameter = null; |
| 124 |
Parameter growthRateParameter = null; |
| 125 |
Parameter timeParameter = null; |
| 126 |
Parameter declineRateParameter = null; |
| 127 |
CataclysmicDemographic cataclysm = null; |
| 128 |
|
| 129 |
@Override |
| 130 |
public Citation.Category getCategory() { |
| 131 |
return Citation.Category.TREE_PRIORS; |
| 132 |
} |
| 133 |
|
| 134 |
@Override |
| 135 |
public String getDescription() { |
| 136 |
return "Boom-Bust Coalescent"; |
| 137 |
} |
| 138 |
|
| 139 |
@Override |
| 140 |
public List<Citation> getCitations() { |
| 141 |
return Collections.singletonList(CITATION); |
| 142 |
} |
| 143 |
|
| 144 |
public static Citation CITATION = new Citation( |
| 145 |
new Author[]{ |
| 146 |
new Author("B", "Shapiro"), |
| 147 |
new Author("", "et al.") |
| 148 |
}, |
| 149 |
"Rise and fall of the Beringian steppe bison", |
| 150 |
2004, |
| 151 |
"Science", |
| 152 |
306, 1561, 1565 |
| 153 |
); |
| 154 |
} |