Skip to content

Commit

Permalink
more porting to BEAST v2.7
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Aug 9, 2022
1 parent 61a28df commit 82edb4f
Show file tree
Hide file tree
Showing 10 changed files with 230 additions and 214 deletions.
73 changes: 40 additions & 33 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
</description>

<!-- set global properties for this build -->
<property name="srcBEAST_CLASSIC" location="../beast-classic/src" />
<property name="buildBEAST_CLASSIC" location="../beast-classic/build" />
<property name="libBEAST_CLASSIC" location="../beast-classic/lib" />
<property name="release_dir" value="../beast-classic/release" />
<property name="BEAST_CLASSICdir" location="../beast-classic/" />
<property name="srcBEAST_CLASSIC" location="${BEAST_CLASSICdir}/src" />
<property name="buildBEAST_CLASSIC" location="${BEAST_CLASSICdir}/build" />
<property name="libBEAST_CLASSIC" location="${BEAST_CLASSICdir}/lib" />
<property name="release_dir" value="${BEAST_CLASSICdir}/release" />
<property name="distBEAST_CLASSIC" location="${buildBEAST_CLASSIC}/dist" />
<property name="beast2path" location="../beast2" />
<property name="libBeast2" location="${beast2path}/lib" />
<property name="srcBeast2" location="${beast2path}/src" />
<property name="beast2classpath" location="${beast2path}/build" />
<property name="BEASTLabspath" location="../BEASTLabs" />
<property name="BEASTLabsclasspath" location="${BEASTLabspath}/build" />
<property name="beastappdir" location="../BeastFX/" />
<property name="beastappclasspath" location="${beastappdir}/build" />
<property name="beastapplib" location="${beastappdir}/locallib" />
<property name="Add_on_dir" value="${release_dir}/add-on" />
<property name="version" value="1.5.0" />

<import file="${beast2path}/build.xml" />

Expand All @@ -29,21 +32,31 @@

<path id="classpath">
<pathelement path="${buildBEAST_CLASSIC}"/>
<fileset dir="${libBeast2}" includes="junit-4.8.2.jar"/>
<fileset dir="${libBeast2}" includes="commons-math3-3.1.1.jar"/>
<fileset dir="${libBeast2}" includes="fest.jar"/>
<fileset dir="${libBeast2}" includes="beagle.jar"/>
<fileset dir="${libBeast2}" includes="jam.jar"/>
<fileset dir="${libBeast2}" includes="colt.jar"/>
<fileset dir="${libBeast2}" includes="antlr-runtime-4.7.jar"/>
<fileset dir="${libBEAST_CLASSIC}" includes="mtj.jar"/>
<fileset dir="${libBeast2}/junit" includes="junit-platform-console-standalone-1.8.2.jar"/>
<fileset dir="${libBEAST_CLASSIC}" includes="mtj.jar"/>
<fileset dir="${libBeast2}" includes="beagle.jar"/>
<fileset dir="${libBeast2}" includes="antlr-runtime-4.10.1.jar"/>
<fileset dir="${libBeast2}" includes="beagle.jar"/>
<fileset dir="${libBeast2}" includes="colt.jar"/>
<fileset dir="${libBeast2}" includes="commons-math3-3.6.1.jar"/>
<fileset dir="${beastapplib}" includes="testfx.jar"/>
<pathelement path="${beast2classpath}"/>
<pathelement path="${beastappclasspath}"/>
<pathelement path="${BEASTLabsclasspath}"/>
</path>

<!-- start -->
<target name="initBEAST_CLASSIC">
<echo message="${ant.project.name}: ${ant.file}" />

<available file="${BEAST_CLASSICdir}/version.xml" property="versionAvailable"/>
<fail unless="versionAvailable">
** Required file version.xml does not exist. **
</fail>

<!-- Read package name and version from xml file -->
<xmlproperty file="${BEAST_CLASSICdir}/version.xml" prefix="fromVersionFile" />
<property name="BEAST_CLASSICversion" value="${fromVersionFile.package(version)}" />
</target>

<target name="cleanBEAST_CLASSIC">
Expand Down Expand Up @@ -78,20 +91,16 @@
<mkdir dir="${buildBEAST_CLASSIC}" />

