From 7dc7bd977a6d95e7f8e2921843fab6c8f48c5459 Mon Sep 17 00:00:00 2001 From: rbouckaert Date: Wed, 5 Oct 2022 10:32:04 +1300 Subject: [PATCH] migrate to BEAST v2.7 --- build.xml | 76 +++++-------------- {templates => fxtemplates}/MGSM.xml | 28 +++---- .../likelihood/MGSMBeagleTreeLikelihood.java | 42 +++++----- .../sitemodel/MultiGammaSiteModel.java | 19 ++--- .../sitemodel/MultiGammaSiteModelPrior.java | 22 +++--- .../sitemodel/RelaxedGammaSiteModel.java | 25 +++--- src/test/0rg.xml | 42 +++++----- .../MGSBeagleTreeLikelihoodTest.java | 8 +- version.xml | 14 +++- 9 files changed, 125 insertions(+), 151 deletions(-) rename {templates => fxtemplates}/MGSM.xml (86%) rename src/{beast => mgsm}/evolution/likelihood/MGSMBeagleTreeLikelihood.java (97%) rename src/{beast => mgsm}/evolution/sitemodel/MultiGammaSiteModel.java (93%) rename src/{beast => mgsm}/evolution/sitemodel/MultiGammaSiteModelPrior.java (83%) rename src/{beast => mgsm}/evolution/sitemodel/RelaxedGammaSiteModel.java (95%) diff --git a/build.xml b/build.xml index 05f8980..4faafd9 100644 --- a/build.xml +++ b/build.xml @@ -17,7 +17,6 @@ - @@ -27,19 +26,27 @@ - + - + - + + + ** Required file version.xml does not exist. ** + + + + + + @@ -79,7 +86,7 @@ memorymaximumsize="1024m" source="1.8" target="1.8"> - + @@ -91,53 +98,10 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - @@ -145,7 +109,7 @@ - + @@ -192,7 +156,7 @@ @@ -200,7 +164,7 @@ - + @@ -217,16 +181,16 @@ - - + + - + - + diff --git a/templates/MGSM.xml b/fxtemplates/MGSM.xml similarity index 86% rename from templates/MGSM.xml rename to fxtemplates/MGSM.xml index 2f209bd..44d2306 100644 --- a/templates/MGSM.xml +++ b/fxtemplates/MGSM.xml @@ -1,14 +1,14 @@ + namespace='beast.app.beauti:beast.pkgmgmt:beast.base.core:beast.base.inference:beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:beast.pkgmgmt:beast.base.core:beast.base.inference.util:beast.evolution.nuc:beast.base.evolution.operator:beast.base.inference.operator:beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:beast.evolution:beast.base.math.distributions'> - + + @@ -16,14 +16,14 @@ - + - + ]]> @@ -52,11 +52,11 @@ - 0.5 - + @@ -73,8 +73,8 @@ - - + + @@ -85,7 +85,7 @@ - + ]]> diff --git a/src/beast/evolution/likelihood/MGSMBeagleTreeLikelihood.java b/src/mgsm/evolution/likelihood/MGSMBeagleTreeLikelihood.java similarity index 97% rename from src/beast/evolution/likelihood/MGSMBeagleTreeLikelihood.java rename to src/mgsm/evolution/likelihood/MGSMBeagleTreeLikelihood.java index e0f971c..3c592f5 100644 --- a/src/beast/evolution/likelihood/MGSMBeagleTreeLikelihood.java +++ b/src/mgsm/evolution/likelihood/MGSMBeagleTreeLikelihood.java @@ -23,7 +23,7 @@ * Boston, MA 02110-1301 USA */ -package beast.evolution.likelihood; +package mgsm.evolution.likelihood; import java.util.ArrayList; import java.util.List; @@ -34,17 +34,17 @@ import beagle.BeagleInfo; import beagle.InstanceDetails; import beagle.ResourceDetails; -import beast.core.CalculationNode; -import beast.core.Description; -import beast.core.util.Log; -import beast.evolution.alignment.Alignment; -import beast.evolution.branchratemodel.StrictClockModel; -import beast.evolution.likelihood.TreeLikelihood; -import beast.evolution.sitemodel.SiteModel; -import beast.evolution.sitemodel.SiteModelInterface.Base; -import beast.evolution.substitutionmodel.EigenDecomposition; -import beast.evolution.tree.Node; -import beast.evolution.tree.Tree; +import beast.base.inference.CalculationNode; +import beast.base.core.Description; +import beast.base.core.Log; +import beast.base.evolution.alignment.Alignment; +import beast.base.evolution.branchratemodel.StrictClockModel; +import beast.base.evolution.likelihood.TreeLikelihood; +import beast.base.evolution.sitemodel.SiteModel; +import beast.base.evolution.sitemodel.SiteModelInterface.Base; +import beast.base.evolution.substitutionmodel.EigenDecomposition; +import beast.base.evolution.tree.Node; +import beast.base.evolution.tree.Tree; /** @@ -63,7 +63,7 @@ public class MGSMBeagleTreeLikelihood extends TreeLikelihood { // allocate each BEAGLE instance to. If less than the number of instances then // will wrap around. // note: to use a different device, say device 2, start beast with - // java -Dbeagle.resource.order=2 beast.app.BeastMCMC + // java -Dbeagle.resource.order=2 beastfx.app.beast.BeastMCMC private static final String RESOURCE_ORDER_PROPERTY = "beagle.resource.order"; private static final String PREFERRED_FLAGS_PROPERTY = "beagle.preferred.flags"; private static final String REQUIRED_FLAGS_PROPERTY = "beagle.required.flags"; @@ -149,14 +149,14 @@ private boolean initialize() { break; } } - if (constantPattern != null && constantPattern.size() > dataInput.get().getPatternCount()) { + if (getConstantPattern() != null && getConstantPattern().size() > dataInput.get().getPatternCount()) { // if there are many more constant patterns than patterns (each pattern can // have a number of constant patters, one for each state) it is less efficient // to just calculate the TreeLikelihood for constant sites than optimising Log.debug("switch off constant sites optimisiation: calculating through separate TreeLikelihood category (as in the olden days)"); invariantCategory = -1; proportionInvariant = 0; - constantPattern = null; + setConstantPattern(null); categoryRates = m_siteModel.getCategoryRates(null); } } @@ -539,7 +539,7 @@ protected boolean requiresRecalculation() { if (hasNodeIndependentCategories(m_siteModel)) { double[] categoryRates = m_siteModel.getCategoryRates(null); - if (constantPattern != null) { + if (getConstantPattern() != null) { double [] tmp = new double [categoryRates.length - 1]; for (int k = 0; k < invariantCategory; k++) { tmp[k] = categoryRates[k]; @@ -693,7 +693,7 @@ public double calculateLogP() { if (updateSiteModel) { if (hasNodeIndependentCategories(m_siteModel)) { double[] categoryRates = m_siteModel.getCategoryRates(null); - if (constantPattern != null) { + if (getConstantPattern() != null) { double [] tmp = new double [categoryRates.length - 1]; for (int k = 0; k < invariantCategory; k++) { tmp[k] = categoryRates[k]; @@ -773,7 +773,7 @@ public double calculateLogP() { int rootIndex = partialBufferHelper.getOffsetIndex(root.getNr()); double[] categoryWeights = m_siteModel.getCategoryProportions(null); - if (constantPattern != null) { + if (getConstantPattern() != null) { double [] tmp = new double [categoryWeights.length - 1]; for (int k = 0; k < invariantCategory; k++) { tmp[k] = categoryWeights[k]; @@ -834,7 +834,7 @@ public double calculateLogP() { proportionInvariant = m_siteModel.getProportionInvariant(); - for (int k : constantPattern) { + for (int k : getConstantPattern()) { int i = k / m_nStateCount; int j = k % m_nStateCount; patternLogLikelihoods[i] = (Math.log(Math.exp(patternLogLikelihoods[i]) + proportionInvariant * frequencies[j])); @@ -911,9 +911,9 @@ private double getAscertainmentCorrectedLogLikelihood(Alignment patternList, double[] patternLogLikelihoods, int[] patternWeights, double [] frequencies) { - if (constantPattern != null) { + if (getConstantPattern() != null) { proportionInvariant = m_siteModel.getProportionInvariant(); - for (int k : constantPattern) { + for (int k : getConstantPattern()) { int i = k / m_nStateCount; int j = k % m_nStateCount; patternLogLikelihoods[i] = (Math.log(Math.exp(patternLogLikelihoods[i]) + proportionInvariant * frequencies[j])); diff --git a/src/beast/evolution/sitemodel/MultiGammaSiteModel.java b/src/mgsm/evolution/sitemodel/MultiGammaSiteModel.java similarity index 93% rename from src/beast/evolution/sitemodel/MultiGammaSiteModel.java rename to src/mgsm/evolution/sitemodel/MultiGammaSiteModel.java index 04faccf..1525348 100644 --- a/src/beast/evolution/sitemodel/MultiGammaSiteModel.java +++ b/src/mgsm/evolution/sitemodel/MultiGammaSiteModel.java @@ -1,16 +1,17 @@ -package beast.evolution.sitemodel; +package mgsm.evolution.sitemodel; import org.apache.commons.math.distribution.GammaDistribution; import org.apache.commons.math.distribution.GammaDistributionImpl; -import beast.core.Description; -import beast.core.Input; -import beast.core.Input.Validate; -import beast.core.parameter.RealParameter; -import beast.core.util.Log; -import beast.evolution.likelihood.MGSMBeagleTreeLikelihood; -import beast.evolution.tree.Node; -import beast.evolution.tree.Tree; +import beast.base.core.Description; +import beast.base.core.Input; +import beast.base.core.Input.Validate; +import beast.base.inference.parameter.RealParameter; +import mgsm.evolution.likelihood.MGSMBeagleTreeLikelihood; +import beast.base.core.Log; +import beast.base.evolution.sitemodel.SiteModel; +import beast.base.evolution.tree.Node; +import beast.base.evolution.tree.Tree; @Description("Gamma site model that allows different shape parameters for each branche") public class MultiGammaSiteModel extends SiteModel { diff --git a/src/beast/evolution/sitemodel/MultiGammaSiteModelPrior.java b/src/mgsm/evolution/sitemodel/MultiGammaSiteModelPrior.java similarity index 83% rename from src/beast/evolution/sitemodel/MultiGammaSiteModelPrior.java rename to src/mgsm/evolution/sitemodel/MultiGammaSiteModelPrior.java index 99a56eb..e5c1ad9 100644 --- a/src/beast/evolution/sitemodel/MultiGammaSiteModelPrior.java +++ b/src/mgsm/evolution/sitemodel/MultiGammaSiteModelPrior.java @@ -1,18 +1,18 @@ -package beast.evolution.sitemodel; +package mgsm.evolution.sitemodel; import java.util.List; import java.util.Random; -import beast.core.Description; -import beast.core.Distribution; -import beast.core.Input; -import beast.core.State; -import beast.core.Input.Validate; -import beast.core.parameter.IntegerParameter; -import beast.core.parameter.Parameter; -import beast.core.parameter.RealParameter; -import beast.evolution.tree.Node; -import beast.evolution.tree.Tree; +import beast.base.core.Description; +import beast.base.inference.Distribution; +import beast.base.core.Input; +import beast.base.inference.State; +import beast.base.core.Input.Validate; +import beast.base.inference.parameter.IntegerParameter; +import beast.base.inference.parameter.Parameter; +import beast.base.inference.parameter.RealParameter; +import beast.base.evolution.tree.Node; +import beast.base.evolution.tree.Tree; @Description("Prior on gammashape parameters for Multi-Gamma Site Model to ensure branches from root " + "have identical gamma shape (this is required in order to prevent identifiability issues)") diff --git a/src/beast/evolution/sitemodel/RelaxedGammaSiteModel.java b/src/mgsm/evolution/sitemodel/RelaxedGammaSiteModel.java similarity index 95% rename from src/beast/evolution/sitemodel/RelaxedGammaSiteModel.java rename to src/mgsm/evolution/sitemodel/RelaxedGammaSiteModel.java index e906fdd..a4faf27 100644 --- a/src/beast/evolution/sitemodel/RelaxedGammaSiteModel.java +++ b/src/mgsm/evolution/sitemodel/RelaxedGammaSiteModel.java @@ -1,4 +1,4 @@ -package beast.evolution.sitemodel; +package mgsm.evolution.sitemodel; import java.io.PrintStream; @@ -7,17 +7,18 @@ import org.apache.commons.math.distribution.GammaDistribution; import org.apache.commons.math.distribution.GammaDistributionImpl; -import beast.core.Description; -import beast.core.Function; -import beast.core.Input; -import beast.core.Loggable; -import beast.core.Input.Validate; -import beast.core.parameter.IntegerParameter; -import beast.core.util.Log; -import beast.evolution.likelihood.MGSMBeagleTreeLikelihood; -import beast.evolution.tree.Node; -import beast.evolution.tree.Tree; -import beast.math.distributions.ParametricDistribution; +import beast.base.core.Description; +import beast.base.core.Function; +import beast.base.core.Input; +import beast.base.core.Loggable; +import beast.base.core.Input.Validate; +import beast.base.inference.parameter.IntegerParameter; +import mgsm.evolution.likelihood.MGSMBeagleTreeLikelihood; +import beast.base.core.Log; +import beast.base.evolution.sitemodel.SiteModel; +import beast.base.evolution.tree.Node; +import beast.base.evolution.tree.Tree; +import beast.base.inference.distribution.ParametricDistribution; @Description("Uncorrelated Relaxed Gamma site model that allows different shape parameters for each branche") public class RelaxedGammaSiteModel extends SiteModel implements Loggable, Function { diff --git a/src/test/0rg.xml b/src/test/0rg.xml index 7f87b5c..f0ec2e7 100644 --- a/src/test/0rg.xml +++ b/src/test/0rg.xml @@ -1,4 +1,4 @@ - + -beast.math.distributions.Uniform -beast.math.distributions.Exponential -beast.math.distributions.LogNormalDistributionModel -beast.math.distributions.Normal -beast.math.distributions.Beta -beast.math.distributions.Gamma -beast.math.distributions.LaplaceDistribution -beast.math.distributions.Prior -beast.math.distributions.InverseGamma -beast.math.distributions.OneOnX +beast.base.inference.distribution.Uniform +beast.base.inference.distribution.Exponential +beast.base.inference.distribution.LogNormalDistributionModel +beast.base.inference.distribution.Normal +beast.base.inference.distribution.Beta +beast.base.inference.distribution.Gamma +beast.base.inference.distribution.LaplaceDistribution +beast.base.inference.distribution.Prior +beast.base.inference.distribution.InverseGamma +beast.base.inference.distribution.OneOnX @@ -52,15 +52,15 @@ name="alignment"> 1 - + 1.0 - - - + + + 1.0 @@ -82,7 +82,7 @@ name="alignment"> - + @@ -90,7 +90,7 @@ name="alignment"> 0.0 - + 1.0 @@ -99,7 +99,7 @@ name="alignment"> - + @@ -152,11 +152,11 @@ name="alignment"> - + - + @@ -169,7 +169,7 @@ name="alignment"> - + diff --git a/src/test/evolution/likelihood/MGSBeagleTreeLikelihoodTest.java b/src/test/evolution/likelihood/MGSBeagleTreeLikelihoodTest.java index dca6296..53952a2 100644 --- a/src/test/evolution/likelihood/MGSBeagleTreeLikelihoodTest.java +++ b/src/test/evolution/likelihood/MGSBeagleTreeLikelihoodTest.java @@ -4,9 +4,9 @@ import org.junit.Test; -import beast.core.Logger; -import beast.util.LogAnalyser; -import beast.util.XMLParser; +import beast.base.inference.Logger; +import beastfx.app.tools.LogAnalyser; +import beast.base.parser.XMLParser; import junit.framework.TestCase; public class MGSBeagleTreeLikelihoodTest extends TestCase{ @@ -14,7 +14,7 @@ public class MGSBeagleTreeLikelihoodTest extends TestCase{ @Test public void testBeagleTreeLikelihood() throws Exception { XMLParser parser = new XMLParser(); - beast.core.Runnable runable = parser.parseFile(new File("src/test/0rg.xml")); + beast.base.inference.Runnable runable = parser.parseFile(new File("src/test/0rg.xml")); Logger.FILE_MODE = Logger.LogFileMode.overwrite; runable.run(); diff --git a/version.xml b/version.xml index d6e2115..dc22876 100644 --- a/version.xml +++ b/version.xml @@ -1,3 +1,11 @@ - - - + + + + + + + + + + +