| 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.evoxml; |
| 27 |
|
| 28 |
import dr.xml.*; |
| 29 |
import dr.evolution.tree.Tree; |
| 30 |
import dr.evolution.alignment.Patterns; |
| 31 |
import dr.evolution.util.Taxa; |
| 32 |
import dr.evolution.datatype.Microsatellite; |
| 33 |
import dr.oldevomodel.substmodel.MicrosatelliteModel; |
| 34 |
import dr.evomodel.branchratemodel.BranchRateModel; |
| 35 |
import dr.evomodel.branchratemodel.DefaultBranchRateModel; |
| 36 |
import dr.oldevomodel.sitemodel.GammaSiteModel; |
| 37 |
import dr.app.seqgen.MicrosatelliteSimulator; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
public class MicrosatelliteSimulatorParser extends AbstractXMLObjectParser { |
| 46 |
public static final String MICROSATELLITE_SIMULATOR = "microsatelliteSimulator"; |
| 47 |
|
| 48 |
public String getParserName(){ |
| 49 |
return MICROSATELLITE_SIMULATOR; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 54 |
|
| 55 |
Microsatellite msatDataType = (Microsatellite)xo.getChild(Microsatellite.class); |
| 56 |
Taxa taxa = (Taxa)xo.getChild(Taxa.class); |
| 57 |
Tree tree = (Tree)xo.getChild(Tree.class); |
| 58 |
MicrosatelliteModel msatModel = (MicrosatelliteModel)xo.getChild(MicrosatelliteModel.class); |
| 59 |
|
| 60 |
BranchRateModel brModel = (BranchRateModel)xo.getChild(BranchRateModel.class); |
| 61 |
if(brModel == null){ |
| 62 |
brModel = new DefaultBranchRateModel(); |
| 63 |
} |
| 64 |
|
| 65 |
MicrosatelliteSimulator msatSim = new MicrosatelliteSimulator( |
| 66 |
msatDataType, |
| 67 |
taxa, |
| 68 |
tree, |
| 69 |
new GammaSiteModel(msatModel), |
| 70 |
brModel |
| 71 |
); |
| 72 |
|
| 73 |
Patterns patterns = msatSim.simulateMsatPattern(); |
| 74 |
|
| 75 |
String msatPatId = xo.getAttribute("id","simMsatPat"); |
| 76 |
patterns.setId(msatPatId); |
| 77 |
MicrosatellitePatternParser.printDetails(patterns); |
| 78 |
MicrosatellitePatternParser.printMicrosatContent(patterns); |
| 79 |
|
| 80 |
return patterns; |
| 81 |
|
| 82 |
} |
| 83 |
|
| 84 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 85 |
return new XMLSyntaxRule[]{ |
| 86 |
new ElementRule(Microsatellite.class), |
| 87 |
new ElementRule(Taxa.class), |
| 88 |
new ElementRule(Tree.class), |
| 89 |
new ElementRule(MicrosatelliteModel.class), |
| 90 |
new ElementRule(BranchRateModel.class, true) |
| 91 |
|
| 92 |
}; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
public String getParserDescription(){ |
| 98 |
return "This parser facilliates simulation of microsatellites " + |
| 99 |
"given a tree and infinitesimal rate model"; |
| 100 |
} |
| 101 |
|
| 102 |
public Class getReturnType(){ |
| 103 |
return Patterns.class; |
| 104 |
} |
| 105 |
} |