66import beast .base .core .Description ;
77import beast .base .core .Input ;
88import beast .base .core .Log ;
9+ import beast .base .core .Input .Validate ;
910import beast .base .evolution .alignment .Alignment ;
11+ import beast .base .evolution .alignment .Sequence ;
12+ import beast .base .evolution .branchratemodel .BranchRateModel ;
1013import beast .base .evolution .datatype .DataType ;
1114import beast .base .evolution .sitemodel .SiteModel ;
1215import beast .base .evolution .substitutionmodel .SubstitutionModel ;
@@ -32,12 +35,18 @@ public class BranchMutationSampler extends AncestralSequenceTreeLikelihood imple
3235 SiteModel .Base siteModel ;
3336 SubstitutionModel substitutionModel ;
3437
38+
3539 double [][] qmatrixBase ;
3640
3741 final int MAX_N_LOOPS = 1000000 ;
3842 final int MAX_MUT_BRANCH = 10000 ; // Any more than this and we risk running out of memory
3943 int gapChar ;
4044
45+
46+ int n1 = 0 ;
47+ int n2 = 0 ;
48+
49+ SimulatedAlignmentWithMutations unconditionalData ; // Data simulated unconditional on the observed data
4150 SimpleIndelCodingAlignment indelData ;
4251
4352 @ Override
@@ -76,18 +85,38 @@ public void initAndValidate() {
7685 this .mutationsAlongEachBranch .add (new ArrayList <>());
7786 }
7887
79-
80-
8188
89+ // Log.warning("datatype " + getDataTypeOfMapper().getClass());
90+ // // Build a mock alignment
91+ // List<Sequence> seqs = new ArrayList<>();
92+ // for (int i = 0; i < tree.getLeafNodeCount(); i++) {
93+ // Sequence s = new Sequence(tree.getNode(i).getID(), getDataTypeOfMapper().encodingToString(new int[] { 0 })); // Dummy sequence
94+ // seqs.add(s);
95+ // }
96+ // Alignment mockData = new Alignment(seqs, getDataTypeOfMapper().getTypeDescription());
97+ //
98+ // unconditionalData = new SimulatedAlignmentWithMutations();
99+ // int nsites = dataInput.get().getPatternCount();
100+ // unconditionalData.initByName("data", mockData, "tree", tree, "siteModel", this.siteModel, "branchRateModel", this.branchRateModel, "sequencelength", nsites);
101+ //
82102 }
83103
84104
105+ @ Override
106+ public StochasticMapper getUnconditionalData () {
107+ return unconditionalData ;
108+ }
109+
110+
85111
86112
87113
88114 @ Override
89115 public void sampleMutations (long sample ) {
90116
117+
118+ //Log.warning(this.getID() + " sampling regular mutations ");
119+
91120 // Only do this once per logged state
92121 if (sample == this .lastSample ) return ;
93122
@@ -200,8 +229,29 @@ public void sampleMutations(long sample) {
200229 }
201230
202231
232+ // Sample unconditional
233+ if (unconditionalData != null ) {
234+ unconditionalData .simulate ();
235+ }
236+
237+
203238 // Update sample number
204239 sample = this .lastSample ;
240+
241+
242+
243+ // for (int nodeNr = 0; nodeNr < nbranches; nodeNr ++) {
244+ // n1 += this.getMutationsOnBranch(nodeNr).size();
245+ // n2 += unconditionalData.getMutationsOnBranch(nodeNr).size();
246+ // }
247+ //
248+ // if (n1 > n2) {
249+ // Log.warning("UNCOND " + n1 + " / " + n2);
250+ // }else {
251+ // Log.warning("COND " + n1 + " / " + n2);
252+ // }
253+ //
254+
205255
206256
207257 }
@@ -469,7 +519,7 @@ public int[] getStatesForNode(Tree tree, Node node) {
469519
470520
471521 @ Override
472- public DataType getDataType () {
522+ public DataType getDataTypeOfMapper () {
473523 return dataInput .get ().getDataType ();
474524 }
475525
0 commit comments