| 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.arg; |
| 27 |
|
| 28 |
import dr.evomodel.arg.ARGModel.Node; |
| 29 |
import dr.evomodel.arg.operators.ARGAddRemoveEventOperator; |
| 30 |
import dr.inference.model.CompoundParameter; |
| 31 |
import dr.inference.model.Statistic; |
| 32 |
import dr.xml.AbstractXMLObjectParser; |
| 33 |
import dr.xml.XMLObject; |
| 34 |
import dr.xml.XMLObjectParser; |
| 35 |
import dr.xml.XMLParseException; |
| 36 |
import dr.xml.XMLSyntaxRule; |
| 37 |
|
| 38 |
|
| 39 |
public class RecombinationPartitionStatistic extends Statistic.Abstract{ |
| 40 |
|
| 41 |
public final static String RECOMBINATION_PARTITION_STATISTIC = "partitionStatistic"; |
| 42 |
private int dimension; |
| 43 |
private ARGModel arg; |
| 44 |
private String[] taxaNames; |
| 45 |
|
| 46 |
public RecombinationPartitionStatistic(String id, ARGModel arg){ |
| 47 |
|
| 48 |
setId(id); |
| 49 |
|
| 50 |
this.arg = arg; |
| 51 |
|
| 52 |
this.dimension = arg.getExternalNodeCount(); |
| 53 |
taxaNames = new String[this.dimension]; |
| 54 |
for(int i = 0; i < taxaNames.length; i++){ |
| 55 |
taxaNames[i] = "" + ((Node)arg.getExternalNode(i)).taxon; |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
public int getDimension() { |
| 61 |
return dimension; |
| 62 |
} |
| 63 |
|
| 64 |
public String getDimensionName(int dim){ |
| 65 |
return "Taxa" + taxaNames[dim]; |
| 66 |
} |
| 67 |
|
| 68 |
public double getStatisticValue(int dim) { |
| 69 |
|
| 70 |
Node x = (Node)arg.getExternalNode(dim); |
| 71 |
|
| 72 |
assert x.taxon.toString().equals(taxaNames[dim]); |
| 73 |
|
| 74 |
boolean c = x.hasReassortmentAncestor(); |
| 75 |
|
| 76 |
if(c){ |
| 77 |
return 1.0; |
| 78 |
} |
| 79 |
return 0.0; |
| 80 |
} |
| 81 |
|
| 82 |
public static XMLObjectParser PARSER = new AbstractXMLObjectParser(){ |
| 83 |
|
| 84 |
public String getParserDescription() { |
| 85 |
return null; |
| 86 |
} |
| 87 |
|
| 88 |
public Class getReturnType() { |
| 89 |
return RecombinationPartitionStatistic.class; |
| 90 |
} |
| 91 |
|
| 92 |
public XMLSyntaxRule[] getSyntaxRules() { |
| 93 |
return null; |
| 94 |
} |
| 95 |
|
| 96 |
public Object parseXMLObject(XMLObject xo) throws XMLParseException { |
| 97 |
String id = xo.getId(); |
| 98 |
|
| 99 |
ARGModel arg = (ARGModel)xo.getChild(ARGModel.class); |
| 100 |
|
| 101 |
return new RecombinationPartitionStatistic(id,arg); |
| 102 |
} |
| 103 |
|
| 104 |
public String getParserName() { |
| 105 |
return RECOMBINATION_PARTITION_STATISTIC; |
| 106 |
} |
| 107 |
|
| 108 |
}; |
| 109 |
|
| 110 |
} |