<!-- Compile the java code from ${srcBEAST_CLASSIC} into ${buildBEAST_CLASSIC} /bin -->
<javac target="1.8" srcdir="${srcBEAST_CLASSIC}" destdir="${buildBEAST_CLASSIC}" classpathref="classpath"
<javac srcdir="${srcBEAST_CLASSIC}" destdir="${buildBEAST_CLASSIC}" classpathref="classpath"
fork="true"
memoryinitialsize="256m"
memorymaximumsize="256m"
source="1.8"
target="1.8">
<!--
source="1.6"
target="1.6">
-->
<include name="beast/**/**" />
<include name="dr/**/**" />
>
<include name="beastclassic/**/**" />
<!-- compile JUnit test classes -->
<!--
<include name="test/**" />
-->
</javac>
<echo message="Successfully compiled." />
</target>
Expand Down Expand Up @@ -128,8 +137,7 @@
</jar>
<jar jarfile="${distBEAST_CLASSIC}/BEAST_CLASSIC.src.jar">
<fileset dir="${srcBEAST_CLASSIC}">
<include name="beast/**/*.java" />
<include name="dr/**/*.java" />
<include name="beastclassic/**/*.java" />
<include name="test/**/*.java" />
<include name="beast/**/*.png" />
<include name="beast/**/*.xsl" />
Expand All @@ -140,9 +148,8 @@
<attribute name="Built-By" value="${user.name}" />
</manifest>
<fileset dir="${buildBEAST_CLASSIC}">
<include name="beast/**/*.class" />
<include name="dr/**/*.class" />
<include name="util/**/*.class" />
<include name="beastclassic/**/*.class" />
<include name="test/**/*.class" />
<include name="**/*.properties" />
</fileset>
</jar>
Expand Down Expand Up @@ -200,7 +207,7 @@
<mkdir dir="${Add_on_dir}/lib" />
<mkdir dir="${Add_on_dir}/examples" />
<mkdir dir="${Add_on_dir}/examples/nexus" />
<mkdir dir="${Add_on_dir}/templates" />
<mkdir dir="${Add_on_dir}/fxtemplates" />

<copy todir="${Add_on_dir}">
<fileset file="version.xml"/>
Expand All @@ -218,16 +225,16 @@
<copy todir="${Add_on_dir}">
<fileset dir="${distBEAST_CLASSIC}" includes="BEAST_CLASSIC.src.jar" />
</copy>
<copy todir="${Add_on_dir}/templates">
<fileset file="templates/discrete-trait.xml" />
<fileset file="templates/ClassicSubtseModels.xml" />
<copy todir="${Add_on_dir}/fxtemplates">
<fileset file="fxtemplates/discrete-trait.xml" />
<fileset file="fxtemplates/ClassicSubtseModels.xml" />
</copy>
<jar jarfile="${distBEAST_CLASSIC}/BEAST_CLASSIC.addon.v${version}.zip">
<jar jarfile="${distBEAST_CLASSIC}/BEAST_CLASSIC.addon.v${BEAST_CLASSICversion}.zip">
<fileset dir="${Add_on_dir}">
<include name="**/*" />
</fileset>
</jar>
<echo message="Add-on version v${version} release is finished." />
<echo message="Add-on version v${BEAST_CLASSICversion} release is finished." />
</target>

<target name="tutorial">
Expand Down
59 changes: 31 additions & 28 deletions examples/H5N1_HA_discrete2.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<beast version='2.0'
namespace='beast.evolution.alignment:beast.core:beast.evolution.tree:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood:beast.evolution.tree.coalescent:beast.core.parameter'>
namespace='beast.base.evolution.alignment:beast.pkgmgmt:beast.base.core:beast.base.inference:beast.base.evolution.tree:beast.base.util:beast.base.math:beast.evolution.nuc:beast.base.evolution.operator:beast.base.inference.operator:beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:beast.base.evolution.tree.coalescent:beast.pkgmgmt:beast.base.core:beast.base.inference.parameter'>


<data dataType="nucleotide" id="alignment" name="alignment">
Expand Down Expand Up @@ -299,7 +299,7 @@
</sequence>
</data>

<trait id='tipDates' spec='beast.evolution.tree.TraitSet' traitname='date' units='year' value='
<trait id='tipDates' spec='beast.base.evolution.tree.TraitSet' traitname='date' units='year' value='
A_chicken_Fujian_1042_2005 = 2005.0,
A_Duck_Fujian_1734_2005 = 2005.0,
A_duck_Fujian_897_2005 = 2005.0,
Expand Down Expand Up @@ -398,10 +398,10 @@
A_duck_Hunan_1608_2005 = 2005.0,
A_duck_Hunan_182_2005 = 2005.0,
A_blackbird_Hunan_1_2004 = 2004.0'>
<taxa spec='beast.evolution.alignment.TaxonSet' alignment='@alignment'/>
<taxa spec='beast.base.evolution.alignment.TaxonSet' alignment='@alignment'/>
</trait>

