Skip to content

Commit 0e93919

Browse files
committed
further stochastic mapping utilities
1 parent e8df1f7 commit 0e93919

32 files changed

+2829
-377
lines changed

build.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<!-- <fileset dir="${beast2path}/lib" includes="fest.jar"/> -->
3737
<!-- <fileset dir="${beast2path}/lib" includes="colt.jar"/> -->
3838
<pathelement path="../codonsubstmodels/build"/>
39+
<pathelement path="../BeastFX/build"/>
3940
</path>
4041

4142

@@ -199,6 +200,7 @@
199200
<mkdir dir="${Add_on_dir}/doc" />
200201
<mkdir dir="${Add_on_dir}/fxtemplates" />
201202
<mkdir dir="${Add_on_dir}/examples" />
203+
<mkdir dir="${Add_on_dir}/icons" />
202204

203205
<copy todir="${Add_on_dir}">
204206
<fileset file="version.xml"/>
@@ -209,6 +211,9 @@
209211
<copy todir="${Add_on_dir}/fxtemplates">
210212
<fileset dir="fxtemplates" />
211213
</copy>
214+
<copy todir="${Add_on_dir}/icons">
215+
<fileset dir="icons" />
216+
</copy>
212217
<!--
213218
<copy todir="${Add_on_dir}/doc">
214219
<fileset dir="doc" includes="beastmap.pdf"/>

src/beastmap/evolution/AncestralSequenceTreeLikelihood.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323

2424

2525
/**
26-
* Adapted from AncestralStateTreeLikelihood in beast classic
26+
* Adapted from AncestralStateTreeLikelihood in beast classic, which came from BEAST X
2727
*/
28-
29-
3028
@Description("Ancestral State Tree Likelihood")
3129
public class AncestralSequenceTreeLikelihood extends TreeLikelihood {
3230
public static final String STATES_KEY = "states";
@@ -239,7 +237,7 @@ protected boolean requiresRecalculation() {
239237
}
240238

241239

242-
public DataType getDataType() {
240+
public DataType getDataTypeOfMapper() {
243241
return dataType;
244242
}
245243

@@ -377,7 +375,6 @@ public void traverseSample(TreeInterface tree, Node node, int[] parentState) {
377375
state[j] = drawChoice(conditionalProbabilities);
378376
} catch (Error e) {
379377
System.err.println(e.toString());
380-
System.err.println("Please report error to Marc");
381378
state[j] = 0;
382379
}
383380
reconstructedStates[nodeNum][j] = state[j];

src/beastmap/evolution/BranchMutationSampler.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
import beast.base.core.Description;
77
import beast.base.core.Input;
88
import beast.base.core.Log;
9+
import beast.base.core.Input.Validate;
910
import beast.base.evolution.alignment.Alignment;
11+
import beast.base.evolution.alignment.Sequence;
12+
import beast.base.evolution.branchratemodel.BranchRateModel;
1013
import beast.base.evolution.datatype.DataType;
1114
import beast.base.evolution.sitemodel.SiteModel;
1215
import 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

src/beastmap/evolution/RecordedMutationSimulator.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)