<userDataType spec='beast.evolution.datatype.UserDataType' id='location'
<userDataType spec='beast.base.evolution.datatype.UserDataType' id='location'
states='7'
codelength='-1'
codeMap='
Expand All @@ -420,8 +420,8 @@
<!--
<distribution spec='TraitedTreeLikelihood' id="geoTreeLikelihood" dataType='@location'>
-->
<distribution spec='AncestralStateTreeLikelihood' id="geoTreeLikelihood" tag='location'>
<data spec='AlignmentFromTrait' userDataType='@location'>
<distribution spec='beastclassic.evolution.likelihood.AncestralStateTreeLikelihood' id="geoTreeLikelihood" tag='location'>
<data spec='beastclassic.evolution.alignment.AlignmentFromTrait' userDataType='@location'>
<traitSet id='traitset' spec='TraitSet'
traitname='discrete' value="
A_chicken_Fujian_1042_2005 = Fujian,
Expand Down Expand Up @@ -522,12 +522,12 @@
A_duck_Hunan_1608_2005 = Hunan,
A_duck_Hunan_182_2005 = Hunan,
A_blackbird_Hunan_1_2004 = Hunan">
<taxa spec='beast.evolution.alignment.TaxonSet' alignment='@alignment'/>
<taxa spec='beast.base.evolution.alignment.TaxonSet' alignment='@alignment'/>
</traitSet>
</data>
<tree idref="tree"/>
<siteModel spec='SiteModel' id="geoSiteModel" gammaCategoryCount='1'>
<substModel spec="SVSGeneralSubstitutionModel" id="svs" eigenSystem="beast.evolution.substitutionmodel.RobustEigenSystem">
<substModel spec="beastclassic.evolution.substitutionmodel.SVSGeneralSubstitutionModel" id="svs" eigenSystem="beast.evolution.substitutionmodel.RobustEigenSystem">
<frequencies id='freqs' spec='Frequencies'>
<frequencies id='frequencies' spec='parameter.RealParameter' value='0.143 0.143 0.143 0.143 0.143 0.143 0.142'/>
</frequencies>
Expand Down Expand Up @@ -565,8 +565,8 @@
<input name ="frequencies" id='seq.freqs' spec='Frequencies' data="@alignment"/>
</substModel>
</siteModel>
<branchRateModel spec='beast.evolution.branchratemodel.UCRelaxedClockModel' id="branchRates">
<distr id='discreteormal' spec="beast.math.distributions.LogNormalDistributionModel" meanInRealSpace='true'>
<branchRateModel spec='beast.base.evolution.branchratemodel.UCRelaxedClockModel' id="branchRates">
<distr id='discreteormal' spec="beast.base.inference.distribution.LogNormalDistributionModel" meanInRealSpace='true'>
<parameter name='M' id='ucld.mean' value="0.0040" lower="0.0" upper="100.0"/>
<parameter name='S' id='ucld.stdev' value="0.1" lower="0.0" upper="10.0"/>
</distr>
Expand All @@ -576,14 +576,14 @@
</distribution>

<!-- b/(d+s) -->
<RPNcalculator spec="beast.math.statistic.RPNcalculator" id="actualGeoRates" expression="relativeGeoRates rateIndicator *">
<RPNcalculator spec="beast.base.inference.util.RPNcalculator" id="actualGeoRates" expression="relativeGeoRates rateIndicator *">
<parameter idref="relativeGeoRates"/>
<parameter idref="rateIndicator"/>
</RPNcalculator>

<ParameterCumSum spec="beast.core.util.Sum" id="nonZeroRates" arg="@rateIndicator"/>

<tree spec='beast.util.ClusterTree' id='tree' clusterType='upgma' trait="@tipDates">
<ParameterCumSum spec="beast.base.evolution.Sum" id="nonZeroRates" arg="@rateIndicator"/>

<tree spec='beast.base.evolution.tree.ClusterTree' id='tree' clusterType='upgma' trait="@tipDates">
<input name='taxa' idref='alignment'/>
</tree>

Expand Down Expand Up @@ -611,26 +611,26 @@

<distribution spec='CompoundDistribution' id='posterior'>
<distribution spec='CompoundDistribution' id='prior'>
<distribution x="@constant.popSize" id="popSizePrior" spec='beast.math.distributions.Prior'>
<distr spec='beast.math.distributions.OneOnX' id='popSizePrior_OneOnX'/>
<distribution x="@constant.popSize" id="popSizePrior" spec='beast.base.inference.distribution.Prior'>
<distr spec='beast.base.inference.distribution.OneOnX' id='popSizePrior_OneOnX'/>
</distribution>
<distribution id="coalescent" spec="Coalescent">
<treeIntervals spec='TreeIntervals' id='TreeIntervals' tree='@tree'/>
<treeIntervals spec="beast.base.evolution.tree.TreeIntervals" id="beast.base.evolution.tree.TreeIntervals" tree='@tree'/>
<populationModel spec="ConstantPopulation" id='ConstantPopulation'>
<parameter name="popSize" id="constant.popSize" value="90." lower="0." upper="Infinity" />
</populationModel>
</distribution>

<!-- this is a cached prior in beast1 - necessary??? -->
<distribution id='discreteTraitPrior' x="@relativeGeoRates" spec='beast.math.distributions.Prior'>
<distr spec='beast.math.distributions.Gamma' alpha="1." beta="1." offset="0.0"/>
<distribution id='discreteTraitPrior' x="@relativeGeoRates" spec='beast.base.inference.distribution.Prior'>
<distr spec='beast.base.inference.distribution.Gamma' alpha="1." beta="1." offset="0.0"/>
</distribution>
<distribution x="@geoMutationRate" id="geoMuPrior" spec='beast.math.distributions.Prior'>
<distr spec='beast.math.distributions.Exponential' id='geoMuPrior_Exp' mean="1." offset="0.0"/>
<distribution x="@geoMutationRate" id="geoMuPrior" spec='beast.base.inference.distribution.Prior'>
<distr spec='beast.base.inference.distribution.Exponential' id='geoMuPrior_Exp' mean="1." offset="0.0"/>
</distribution>

<distribution x="@nonZeroRates" id="nonZeroRatePrior" spec='beast.math.distributions.Prior'>
<distr spec='beast.math.distributions.Poisson' id='nonZeroRatePrior_Poi' lambda="0.693" offset="6.0"/>
<distribution x="@nonZeroRates" id="nonZeroRatePrior" spec='beast.base.inference.distribution.Prior'>
<distr spec='beast.base.inference.distribution.Poisson' id='nonZeroRatePrior_Poi' lambda="0.693" offset="6.0"/>
</distribution>

</distribution>
Expand Down Expand Up @@ -667,7 +667,7 @@
<operator id='georateScaler' spec='ScaleOperator' scaleFactor="0.75" weight="30" parameter="@relativeGeoRates" scaleAllIndependently='true'/>
<!-- START BSSVS discrete traits -->
<operator spec="BitFlipOperator" id="indicatorFlip" parameter="@rateIndicator" weight="30"/>
<operator spec="BitFlipBSSVSOperator" id="BSSVSoperator" indicator="@rateIndicator" mu="@geoMutationRate" weight="30"/>
<operator spec="beastclassic.evolution.operators.BitFlipBSSVSOperator" id="BSSVSoperator" indicator="@rateIndicator" mu="@geoMutationRate" weight="30"/>
<!-- END BSSVS discrete traits -->
<!-- END discrete traits -->

Expand All @@ -681,13 +681,13 @@
<log idref="posterior"/>
<log idref="prior"/>
<log idref="likelihood"/>
<log id="treeModel.rootHeight" spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
<log id="treeModel.rootHeight" spec='beast.base.evolution.tree.TreeStatLogger' tree='@tree'/>
<log idref="constant.popSize"/>
<log idref="hky.kappa"/>
<log idref="gammaShape"/>
<log idref="ucld.mean"/>
<log idref="ucld.stdev"/>
<log id='rateStat' spec='beast.evolution.branchratemodel.RateStatistic' tree='@tree' branchratemodel='@branchRates'/>
<log id='rateStat' spec='beast.base.evolution.RateStatistic' tree='@tree' branchratemodel='@branchRates'/>
<!-- START discrete traits -->
<log idref="geoMutationRate"/>
<log idref="geoTreeLikelihood"/>
Expand All @@ -703,11 +703,14 @@
<log idref="geoTreeLikelihood"/>
<log idref="geoMutationRate"/>
<log idref="nonZeroRates"/>
<!--
<log id="geoSubstModelLogger" spec="SVSGeneralSubstitutionModelLogger" dataType="@location" model="@svs"/>
-->
<log idref="actualGeoRates"/>
</logger>

<logger logEvery="10000" fileName="H5N1_discrete_geo.$(seed).trees" mode='tree'>
<log spec='TreeWithTraitLogger' tree='@tree'>
<log spec='beastclassic.evolution.tree.TreeWithTraitLogger' tree='@tree'>
<metadata idref="posterior"/>
<metadata idref="geoTreeLikelihood"/>
<metadata idref="branchRates"/>
Expand All @@ -724,7 +727,7 @@
<log idref="geoTreeLikelihood"/>
<log idref="geoMutationRate"/>
<log idref="nonZeroRates"/>
<log spec='beast.evolution.tree.TreeHeightLogger' tree='@tree'/>
<log spec='beast.base.evolution.tree.TreeHeightLogger' tree='@tree'/>
<log idref="constant.popSize"/>
<log idref="ucld.mean"/>
<log idref="ucld.stdev"/>
Expand Down
Loading

0 comments on commit 82edb4f

Please sign in to comment.