├── .github └── workflows │ ├── beauti.yml │ └── core.yml ├── .gitignore ├── COPYING ├── Dockerfile ├── README.md ├── build-testing.xml ├── build.xml ├── examples ├── beast2vs1 │ ├── beast1 │ │ ├── testBSP1.xml │ │ ├── testBSPNoClock.xml │ │ ├── testBirthDeathAsYule.xml │ │ ├── testBirthDeathModel_10taxa.xml │ │ ├── testCalibration.xml │ │ ├── testCoalescent.xml │ │ ├── testCoalescentNoClock.xml │ │ ├── testCoalescentNoClock1.xml │ │ ├── testEBSP.xml │ │ ├── testExponentialGrowth.xml │ │ ├── testMCMC.xml │ │ ├── testMultiSubstModel.xml │ │ ├── testRandomLocalClock.xml │ │ ├── testSRD06CP12_3.xml │ │ ├── testSiteModelAlpha.xml │ │ ├── testStarBEASTConstant.xml │ │ ├── testStarBEASTLinear.xml │ │ ├── testStarBEASTLinearConstRoot.xml │ │ ├── testStrictClockNoDate.xml │ │ ├── testStrictClockNoDate2.xml │ │ ├── testStrictClockTipDatesSampling.xml │ │ ├── testStrictClockTipTime.xml │ │ ├── testUCRelaxedClockLogNormal.xml │ │ ├── testYule.xml │ │ └── testYuleModel_10taxa.xml │ ├── testBSP1.xml │ ├── testBSPNoClock.xml │ ├── testBirthDeathAsYule.xml │ ├── testBirthDeathModel_10taxa.xml │ ├── testCalibration.xml │ ├── testCalibrationMono.xml │ ├── testCoalescentNoClock.xml │ ├── testCoalescentNoClock1.xml │ ├── testCoalescentTipDates.xml │ ├── testCoalescentTipDates1.xml │ ├── testCoalescentTipDatesSampling.xml │ ├── testEBSP.xml │ ├── testExponentialGrowth.xml │ ├── testHKY.xml │ ├── testMultiSubstModel.xml │ ├── testRandomLocalClock.xml │ ├── testSRD06CP12_3.xml │ ├── testSiteModelAlpha.xml │ ├── testStarBEAST.xml │ ├── testStarBEASTConstant.xml │ ├── testStarBEASTLinear.xml │ ├── testStarBEASTLinearConstRoot.xml │ ├── testStarBeast2.xml │ ├── testStrictClock.xml │ ├── testStrictClock2.xml │ ├── testStrictClockTipDatesSampling.xml │ ├── testStrictClockTipTime.xml │ ├── testTipDates.xml │ ├── testUCRelaxedClockLogNormal.xml │ └── testYuleModel_10taxa.xml ├── benchmark │ ├── 1 │ │ ├── experiment.sh │ │ ├── testHKY1044.xml │ │ ├── testHKY1366.xml │ │ ├── testHKY1510.xml │ │ ├── testHKY1748.xml │ │ ├── testHKY1749.xml │ │ ├── testHKY1809.xml │ │ ├── testHKY336.xml │ │ ├── testHKY3475.xml │ │ ├── testHKY501.xml │ │ ├── testHKY520.xml │ │ ├── testHKY755.xml │ │ └── testHKY767.xml │ ├── II │ │ ├── experiment.sh │ │ ├── testHKY1044.xml │ │ ├── testHKY1366.xml │ │ ├── testHKY1510.xml │ │ ├── testHKY1748.xml │ │ ├── testHKY1749.xml │ │ ├── testHKY1809.xml │ │ ├── testHKY336.xml │ │ ├── testHKY3475.xml │ │ ├── testHKY501.xml │ │ ├── testHKY520.xml │ │ ├── testHKY755.xml │ │ └── testHKY767.xml │ └── mrbayes │ │ ├── experiment.sh │ │ ├── run1044.nex │ │ ├── run1366.nex │ │ ├── run1510.nex │ │ ├── run1748.nex │ │ ├── run1749.nex │ │ ├── run1809.nex │ │ ├── run336.nex │ │ ├── run3475.nex │ │ ├── run501.nex │ │ ├── run520.nex │ │ ├── run755.nex │ │ ├── run767.nex │ │ ├── testHKY1044.nex │ │ ├── testHKY1366.nex │ │ ├── testHKY1510.nex │ │ ├── testHKY1748.nex │ │ ├── testHKY1749.nex │ │ ├── testHKY1809.nex │ │ ├── testHKY336.nex │ │ ├── testHKY3475.nex │ │ ├── testHKY501.nex │ │ ├── testHKY520.nex │ │ ├── testHKY755.nex │ │ └── testHKY767.nex ├── bitflip.xml ├── fasta │ ├── E15-binary.fasta │ ├── aminoacid.fasta │ └── dna.fasta ├── nexus │ ├── 26.nex │ ├── 29.nex │ ├── 47.nex │ ├── 53.nex │ ├── 59.nex │ ├── 64.nex │ ├── 72.nex │ ├── Darwins-finches.nex │ ├── Dengue4.env.nex │ ├── FPV.nex │ ├── Flu.nex │ ├── M243.nex │ ├── ML_analysis.nex │ ├── MP_analysis.nex │ ├── Primates.nex │ ├── RSV2.nex │ ├── Shankarappa.Patient9.nex │ ├── angiosperms.nex │ ├── anolis.nex │ ├── anolis.nex_phyml_stats.txt │ ├── anolis.nex_phyml_tree.txt │ ├── avian-ovomucoids.nex │ ├── dna.nex │ ├── gopher.nex │ ├── humanChimpSNP.nex │ ├── maddison.nex │ ├── old.nex │ ├── primate-mtDNA-interleaved.nex │ ├── primate-mtDNA.nex │ ├── primate-mtDNA.nex~ │ ├── protein.nex │ ├── ringe.nex │ ├── ringe.nex~ │ ├── seaview.nxs │ ├── traitlab.nex │ └── x.nex ├── parameterised │ ├── README.md │ ├── RSV2.json │ └── RSV2.xml ├── ringe_ctmc.xml.state ├── starbeastinit │ ├── sbi-01.xml │ ├── sbi-02.xml │ └── sbi-03.xml ├── testBSP.xml ├── testCalYule_5t_2c.xml ├── testCalibration.xml ├── testClassicRootCalibrationPrior.xml ├── testCoalescent.xml ├── testConditionalRootCalibrationPrior.xml ├── testDirectSimulator.xml ├── testDirectSimulator2.xml ├── testDirectSimulatorHierarchical.xml ├── testEBSP.xml ├── testExponentialGrowth.xml ├── testGTR.xml ├── testHKY.json ├── testHKY.xml ├── testHKY.xml~ ├── testJukesCantor.xml ├── testJukesCantorShort.xml ├── testJukesCantorShortUncertain.xml ├── testJukesCantorShortUncertain2.xml ├── testJukesCantorShortUncertain2MLE.xml ├── testMultipleAlignments_randomTaxaOrder.xml ├── testOpSubSchedule.xml ├── testPlates.xml ├── testRNA.xml ├── testRandomLocalClock.xml ├── testRelaxedClock.xml ├── testRestrictedGTR.xml ├── testSRD06.xml ├── testSYM.xml ├── testSeqGen.xml ├── testSimulatedAlignment.xml ├── testSliceHKY.xml ├── testStarBeast.xml ├── testStarBeastFBD.xml ├── testTIM.xml ├── testTIM.xml.state ├── testTN93.xml ├── testTVM.xml ├── testTipDates.xml ├── testTipDates2.xml ├── testTwoCalibrationsPrior.xml ├── testUCLNclock.json ├── testYuleCalibrated.xml ├── testYuleOneSite.xml └── testYuleUncalibrated.xml ├── lib ├── antlr-runtime-4.10.1.jar ├── beagle.jar ├── bundler │ ├── jarbundler-core-3.3.0.jar │ └── jsign-3.1.jar ├── colt.jar ├── commons-math3-3.6.1.jar └── junit │ └── junit-platform-console-standalone-1.8.2.jar ├── release ├── Linux │ └── jrebin │ │ ├── applauncher │ │ ├── beast │ │ ├── beauti │ │ ├── densitree │ │ ├── loganalyser │ │ ├── logcombiner │ │ ├── packagemanager │ │ └── treeannotator ├── Mac │ ├── README.md │ ├── createdmg.sh │ ├── install.png │ ├── launch.c │ ├── universalJavaApplicationJREStub │ └── universalJavaApplicationStub ├── Windows │ ├── AppLauncher_launch4j.xml │ ├── AppLauncher_launch4j_jre.xml │ ├── BEAST_launch4j.xml │ ├── BEAST_launch4j_jre.xml │ ├── BEAUti_launch4j.xml │ ├── BEAUti_launch4j_jre.xml │ ├── LogCombiner_launch4j.xml │ ├── LogCombiner_launch4j_jre.xml │ ├── TreeAnnotator_launch4j.xml │ ├── TreeAnnotator_launch4j_jre.xml │ ├── bat │ │ ├── applauncher.bat │ │ ├── beast.bat │ │ ├── beauti.bat │ │ ├── loganalyser.bat │ │ ├── logcombiner.bat │ │ ├── packagemanager.bat │ │ └── treeannotator.bat │ └── windowsCertificationNotes.txt └── common │ ├── LICENSE.txt │ ├── README.txt │ ├── VERSION HISTORY.txt │ ├── icons │ ├── beast.icns │ ├── beast.ico │ ├── beast.png │ ├── beauti.icns │ ├── beauti.ico │ ├── beauti.png │ ├── utility.icns │ ├── utility.ico │ └── utility.png │ └── tools │ ├── DensiTree.icns │ ├── DensiTree.ico │ ├── DensiTree.jar │ ├── DensiTree.png │ ├── DensiTree_launch4j.xml │ └── DensiTree_launch4j_jre.xml ├── scripts ├── doc.pl ├── migrate.md └── migrate.pl ├── src ├── beast │ ├── base │ │ ├── CudaDetector.java │ │ ├── core │ │ │ ├── BEASTInterface.java │ │ │ ├── BEASTObject.java │ │ │ ├── BEASTObjectStore.java │ │ │ ├── BEASTVersion2.java │ │ │ ├── Citable.java │ │ │ ├── Citation.java │ │ │ ├── Description.java │ │ │ ├── Function.java │ │ │ ├── Input.java │ │ │ ├── InputForAnnotatedConstructor.java │ │ │ ├── Log.java │ │ │ ├── Loggable.java │ │ │ ├── Param.java │ │ │ ├── ProgramStatus.java │ │ │ └── VirtualBEASTObject.java │ │ ├── evolution │ │ │ ├── RateStatistic.java │ │ │ ├── Sum.java │ │ │ ├── TreeWithMetaDataLogger.java │ │ │ ├── alignment │ │ │ │ ├── Alignment.java │ │ │ │ ├── AscertainedAlignment.java │ │ │ │ ├── FilteredAlignment.java │ │ │ │ ├── Sequence.java │ │ │ │ ├── Taxon.java │ │ │ │ ├── TaxonSet.java │ │ │ │ └── TreeTipData.java │ │ │ ├── branchratemodel │ │ │ │ ├── BranchRateModel.java │ │ │ │ ├── RandomLocalClockModel.java │ │ │ │ ├── StrictClockModel.java │ │ │ │ └── UCRelaxedClockModel.java │ │ │ ├── datatype │ │ │ │ ├── Aminoacid.java │ │ │ │ ├── Binary.java │ │ │ │ ├── DataType.java │ │ │ │ ├── IntegerData.java │ │ │ │ ├── Nucleotide.java │ │ │ │ ├── StandardData.java │ │ │ │ ├── TwoStateCovarion.java │ │ │ │ └── UserDataType.java │ │ │ ├── distance │ │ │ │ ├── Distance.java │ │ │ │ ├── F84Distance.java │ │ │ │ ├── HammingDistance.java │ │ │ │ ├── JukesCantorDistance.java │ │ │ │ └── SMMDistance.java │ │ │ ├── likelihood │ │ │ │ ├── BeagleTreeLikelihood.java │ │ │ │ ├── BeerLikelihoodCore.java │ │ │ │ ├── BeerLikelihoodCore4.java │ │ │ │ ├── GenericTreeLikelihood.java │ │ │ │ ├── LikelihoodCore.java │ │ │ │ ├── ThreadedBeerLikelihoodCore.java │ │ │ │ ├── ThreadedBeerLikelihoodCore4.java │ │ │ │ ├── ThreadedLikelihoodCore.java │ │ │ │ ├── ThreadedTreeLikelihood.java │ │ │ │ └── TreeLikelihood.java │ │ │ ├── operator │ │ │ │ ├── AdaptableOperatorSampler.java │ │ │ │ ├── EpochFlexOperator.java │ │ │ │ ├── Exchange.java │ │ │ │ ├── NodeReheight.java │ │ │ │ ├── ScaleOperator.java │ │ │ │ ├── SubtreeSlide.java │ │ │ │ ├── TipDatesRandomWalker.java │ │ │ │ ├── TipDatesScaler.java │ │ │ │ ├── TreeOperator.java │ │ │ │ ├── TreeStretchOperator.java │ │ │ │ ├── Uniform.java │ │ │ │ ├── WilsonBalding.java │ │ │ │ └── kernel │ │ │ │ │ ├── AdaptableVarianceMultivariateNormalOperator.java │ │ │ │ │ ├── BactrianNodeOperator.java │ │ │ │ │ ├── BactrianOperatorSchedule.java │ │ │ │ │ ├── BactrianScaleOperator.java │ │ │ │ │ ├── BactrianSubtreeSlide.java │ │ │ │ │ └── BactrianTipDatesRandomWalker.java │ │ │ ├── sitemodel │ │ │ │ ├── SiteModel.java │ │ │ │ └── SiteModelInterface.java │ │ │ ├── speciation │ │ │ │ ├── BirthDeathGernhard08Model.java │ │ │ │ ├── CalibratedBirthDeathModel.java │ │ │ │ ├── CalibratedYuleInitialTree.java │ │ │ │ ├── CalibratedYuleModel.java │ │ │ │ ├── CalibrationLineagesIterator.java │ │ │ │ ├── CalibrationPoint.java │ │ │ │ ├── GeneTreeForSpeciesTreeDistribution.java │ │ │ │ ├── RandomGeneTree.java │ │ │ │ ├── SpeciesTreeDistribution.java │ │ │ │ ├── SpeciesTreeLogger.java │ │ │ │ ├── SpeciesTreePopFunction.java │ │ │ │ ├── SpeciesTreePrior.java │ │ │ │ ├── StarBeastStartState.java │ │ │ │ ├── TreeTopFinder.java │ │ │ │ └── YuleModel.java │ │ │ ├── substitutionmodel │ │ │ │ ├── BinaryCovarion.java │ │ │ │ ├── Blosum62.java │ │ │ │ ├── CPREV.java │ │ │ │ ├── ColtEigenSystem.java │ │ │ │ ├── ComplexColtEigenSystem.java │ │ │ │ ├── ComplexSubstitutionModel.java │ │ │ │ ├── Dayhoff.java │ │ │ │ ├── DefaultEigenSystem.java │ │ │ │ ├── EigenDecomposition.java │ │ │ │ ├── EigenSystem.java │ │ │ │ ├── EmpiricalSubstitutionModel.java │ │ │ │ ├── Frequencies.java │ │ │ │ ├── GTR.java │ │ │ │ ├── GeneralSubstitutionModel.java │ │ │ │ ├── HKY.java │ │ │ │ ├── JTT.java │ │ │ │ ├── JukesCantor.java │ │ │ │ ├── MTREV.java │ │ │ │ ├── MutationDeathModel.java │ │ │ │ ├── SYM.java │ │ │ │ ├── SubstitutionModel.java │ │ │ │ ├── TIM.java │ │ │ │ ├── TN93.java │ │ │ │ ├── TVM.java │ │ │ │ └── WAG.java │ │ │ └── tree │ │ │ │ ├── CladeSet.java │ │ │ │ ├── ClusterTree.java │ │ │ │ ├── IntervalList.java │ │ │ │ ├── IntervalType.java │ │ │ │ ├── MRCAPrior.java │ │ │ │ ├── Node.java │ │ │ │ ├── TraitSet.java │ │ │ │ ├── Tree.java │ │ │ │ ├── TreeDistribution.java │ │ │ │ ├── TreeHeightLogger.java │ │ │ │ ├── TreeInterface.java │ │ │ │ ├── TreeIntervals.java │ │ │ │ ├── TreeMetric.java │ │ │ │ ├── TreeParser.java │ │ │ │ ├── TreeStatLogger.java │ │ │ │ ├── TreeUtils.java │ │ │ │ ├── coalescent │ │ │ │ ├── BayesianSkyline.java │ │ │ │ ├── Coalescent.java │ │ │ │ ├── CompoundPopulationFunction.java │ │ │ │ ├── ConstantPopulation.java │ │ │ │ ├── ExponentialGrowth.java │ │ │ │ ├── PopulationFunction.java │ │ │ │ ├── RandomTree.java │ │ │ │ ├── SampleOffValues.java │ │ │ │ └── ScaledPopulationFunction.java │ │ │ │ └── treeparser │ │ │ │ ├── NewickLexer.g4 │ │ │ │ ├── NewickLexer.java │ │ │ │ ├── NewickParser.g4 │ │ │ │ ├── NewickParser.java │ │ │ │ ├── NewickParserBaseListener.java │ │ │ │ ├── NewickParserBaseVisitor.java │ │ │ │ ├── NewickParserListener.java │ │ │ │ ├── NewickParserVisitor.java │ │ │ │ └── README │ │ ├── inference │ │ │ ├── CalculationNode.java │ │ │ ├── CompoundDistribution.java │ │ │ ├── DirectSimulator.java │ │ │ ├── Distribution.java │ │ │ ├── Evaluator.java │ │ │ ├── Logger.java │ │ │ ├── MCMC.java │ │ │ ├── ModelLogger.java │ │ │ ├── Operator.java │ │ │ ├── OperatorSchedule.java │ │ │ ├── Runnable.java │ │ │ ├── State.java │ │ │ ├── StateNode.java │ │ │ ├── StateNodeInitialiser.java │ │ │ ├── distribution │ │ │ │ ├── Beta.java │ │ │ │ ├── ChiSquare.java │ │ │ │ ├── Dirichlet.java │ │ │ │ ├── Exponential.java │ │ │ │ ├── Gamma.java │ │ │ │ ├── InverseGamma.java │ │ │ │ ├── LaplaceDistribution.java │ │ │ │ ├── LogNormal.java │ │ │ │ ├── LogNormalDistributionModel.java │ │ │ │ ├── MarkovChainDistribution.java │ │ │ │ ├── Normal.java │ │ │ │ ├── OneOnX.java │ │ │ │ ├── ParametricDistribution.java │ │ │ │ ├── Poisson.java │ │ │ │ ├── Prior.java │ │ │ │ └── Uniform.java │ │ │ ├── operator │ │ │ │ ├── BitFlipOperator.java │ │ │ │ ├── CompoundParameterHelper.java │ │ │ │ ├── DeltaExchangeOperator.java │ │ │ │ ├── IntRandomWalkOperator.java │ │ │ │ ├── IntUniformOperator.java │ │ │ │ ├── JointOperator.java │ │ │ │ ├── RealRandomWalkOperator.java │ │ │ │ ├── SliceOperator.java │ │ │ │ ├── SwapOperator.java │ │ │ │ ├── UniformOperator.java │ │ │ │ ├── UpDownOperator.java │ │ │ │ └── kernel │ │ │ │ │ ├── BactrianDeltaExchangeOperator.java │ │ │ │ │ ├── BactrianIntervalOperator.java │ │ │ │ │ ├── BactrianRandomWalkOperator.java │ │ │ │ │ ├── BactrianUpDownOperator.java │ │ │ │ │ ├── KernelDistribution.java │ │ │ │ │ ├── KernelOperator.java │ │ │ │ │ └── Transform.java │ │ │ ├── parameter │ │ │ │ ├── BooleanParameter.java │ │ │ │ ├── BooleanParameterList.java │ │ │ │ ├── CompoundRealParameter.java │ │ │ │ ├── CompoundValuable.java │ │ │ │ ├── GeneralParameterList.java │ │ │ │ ├── IntegerParameter.java │ │ │ │ ├── IntegerParameterList.java │ │ │ │ ├── Map.java │ │ │ │ ├── Parameter.java │ │ │ │ ├── RealParameter.java │ │ │ │ └── RealParameterList.java │ │ │ └── util │ │ │ │ ├── ESS.java │ │ │ │ ├── InputUtil.java │ │ │ │ ├── RPNcalculator.java │ │ │ │ └── RPNexpressionCalculator.java │ │ ├── math │ │ │ ├── LogTricks.java │ │ │ ├── MathUtils.java │ │ │ └── matrixalgebra │ │ │ │ ├── CholeskyDecomposition.java │ │ │ │ ├── IllegalDimension.java │ │ │ │ ├── LUPDecomposition.java │ │ │ │ ├── LinearEquations.java │ │ │ │ ├── Matrix.java │ │ │ │ ├── NonSymmetricComponents.java │ │ │ │ ├── RobustEigenDecomposition.java │ │ │ │ ├── RobustSingularValueDecomposition.java │ │ │ │ ├── SymmetricMatrix.java │ │ │ │ └── Vector.java │ │ ├── parser │ │ │ ├── ClassToPackageMap.java │ │ │ ├── InputType.java │ │ │ ├── JSONParser.java │ │ │ ├── JSONParserException.java │ │ │ ├── JSONProducer.java │ │ │ ├── NexusParser.java │ │ │ ├── NexusParserListener.java │ │ │ ├── OutputUtils.java │ │ │ ├── PartitionContext.java │ │ │ ├── XMLModelLogger.java │ │ │ ├── XMLParser.java │ │ │ ├── XMLParserException.java │ │ │ ├── XMLParserUtils.java │ │ │ └── XMLProducer.java │ │ └── util │ │ │ ├── Binomial.java │ │ │ ├── CollectionUtils.java │ │ │ ├── CredibleSet.java │ │ │ ├── DiscreteStatistics.java │ │ │ ├── FileUtils.java │ │ │ ├── FrequencySet.java │ │ │ ├── GammaFunction.java │ │ │ ├── HeapSort.java │ │ │ ├── MachineAccuracy.java │ │ │ ├── MersenneTwisterFast.java │ │ │ └── Randomizer.java │ └── pkgmgmt │ │ ├── Arguments.java │ │ ├── BEASTClassLoader.java │ │ ├── BEASTVersion.java │ │ ├── MultiParentURLClassLoader.java │ │ ├── Package.java │ │ ├── PackageDependency.java │ │ ├── PackageManager.java │ │ ├── PackageVersion.java │ │ ├── Utils6.java │ │ ├── Version.java │ │ ├── icons │ │ └── beauti.png │ │ └── launcher │ │ ├── AppLauncherLauncher.java │ │ ├── BeastLauncher.java │ │ ├── BeautiLauncher.java │ │ ├── LogCombinerLauncher.java │ │ └── TreeAnnotatorLauncher.java └── org │ ├── apache │ └── commons │ │ └── math │ │ ├── ConvergenceException.java │ │ ├── ConvergingAlgorithm.java │ │ ├── ConvergingAlgorithmImpl.java │ │ ├── FunctionEvaluationException.java │ │ ├── MathConfigurationException.java │ │ ├── MathException.java │ │ ├── MathRuntimeException.java │ │ ├── MaxEvaluationsExceededException.java │ │ ├── MaxIterationsExceededException.java │ │ ├── analysis │ │ ├── BinaryFunction.java │ │ ├── BivariateRealFunction.java │ │ ├── ComposableFunction.java │ │ ├── DifferentiableUnivariateRealFunction.java │ │ ├── MultivariateRealFunction.java │ │ ├── UnivariateRealFunction.java │ │ ├── integration │ │ │ ├── RombergIntegrator.java │ │ │ ├── TrapezoidIntegrator.java │ │ │ ├── UnivariateRealIntegrator.java │ │ │ └── UnivariateRealIntegratorImpl.java │ │ └── solvers │ │ │ ├── BisectionSolver.java │ │ │ ├── BrentSolver.java │ │ │ ├── MullerSolver.java │ │ │ ├── NewtonSolver.java │ │ │ ├── RiddersSolver.java │ │ │ ├── SecantSolver.java │ │ │ ├── UnivariateRealSolver.java │ │ │ ├── UnivariateRealSolverFactory.java │ │ │ ├── UnivariateRealSolverFactoryImpl.java │ │ │ ├── UnivariateRealSolverImpl.java │ │ │ └── UnivariateRealSolverUtils.java │ │ ├── distribution │ │ ├── AbstractContinuousDistribution.java │ │ ├── AbstractDistribution.java │ │ ├── AbstractIntegerDistribution.java │ │ ├── BetaDistribution.java │ │ ├── BetaDistributionImpl.java │ │ ├── BinomialDistribution.java │ │ ├── BinomialDistributionImpl.java │ │ ├── CauchyDistribution.java │ │ ├── CauchyDistributionImpl.java │ │ ├── ChiSquaredDistribution.java │ │ ├── ChiSquaredDistributionImpl.java │ │ ├── ContinuousDistribution.java │ │ ├── DiscreteDistribution.java │ │ ├── Distribution.java │ │ ├── ExponentialDistribution.java │ │ ├── ExponentialDistributionImpl.java │ │ ├── FDistribution.java │ │ ├── FDistributionImpl.java │ │ ├── GammaDistribution.java │ │ ├── GammaDistributionImpl.java │ │ ├── HasDensity.java │ │ ├── HypergeometricDistribution.java │ │ ├── HypergeometricDistributionImpl.java │ │ ├── IntegerDistribution.java │ │ ├── NormalDistribution.java │ │ ├── NormalDistributionImpl.java │ │ ├── PascalDistribution.java │ │ ├── PascalDistributionImpl.java │ │ ├── PoissonDistribution.java │ │ ├── PoissonDistributionImpl.java │ │ ├── SaddlePointExpansion.java │ │ ├── TDistribution.java │ │ ├── TDistributionImpl.java │ │ ├── WeibullDistribution.java │ │ ├── WeibullDistributionImpl.java │ │ ├── ZipfDistribution.java │ │ └── ZipfDistributionImpl.java │ │ ├── special │ │ ├── Beta.java │ │ ├── Erf.java │ │ └── Gamma.java │ │ └── util │ │ ├── ContinuedFraction.java │ │ ├── MathUtils.java │ │ └── OpenIntToDoubleHashMap.java │ └── json │ ├── JSON.java │ ├── JSONArray.java │ ├── JSONException.java │ ├── JSONObject.java │ ├── JSONStringer.java │ └── JSONTokener.java ├── test └── test │ └── beast │ ├── BEASTTestCase.java │ ├── beast2vs1 │ ├── ClockModelTest.java │ ├── StarBEASTTest.java │ ├── SubstitutionModelTest.java │ ├── TaxonOrderTest.java │ ├── TestFramework.java │ ├── TipTimeTest.java │ ├── TreePriorTest.java │ ├── TreeTest.java │ ├── trace │ │ ├── DiscreteStatistics.java │ │ ├── Expectation.java │ │ ├── LogAnalyser.java │ │ ├── LogFileTraces.java │ │ ├── NumberFormatter.java │ │ ├── TraceException.java │ │ ├── TraceStatistics.java │ │ ├── TraceType.java │ │ └── TrimLineReader.java │ └── tutorials │ │ ├── DivergenceDatingTest.java │ │ └── RateTutorialTest.java │ ├── core │ ├── BEASTInterfaceTest.java │ ├── InputForAnnotatedConstructorTest.java │ ├── InputTest.java │ ├── LoggerTest.java │ ├── OperatorScheduleTest.java │ ├── PrimitiveBeastObject.java │ ├── PrimitiveInterface.java │ ├── StateNodeInitialiserTest.java │ ├── parameter │ │ ├── BooleanParameterListTest.java │ │ ├── IntegerParameterListTest.java │ │ ├── ParameterTest.java │ │ └── RealParameterListTest.java │ └── util │ │ └── SumTest.java │ ├── evolution │ ├── alignment │ │ ├── FilteredAlignmentTest.java │ │ └── UncertainAlignmentTest.java │ ├── datatype │ │ ├── DataTypeDeEncodeTest.java │ │ └── IntegerDataTest.java │ ├── inference │ │ └── DirichletTest.java │ ├── likelihood │ │ ├── BeagleTreeLikelihoodTest.java │ │ └── TreeLikelihoodTest.java │ ├── operator │ │ ├── BactrianDeltaExchangeOperatorTest.java │ │ ├── BactrianIntervalOperatorTest.java │ │ ├── BactrianRandomWalkOperatorTest.java │ │ ├── BactrianScaleOperatorTest.java │ │ ├── BactrianUpDownOperatorTest.java │ │ ├── CompoundParameterHelperTest.java │ │ ├── DeltaExchangeOperatorTest.java │ │ ├── ExchangeOperatorTest.java │ │ ├── IntRandomWalkOperatorTest.java │ │ ├── KernelDistiburionTest.java │ │ ├── ScaleOperatorTest.java │ │ ├── TestOperator.java │ │ └── UniformIntegerOperatorTest.java │ ├── speciation │ │ ├── BirthDeathGernhard08ModelTest.java │ │ └── YuleModelTest.java │ ├── substmodel │ │ ├── BinaryCovarionModelTest.java │ │ ├── GTRTest.java │ │ ├── GeneralSubstitutionModelTest.java │ │ └── HKYTest.java │ └── tree │ │ ├── NodeTest.java │ │ ├── RandomTreeTest.java │ │ ├── TraitSetTest.java │ │ ├── TreeTest.java │ │ ├── TreeUtilsTest.java │ │ └── coalescent │ │ ├── BayesianSkylineTest.java │ │ └── CoalescentTest.java │ ├── integration │ ├── DependencyTest.java │ ├── DocumentationTest.java │ ├── InputTypeTest.java │ ├── XMLElementNameTest.java │ └── XMLProducerTest.java │ ├── math │ └── distributions │ │ ├── GammaTest.java │ │ ├── InvGammaTest.java │ │ ├── LaplaceDistributionTest.java │ │ ├── LogNormalDistributionModelTest.java │ │ ├── MRCAPriorTest.java │ │ ├── MeanOfParametricDistributionTest.java │ │ └── NormalDistributionTest.java │ ├── statistic │ └── RPNCalculatorTest.java │ └── util │ ├── AnnotatedRunnableTestClass.java │ ├── ClusterTreeTest.java │ ├── NexusParserTest.java │ ├── RandomizerTest.java │ ├── TreeParserTest.java │ ├── XMLParserTest.java │ └── XMLTest.java └── version.xml /.github/workflows/beauti.yml: -------------------------------------------------------------------------------- 1 | name: BEAUti tests 2 | on: [ workflow_dispatch ] 3 | 4 | jobs: 5 | test-beauti: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | - run: docker build -t beast2-test . 10 | - run: docker run beast2-test test-beauti -------------------------------------------------------------------------------- /.github/workflows/core.yml: -------------------------------------------------------------------------------- 1 | name: Core tests 2 | on: [ push, pull_request, workflow_dispatch ] 3 | 4 | jobs: 5 | test-core: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v2 9 | - run: docker build -t beast2-test . 10 | - run: docker run beast2-test test-core 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # IntelliJ ignores 2 | /.idea 3 | /beast2.iml 4 | /META-INF 5 | /out 6 | 7 | # Eclipse ignores 8 | /.classpath 9 | 10 | # OS X ignores 11 | .DS_Store 12 | /build/ 13 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile to build container for unit testing. 2 | # 3 | # To build the image, run the following from this directory: 4 | # docker build -t beast_testing . 5 | # 6 | # To run the tests, use 7 | # docker run beast_testing 8 | # 9 | # To run the tests interactively, use 10 | # docker run --entrypoint /bin/bash -it -p 5900:5900 beast_testing 11 | # This will give you a shell in the container. From this 12 | # shell, run 13 | # vncserver $DISPLAY -geometry 1920x1080; ant -f build-testing.xml 14 | # 15 | # The previous command exposes the VNC session, so while the 16 | # BEAUti test suite is running you can run a VNC viewer and 17 | # connect it to localhost (password: password) to observe 18 | # the graphical output of these tests. 19 | 20 | FROM openjdk:11 21 | WORKDIR /beast2 22 | 23 | # Install Apache Ant 24 | RUN apt-get update && apt-get install -y ant 25 | 26 | # Install and configure VNC server 27 | RUN apt-get update && apt-get install -y tightvncserver twm 28 | RUN mkdir /root/.vnc 29 | RUN echo password | vncpasswd -f > /root/.vnc/passwd 30 | RUN chmod 600 /root/.vnc/passwd 31 | 32 | # Install BEAGLE 33 | RUN apt-get update && apt-get install -y build-essential autoconf automake libtool pkg-config 34 | # use latest release v3.1.2, issue #786 35 | RUN cd /root && git clone --branch v3.1.2 --depth=1 https://github.com/beagle-dev/beagle-lib.git 36 | RUN cd /root/beagle-lib && ./autogen.sh && ./configure --prefix=/usr/local && make install 37 | RUN ldconfig 38 | 39 | ADD . ./ 40 | 41 | RUN echo "#!/bin/bash\n" \ 42 | "export USER=root\n" \ 43 | "export DISPLAY=:1\n" \ 44 | "vncserver :1 -geometry 1920x1080\n" \ 45 | "ant -lib lib -f build-testing.xml \$1\n" > entrypoint.sh 46 | RUN chmod a+x entrypoint.sh 47 | 48 | ENTRYPOINT ["./entrypoint.sh"] 49 | 50 | CMD ["test-all"] 51 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BEAST 2 2 | ======= 3 | 4 | [![Build Status](https://github.com/CompEvol/beast2/workflows/Core%20tests/badge.svg)](https://github.com/CompEvol/beast2/actions?query=workflow%3A%22Core+tests%22) 5 | 6 | BEAST is a cross-platform program for Bayesian inference using MCMC of 7 | molecular sequences. It is entirely oriented towards rooted, 8 | time-measured phylogenies inferred using strict or relaxed molecular 9 | clock models. It can be used as a method of reconstructing phylogenies 10 | but is also a framework for testing evolutionary hypotheses without 11 | conditioning on a single tree topology. BEAST uses MCMC to average 12 | over tree space, so that each tree is weighted proportional to its 13 | posterior probability. We include a simple to use user-interface 14 | program for setting up standard analyses and a suit of programs for 15 | analysing the results. 16 | 17 | NOTE: This directory contains the BEAST 2 source code, and is 18 | therefore of interest primarily to BEAST 2 developers. For binary 19 | releases, user tutorials and other information you should visit the 20 | project website at [beast2.org](https://www.beast2.org). 21 | 22 | Development Rules and Philosophy 23 | -------------------------------- 24 | 25 | Aspects relating to BEAST 2 development such as coding style, version 26 | numbering and design philosophy are discussed on the BEAST 2 web page at 27 | [beast2.org/package-development-guide/core-development-rules](https://www.beast2.org/package-development-guide/core-development-rules/). 28 | 29 | License 30 | ------- 31 | 32 | BEAST 2 is free software; you can redistribute it and/or modify it 33 | under the terms of the GNU Lesser General Public License as published 34 | by the Free Software Foundation; either version 2.1 of the License, or 35 | (at your option) any later version. A copy of the license is contained 36 | in the file COPYING, located in the root directory of this repository. 37 | 38 | This software is distributed in the hope that it will be useful, but 39 | WITHOUT ANY WARRANTY; without even the implied warranty of 40 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 41 | Lesser General Public License contained in the file COPYING for more 42 | details. 43 | -------------------------------------------------------------------------------- /examples/benchmark/1/experiment.sh: -------------------------------------------------------------------------------- 1 | echo FILE M1044 > times.dat 2 | time beast testHKY1044.xml >> times.dat 2>&1 3 | echo FILE M1366 >> times.dat 4 | time beast testHKY1366.xml >> times.dat 2>&1 5 | echo FILE M1510 >> times.dat 6 | time beast testHKY1510.xml >> times.dat 2>&1 7 | echo FILE M1748 >> times.dat 8 | time beast testHKY1748.xml >> times.dat 2>&1 9 | echo FILE M1749 >> times.dat 10 | time beast testHKY1749.xml >> times.dat 2>&1 11 | echo FILE M1809 >> times.dat 12 | time beast testHKY1809.xml >> times.dat 2>&1 13 | echo FILE M336 >> times.dat 14 | time beast testHKY336.xml >> times.dat 2>&1 15 | echo FILE M3475 >> times.dat 16 | time beast testHKY3475.xml >> times.dat 2>&1 17 | echo FILE M501 >> times.dat 18 | time beast testHKY501.xml >> times.dat 2>&1 19 | echo FILE M520 >> times.dat 20 | time beast testHKY520.xml >> times.dat 2>&1 21 | echo FILE M755 >> times.dat 22 | time beast testHKY755.xml >> times.dat 2>&1 23 | echo FILE M767 >> times.dat 24 | time beast testHKY767.xml >> times.dat 2>&1 25 | -------------------------------------------------------------------------------- /examples/benchmark/II/experiment.sh: -------------------------------------------------------------------------------- 1 | echo FILE M1044 > times.dat 2 | time beastII -overwrite testHKY1044.xml >> times.dat 2>&1 3 | echo FILE M1366 >> times.dat 4 | time beastII -overwrite testHKY1366.xml >> times.dat 2>&1 5 | echo FILE M1510 >> times.dat 6 | time beastII -overwrite testHKY1510.xml >> times.dat 2>&1 7 | echo FILE M1748 >> times.dat 8 | time beastII -overwrite testHKY1748.xml >> times.dat 2>&1 9 | echo FILE M1749 >> times.dat 10 | time beastII -overwrite testHKY1749.xml >> times.dat 2>&1 11 | echo FILE M1809 >> times.dat 12 | time beastII -overwrite testHKY1809.xml >> times.dat 2>&1 13 | echo FILE M336 >> times.dat 14 | time beastII -overwrite testHKY336.xml >> times.dat 2>&1 15 | echo FILE M3475 >> times.dat 16 | time beastII -overwrite testHKY3475.xml >> times.dat 2>&1 17 | echo FILE M501 >> times.dat 18 | time beastII -overwrite testHKY501.xml >> times.dat 2>&1 19 | echo FILE M520 >> times.dat 20 | time beastII -overwrite testHKY520.xml >> times.dat 2>&1 21 | echo FILE M755 >> times.dat 22 | time beastII -overwrite testHKY755.xml >> times.dat 2>&1 23 | echo FILE M767 >> times.dat 24 | time beastII -overwrite testHKY767.xml >> times.dat 2>&1 25 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/experiment.sh: -------------------------------------------------------------------------------- 1 | echo FILE M1044 > times.dat 2 | time mb < run1044.nex >> times.dat 2>&1 3 | echo FILE M1366 >> times.dat 4 | time mb < run1366.nex >> times.dat 2>&1 5 | echo FILE M1510 >> times.dat 6 | time mb < run1510.nex >> times.dat 2>&1 7 | echo FILE M1748 >> times.dat 8 | time mb < run1748.nex >> times.dat 2>&1 9 | echo FILE M1749 >> times.dat 10 | time mb < run1749.nex >> times.dat 2>&1 11 | echo FILE M1809 >> times.dat 12 | time mb < run1809.nex >> times.dat 2>&1 13 | echo FILE M336 >> times.dat 14 | time mb < run336.nex >> times.dat 2>&1 15 | echo FILE M3475 >> times.dat 16 | time mb < run3475.nex >> times.dat 2>&1 17 | echo FILE M501 >> times.dat 18 | time mb < run501.nex >> times.dat 2>&1 19 | echo FILE M520 >> times.dat 20 | time mb < run520.nex >> times.dat 2>&1 21 | echo FILE M755 >> times.dat 22 | time mb < run755.nex >> times.dat 2>&1 23 | echo FILE M767 >> times.dat 24 | time mb < run767.nex >> times.dat 2>&1 25 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1044.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1044.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1366.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1366.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1510.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1510.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1748.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1748.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1749.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1749.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run1809.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY1809.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run336.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY336.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run3475.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY3475.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run501.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY501.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run520.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY520.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run755.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY755.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/benchmark/mrbayes/run767.nex: -------------------------------------------------------------------------------- 1 | begin mrbayes; 2 | set autoclose=yes nowarn=yes; 3 | execute testHKY767.nex; 4 | lset nst=2; 5 | mcmc nruns=1 ngen=1000000 samplefreq=10000 file=testHKY.nex1; 6 | end; 7 | -------------------------------------------------------------------------------- /examples/bitflip.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /examples/nexus/angiosperms.nex: -------------------------------------------------------------------------------- 1 | #NEXUS [!Data from: Young, D. A. 1981. Are the angiosperm primitively vesselless? Systematic Botany. 6:313-330. Character 9 coded "0" for OTU AUST, following Riggins and Farris (1983) ] begin taxa; dimensions ntax=34; taxlabels ANCEST ANNO AMBO ARIS AUST CALY CANE CHLO DEGE EUPO GOMO GYRO HERN HIMA IDIO ILLI LACT LAUR MAGN MONI MYRI PIPE SARC SAUR SCHI TRIM WINT TETR TROC CERC CABO CERA NYMP NELU ; end; begin characters; dimensions nchar=41; format symbols = "012"; matrix ANCEST 00000000000000000000000000000000000000000 ANNO 00010000001010102001000110010000000022022 AMBO 00000000011210002000000100002200000022100 ARIS 10010000011010111111010102212000000000022 AUST 10200000001000000000000000010000000000000 CALY 00210000001001000001000100010200011002022 CANE 00000000001010101011100002011000000022001 CHLO 00201000111111210010011100102210100122000 DEGE 00000000001001101000000000002000000000000 EUPO 00000000001001210000000000210000000022000 GOMO 00200000001020002101001102212200010022001 GYRO 00000000011120002101001100212200011002022 HERN 01000000011120002101001100212200011002022 HIMA 00000000001011102110000000011200000000022 IDIO 00200000001001000000001100002200001002022 ILLI 00001000001001000001000200010200000000000 LACT 00000000101101002100001020002100000000021 LAUR 00110000011120002111011100112200011022011 MAGN 00010000101102100000000000010000000011000 MONI 00200100001110100001000110110200000002011 MYRI 00000000001220112111100000012200000020011 PIPE 20110000111120210001001002012210101122022 SARC 10201000111000210000011100002200000022100 SAUR 20020000111020210001001001112210001101022 SCHI 10021000001200000001100200000200000022000 TRIM 00110100001120112101001100002200000022000 WINT 00000000001121100001000011000000000011100 TETR 00021000111020112101001201012100000000100 TROC 00221000011020210001000200010000000000100 CERC 00221000100210112101000200012000000000001 CABO 20010000010000102101000000011200011101100 CERA 20211000010200210001000100012210211002100 NYMP 20020000010002100000000012110000001120100 NELU 20020000110002000001000200000200011002000 ; end; begin assumptions; options deftype = ord; end; -------------------------------------------------------------------------------- /examples/nexus/anolis.nex_phyml_stats.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/examples/nexus/anolis.nex_phyml_stats.txt -------------------------------------------------------------------------------- /examples/nexus/anolis.nex_phyml_tree.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/examples/nexus/anolis.nex_phyml_tree.txt -------------------------------------------------------------------------------- /examples/nexus/avian-ovomucoids.nex: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/examples/nexus/avian-ovomucoids.nex -------------------------------------------------------------------------------- /examples/nexus/maddison.nex: -------------------------------------------------------------------------------- 1 | #NEXUS 2 | 3 | [ 4 | Example from Nexus: An Extensible File Format for Systematic Information 5 | David R. Maddison David L. Swofford Wayne P. Maddison David Cannatella 6 | Syst Biol (1997) 46 (4): 590-621. 7 | ] 8 | 9 | 10 | BEGIN TAXA; 11 | DIMENSIONS NTAX=4; 12 | TAXLABELS fish frog snake mouse; 13 | END; 14 | 15 | BEGIN CHARACTERS; 16 | DIMENSIONS NCHAR=20; 17 | FORMAT DATATYPE=DNA; 18 | MATRIX 19 | fish ACATAGAGGGTACCTCTAAG 20 | frog ACTTAGAGGCTACCTCTACG 21 | snake ACTCACTGGGTACCTTTGCG 22 | mouse ACTCAGACGGTACCTTTGCG; 23 | END; 24 | 25 | BEGIN TREES; 26 | TREE best = (fish,(frog,(snake,mouse))); 27 | END; 28 | -------------------------------------------------------------------------------- /examples/nexus/old.nex: -------------------------------------------------------------------------------- 1 | #nexus 2 | 3 | BEGIN Taxa; 4 | DIMENSIONS ntax=1; 5 | TAXLABELS 6 | [1] cae 7 | ; 8 | END; [Taxa] 9 | 10 | BEGIN Characters; 11 | DIMENSIONS nchar=4; 12 | format datatype=standard 13 | missing=? 14 | gap=- 15 | symbols="01" 16 | labels=left 17 | transpose=no 18 | interleave=no 19 | ; 20 | MATRIX 21 | cae 1000 22 | ; 23 | END; [Characters] 24 | 25 | 26 | -------------------------------------------------------------------------------- /examples/nexus/traitlab.nex: -------------------------------------------------------------------------------- 1 | #NEXUS 2 | [file format produced by TraitLab] 3 | 4 | BEGIN DATA; 5 | 6 | DIMENSIONS NTAX=9 NCHAR=30; 7 | FORMAT MISSING=? GAP=- INTERLEAVE ; 8 | 9 | MATRIX 10 | 11 | taxon_1 00?1111010110101000101001?0000 12 | taxon_2 101111010?11001111001011011000 13 | taxon_3 01101101??1110111?001010011000 14 | taxon_4 010111100111011100110000100100 15 | taxon_5 110111101111011??0110100100100 16 | taxon_6 111111010111?01111001011011011 17 | taxon_7 1111???101101011110??011011011 18 | taxon_8 111111000111101110001011011011 19 | taxon_9 11111101?111101111001011?11011 20 | ; 21 | END; 22 | 23 | BEGIN CLADES; 24 | 25 | CLADE NAME = Clade_1 26 | ROOTMIN = 346 27 | ROOTMAX = 422 28 | TAXA = taxon_4, taxon_5; 29 | 30 | CLADE NAME = Clade_2 31 | ORIGINATEMIN = 346 32 | TAXA = taxon_1, taxon_8, taxon_9; 33 | 34 | END; 35 | 36 | -------------------------------------------------------------------------------- /examples/parameterised/README.md: -------------------------------------------------------------------------------- 1 | Run with BEAST using the -D and -DF options. 2 | 3 | The -D option specifies attribute-value pairs to be replaced in the XML, e.g., `-D arg1=10,arg2=20` 4 | The -DF option is as -D, but has attribute-value pairs defined in file in JSON format 5 | 6 | Note that the `$(filebase)` definition is automatically replaced by the base name of the XML file. 7 | 8 | 9 | To run the RSV2.xml example in this directory with a chain length of 1000000 and alignment and date trait defined in RSV2.json, on OS X and Linux: 10 | 11 | ''' 12 | /path/to/beast/bin/beast -D chainLength=1000000 -DF RSV2.json RSV2.xml 13 | ''' 14 | 15 | where `/path/to/beast` the path to where BEAST is installed. 16 | 17 | To run on Windows: 18 | 19 | ''' 20 | \path\to\beast\bat\beast.bat -D chainLength=1000000 -DF RSV2.json RSV2.xml 21 | ''' 22 | 23 | where `\path\to\beast` the path to where BEAST is installed. 24 | 25 | -------------------------------------------------------------------------------- /examples/ringe_ctmc.xml.state: -------------------------------------------------------------------------------- 1 | 2 | ((0:0.25,1:0.25)4:0.25,(2:0.25,3:0.25)5:0.25)6:0.0 3 | birthRate.t:tree[1 1] (-Infinity,Infinity): 1.0 4 | 5 | 10 | -------------------------------------------------------------------------------- /examples/testCalYule_5t_2c.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /examples/testDirectSimulator.xml: -------------------------------------------------------------------------------- 1 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /examples/testDirectSimulator2.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /examples/testDirectSimulatorHierarchical.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /lib/antlr-runtime-4.10.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/antlr-runtime-4.10.1.jar -------------------------------------------------------------------------------- /lib/beagle.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/beagle.jar -------------------------------------------------------------------------------- /lib/bundler/jarbundler-core-3.3.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/bundler/jarbundler-core-3.3.0.jar -------------------------------------------------------------------------------- /lib/bundler/jsign-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/bundler/jsign-3.1.jar -------------------------------------------------------------------------------- /lib/colt.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/colt.jar -------------------------------------------------------------------------------- /lib/commons-math3-3.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/commons-math3-3.6.1.jar -------------------------------------------------------------------------------- /lib/junit/junit-platform-console-standalone-1.8.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/lib/junit/junit-platform-console-standalone-1.8.2.jar -------------------------------------------------------------------------------- /release/Linux/jrebin/applauncher: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | 34 | 35 | # use BEAGLE_LIB if the BEAGLE library is not in a standard location 36 | if [ -n "$BEAGLE_LIB" ]; then 37 | if [ -n "$BEAST_EXTRA_LIBS" ]; then 38 | BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB" 39 | else 40 | BEAST_EXTRA_LIBS="$BEAGLE_LIB" 41 | fi 42 | fi 43 | 44 | # Explicitly add /usr/local/lib to library search path to ensure 45 | # beast continues to find beagle when installed here. (This is 46 | # necessary due to known problems with certain JREs.) 47 | if [ -z "$LD_LIBRARY_PATH" ]; then 48 | export LD_LIBRARY_PATH=/usr/local/lib 49 | else 50 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib 51 | fi 52 | 53 | # use BEAST_EXTRA_LIBS variable to load BEAGLE and other libraries from non-default locations 54 | # this assumes that the library path contains all these libraries (or are set through LD_LIBRARY_PATH) 55 | if [ -n "$BEAST_EXTRA_LIBS" ]; then 56 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_EXTRA_LIBS" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher $* 57 | else 58 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher $* 59 | fi 60 | -------------------------------------------------------------------------------- /release/Linux/jrebin/beauti: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | 34 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_LIB" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.BeautiLauncher -capture $* 35 | 36 | -------------------------------------------------------------------------------- /release/Linux/jrebin/densitree: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | "$JAVA" -Xss256m -Xmx8g -Djava.library.path="$BEAST_LIB" -cp "$BEAST_LIB/DensiTree.jar:$BEAST/DensiTree.app/Contents/Resources/Java/DensiTree.jar" viz.DensiTree $* 34 | 35 | -------------------------------------------------------------------------------- /release/Linux/jrebin/loganalyser: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | 34 | 35 | # use BEAGLE_LIB if the BEAGLE library is not in a standard location 36 | if [ -n "$BEAGLE_LIB" ]; then 37 | if [ -n "$BEAST_EXTRA_LIBS" ]; then 38 | BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB" 39 | else 40 | BEAST_EXTRA_LIBS="$BEAGLE_LIB" 41 | fi 42 | fi 43 | 44 | # Explicitly add /usr/local/lib to library search path to ensure 45 | # beast continues to find beagle when installed here. (This is 46 | # necessary due to known problems with certain JREs.) 47 | if [ -z "$LD_LIBRARY_PATH" ]; then 48 | export LD_LIBRARY_PATH=/usr/local/lib 49 | else 50 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib 51 | fi 52 | 53 | # use BEAST_EXTRA_LIBS variable to load BEAGLE and other libraries from non-default locations 54 | # this assumes that the library path contains all these libraries (or are set through LD_LIBRARY_PATH) 55 | if [ -n "$BEAST_EXTRA_LIBS" ]; then 56 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_EXTRA_LIBS" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher beastfx.app.tools.LogAnalyser $* 57 | else 58 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher beastfx.app.tools.LogAnalyser $* 59 | fi 60 | 61 | 62 | -------------------------------------------------------------------------------- /release/Linux/jrebin/logcombiner: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_LIB" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.LogCombinerLauncher $* 34 | 35 | -------------------------------------------------------------------------------- /release/Linux/jrebin/packagemanager: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | "$JAVA" -Xss256m -Xmx8g -Djava.library.path="$BEAST_LIB" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.PackageManager $* 34 | 35 | -------------------------------------------------------------------------------- /release/Linux/jrebin/treeannotator: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$BEAST" ]; then 4 | ## resolve links - $0 may be a link to application 5 | PRG="$0" 6 | 7 | # need this for relative symlinks 8 | while [ -h "$PRG" ] ; do 9 | ls=`ls -ld "$PRG"` 10 | link=`expr "$ls" : '.*-> \(.*\)$'` 11 | if expr "$link" : '/.*' > /dev/null; then 12 | PRG="$link" 13 | else 14 | PRG="`dirname "$PRG"`/$link" 15 | fi 16 | done 17 | 18 | # make it fully qualified 19 | saveddir=`pwd` 20 | BEAST0=`dirname "$PRG"`/.. 21 | BEAST=`cd "$BEAST0" && pwd` 22 | cd "$saveddir" 23 | fi 24 | 25 | BEAST_LIB="$BEAST/lib" 26 | export JAVA_HOME="$BEAST/jre" 27 | 28 | if [ -z "$JAVA_HOME" ]; then 29 | JAVA=java 30 | else 31 | JAVA="$JAVA_HOME"/bin/java 32 | fi 33 | "$JAVA" -Dlauncher.wait.for.exit=true -Xss256m -Xmx8g -Djava.library.path="$BEAST_LIB" -Duser.language=en -cp "$BEAST_LIB/launcher.jar" beast.pkgmgmt.launcher.TreeAnnotatorLauncher $* 34 | 35 | -------------------------------------------------------------------------------- /release/Mac/README.md: -------------------------------------------------------------------------------- 1 | # Mac Release 2 | 3 | Last update 28-07-2020 4 | 5 | 6 | ## No JRE 7 | 8 | 1. `ant mac` and then check all messages. 9 | 10 | This will build the disk image and do the notarization. 11 | 12 | 2. `cd ~/tmp` to find _BEAST.v2.?.?.dmg_. 13 | 14 | Note: this path is depend on the path of beast2 project, which is equivalent to `beast2/../../tmp`. 15 | 16 | 3. `xcrun altool --notarization-info *-*-*-*-* -u username -p passwd` 17 | 18 | 4. `xcrun stapler staple BEAST.v2.?.?.dmg` 19 | 20 | 5. upload dmg to Github. 21 | 22 | 23 | ## With JRE 24 | 25 | 1. `ant macjre` and then check all messages. 26 | 27 | 2. `cd ~/tmp` to find _BEAST\_with\_JRE.v2.?.?.dmg_. 28 | 29 | 3. `xcrun altool --notarization-info *-*-*-*-* -u username -p passwd` 30 | 31 | 4. `xcrun stapler staple BEAST_with_JRE.v2.?.?.dmg` 32 | 33 | 5. upload dmg to Github. 34 | 35 | 36 | ## Workflow 37 | 38 | Refer to https://stackoverflow.com/questions/53112078/how-to-upload-dmg-file-for-notarization-in-xcode 39 | 40 | 41 | ## TODO 42 | 43 | 1. the hard code of JRE path in `universalJavaApplicationJREStub` must match JRE path in the `build.xml` 44 | 45 | 46 | -------------------------------------------------------------------------------- /release/Mac/install.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/Mac/install.png -------------------------------------------------------------------------------- /release/Windows/AppLauncher_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.AppLauncherLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | 15 | 16 | AppLauncher 17 | Beast 2 development team 2002-2022 18 | AppLauncher 19 | AppLauncher 20 | AppLauncher.exe 21 | 22 | 23 | -------------------------------------------------------------------------------- /release/Windows/AppLauncher_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.AppLauncherLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | jre 15 | 16 | 17 | AppLauncher 18 | Beast 2 development team 2002-2022 19 | AppLauncher 20 | AppLauncher 21 | AppLauncher.exe 22 | 23 | 24 | -------------------------------------------------------------------------------- /release/Windows/BEAST_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/beast.ico 4 | 5 | beast.pkgmgmt.launcher.BeastLauncher 6 | ./lib/launcher.jar 7 | 8 | -window -working -options 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | -Dfile.encoding=UTF-8 15 | 16 | 17 | BEAST2 18 | Beast 2 development team 2002-2022 19 | BEAST2 20 | BEAST2 21 | BEAST2.exe 22 | 23 | 24 | -------------------------------------------------------------------------------- /release/Windows/BEAST_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/beast.ico 4 | 5 | beast.pkgmgmt.launcher.BeastLauncher 6 | ./lib/launcher.jar 7 | 8 | -window -working -options 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | -Dfile.encoding=UTF-8 15 | jre 16 | 17 | 18 | BEAST2 19 | Beast 2 development team 2002-2022 20 | BEAST2 21 | BEAST2 22 | BEAST2.exe 23 | 24 | 25 | -------------------------------------------------------------------------------- /release/Windows/BEAUti_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/beauti.ico 4 | 5 | beast.pkgmgmt.launcher.BeautiLauncher 6 | ./lib/launcher.jar 7 | 8 | -capture 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | -Dfile.encoding=UTF-8 15 | 16 | 17 | BEAUti2 18 | Beast 2 development team 2002-2022 19 | BEAUti2 20 | BEAUti2 21 | BEAUti2.exe 22 | 23 | 24 | -------------------------------------------------------------------------------- /release/Windows/BEAUti_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/beauti.ico 4 | 5 | beast.pkgmgmt.launcher.BeautiLauncher 6 | ./lib/launcher.jar 7 | 8 | -capture 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | -Dfile.encoding=UTF-8 15 | jre 16 | 17 | 18 | BEAUti2 19 | Beast 2 development team 2002-2022 20 | BEAUti2 21 | BEAUti2 22 | BEAUti2.exe 23 | 24 | 25 | -------------------------------------------------------------------------------- /release/Windows/LogCombiner_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.LogCombinerLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 10 | 1.6.0 11 | 256 12 | 8096 13 | -Duser.language=en 14 | 15 | 16 | LogCombiner 17 | Beast 2 development team 2002-2022 18 | LogCombiner 19 | LogCombiner 20 | LogCombiner.exe 21 | 22 | 23 | -------------------------------------------------------------------------------- /release/Windows/LogCombiner_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.LogCombinerLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 1.6.0 10 | 256 11 | 8096 12 | -Duser.language=en 13 | jre 14 | 15 | 16 | LogCombiner 17 | Beast 2 development team 2002-2022 18 | LogCombiner 19 | LogCombiner 20 | LogCombiner.exe 21 | 22 | 23 | -------------------------------------------------------------------------------- /release/Windows/TreeAnnotator_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.TreeAnnotatorLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 1.6.0 10 | 256 11 | 8096 12 | -Duser.language=en 13 | 14 | 15 | TreeAnnotator 16 | Beast 2 development team 2002-2022 17 | TreeAnnotator 18 | TreeAnnotator 19 | TreeAnnotator.exe 20 | 21 | 22 | -------------------------------------------------------------------------------- /release/Windows/TreeAnnotator_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ../common/icons/utility.ico 4 | 5 | beast.pkgmgmt.launcher.TreeAnnotatorLauncher 6 | ./lib/launcher.jar 7 | 8 | 9 | 1.6.0 10 | 256 11 | 8096 12 | -Duser.language=en 13 | jre 14 | 15 | 16 | TreeAnnotator 17 | Beast 2 development team 2002-2022 18 | TreeAnnotator 19 | TreeAnnotator 20 | TreeAnnotator.exe 21 | 22 | 23 | -------------------------------------------------------------------------------- /release/Windows/bat/applauncher.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/beast.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST %~dp0\..\jre ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -Dfile.encoding=UTF-8 -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.BeastLauncher %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -Dfile.encoding=UTF-8 -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.BeastLauncher %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/beauti.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -Dfile.encoding=UTF-8 -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.BeautiLauncher %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -Dfile.encoding=UTF-8 -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.BeautiLauncher %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/loganalyser.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher LogAnalyser %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.AppLauncherLauncher LogAnalyser %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/logcombiner.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.LogCombinerLauncher %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.LogCombinerLauncher %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/packagemanager.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.PackageManager %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.PackageManager %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/bat/treeannotator.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | REM Check whether the JRE is included 4 | IF EXIST "%~dp0\..\jre" ( 5 | 6 | REM for BEAST version that includes JRE 7 | "%~dp0\..\jre\bin\java" -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.TreeAnnotatorLauncher %* 8 | 9 | ) ELSE ( 10 | REM for version that does not include JRE 11 | java -Xss256m -Xmx8g -cp "%~dp0\..\lib\launcher.jar" beast.pkgmgmt.launcher.TreeAnnotatorLauncher %* 12 | ) -------------------------------------------------------------------------------- /release/Windows/windowsCertificationNotes.txt: -------------------------------------------------------------------------------- 1 | Windows certification notes: 2 | 3 | Create certificate: 4 | 5 | "C:\Program Files\Java\jdk1.8.0_161\bin\keytool.exe" -genkey -dname "CN=RemcoBouckaert, L=Auckland, ST=ST, C=NZ, OU=, O=http://beast2/org" -alias http://beast2.org -keyalg RSA -destkeystore keystore.pfx -keysize 2048 -storetype pkcs12 6 | 7 | 8 | keystore password = UoA password 9 | 10 | Signing with ant: add jsign-3.1.jar from 11 | 12 | -------------------------------------------------------------------------------- /release/common/icons/beast.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beast.icns -------------------------------------------------------------------------------- /release/common/icons/beast.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beast.ico -------------------------------------------------------------------------------- /release/common/icons/beast.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beast.png -------------------------------------------------------------------------------- /release/common/icons/beauti.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beauti.icns -------------------------------------------------------------------------------- /release/common/icons/beauti.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beauti.ico -------------------------------------------------------------------------------- /release/common/icons/beauti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/beauti.png -------------------------------------------------------------------------------- /release/common/icons/utility.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/utility.icns -------------------------------------------------------------------------------- /release/common/icons/utility.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/utility.ico -------------------------------------------------------------------------------- /release/common/icons/utility.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/icons/utility.png -------------------------------------------------------------------------------- /release/common/tools/DensiTree.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/tools/DensiTree.icns -------------------------------------------------------------------------------- /release/common/tools/DensiTree.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/tools/DensiTree.ico -------------------------------------------------------------------------------- /release/common/tools/DensiTree.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/tools/DensiTree.jar -------------------------------------------------------------------------------- /release/common/tools/DensiTree.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/release/common/tools/DensiTree.png -------------------------------------------------------------------------------- /release/common/tools/DensiTree_launch4j.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ./DensiTree.ico 4 | 5 | viz.DensiTree 6 | ./DensiTree.jar 7 | 8 | 9 | 10 | 1.8.0 11 | 256 12 | 4096 13 | -Duser.language=en 14 | 15 | 16 | DensiTree 17 | http://compevol.auckland.ac.nz/software/DensiTree/ 18 | DensiTree 19 | DensiTree 20 | DensiTree.exe 21 | 22 | 23 | -------------------------------------------------------------------------------- /release/common/tools/DensiTree_launch4j_jre.xml: -------------------------------------------------------------------------------- 1 | 2 | gui 3 | ./DensiTree.ico 4 | 5 | viz.DensiTree 6 | ./DensiTree.jar 7 | 8 | 9 | 10 | 1.8.0 11 | 256 12 | 4096 13 | -Duser.language=en 14 | jre 15 | 16 | 17 | DensiTree 18 | http://compevol.auckland.ac.nz/software/DensiTree/ 19 | DensiTree 20 | DensiTree 21 | DensiTree.exe 22 | 23 | 24 | -------------------------------------------------------------------------------- /src/beast/base/CudaDetector.java: -------------------------------------------------------------------------------- 1 | package beast.base; 2 | 3 | import beast.base.core.Log; 4 | import beast.base.core.Log.Level; 5 | import beast.base.evolution.alignment.Alignment; 6 | import beast.base.evolution.alignment.Sequence; 7 | import beast.base.evolution.likelihood.BeagleTreeLikelihood; 8 | import beast.base.evolution.sitemodel.SiteModel; 9 | import beast.base.evolution.substitutionmodel.JukesCantor; 10 | import beast.base.evolution.tree.TreeParser; 11 | 12 | public class CudaDetector { 13 | 14 | /** 15 | * Used to detect whether CUDA with BEAGLE is installed on OS X in {@link Utils6#testCudaStatusOnMac()}, 16 | * which is used by {@link beast.pkgmgmt.launcher.BeastLauncher#main(String[])}. 17 | * @see issues 500. 18 | */ 19 | public static void main(String[] args) { 20 | try { 21 | Log.setLevel(Level.none); 22 | Sequence a = new Sequence("A", "A"); 23 | Sequence b = new Sequence("B", "A"); 24 | Sequence c = new Sequence("C", "A"); 25 | Sequence d = new Sequence("D", "A"); 26 | 27 | Alignment data = new Alignment(); 28 | data.initByName("sequence", a, "sequence", b, "sequence", c, "sequence", d, "dataType", "nucleotide"); 29 | 30 | TreeParser tree = new TreeParser(); 31 | tree.initByName("taxa", data, 32 | "newick", "(((A:1,B:1):1,C:2):1,D:3)", 33 | "IsLabelledNewick", true); 34 | 35 | JukesCantor JC = new JukesCantor(); 36 | JC.initAndValidate(); 37 | 38 | SiteModel siteModel = new SiteModel(); 39 | siteModel.initByName("mutationRate", "1.0", "gammaCategoryCount", 1, "substModel", JC); 40 | 41 | BeagleTreeLikelihood likelihood = new BeagleTreeLikelihood(); 42 | likelihood.initByName("data", data, "tree", tree, "siteModel", siteModel); 43 | } catch (Exception e) { 44 | // TODO Auto-generated catch block 45 | e.printStackTrace(); 46 | } 47 | 48 | 49 | // System.out.println("Success"); 50 | // if we got this far, exit with status 0 51 | System.exit(0); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/beast/base/core/BEASTVersion2.java: -------------------------------------------------------------------------------- 1 | package beast.base.core; 2 | 3 | import beast.pkgmgmt.BEASTVersion; 4 | 5 | /** 6 | * This is a duplicate of BEASTVersion, however the BEASTVersion class should be used by BEASTLauncher 7 | * and derivatives, but this class should be used in any other place 8 | * */ 9 | public class BEASTVersion2 extends BEASTVersion { 10 | 11 | /** 12 | * Version string: assumed to be in format x.x.x 13 | */ 14 | private static final String VERSION = "2.7.7"; 15 | 16 | private static final String DATE_STRING = "2002-2024"; 17 | 18 | private static final boolean IS_PRERELEASE = true; 19 | // 20 | // private static final String BEAST2_WEBPAGE = "http://beast2.org/"; 21 | // 22 | // private static final String BEAST2_SOURCE = "http://github.com/CompEvol/beast2"; 23 | // 24 | @Override 25 | public String getVersion() { 26 | return VERSION; 27 | } 28 | 29 | @Override 30 | public String getVersionString() { 31 | return "v" + VERSION + (IS_PRERELEASE ? " Prerelease" : ""); 32 | } 33 | 34 | @Override 35 | public String getDateString() { 36 | return DATE_STRING; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/beast/base/core/Description.java: -------------------------------------------------------------------------------- 1 | /* 2 | * File Description.java 3 | * 4 | * Copyright (C) 2010 Remco Bouckaert remco@cs.auckland.ac.nz 5 | * 6 | * This file is part of BEAST2. 7 | * See the NOTICE file distributed with this work for additional 8 | * information regarding copyright ownership and licensing. 9 | * 10 | * BEAST is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as 12 | * published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * BEAST is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with BEAST; if not, write to the 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 | * Boston, MA 02110-1301 USA 24 | */ 25 | 26 | package beast.base.core; 27 | 28 | import java.lang.annotation.ElementType; 29 | import java.lang.annotation.Retention; 30 | import java.lang.annotation.RetentionPolicy; 31 | import java.lang.annotation.Target; 32 | 33 | /** 34 | * This is an annotation that can be used to both 35 | * + document a class at the top of the code and 36 | * + create user documentation for XML Beast files. 37 | *

38 | * The idea is to add @Description("bla bla bla") 39 | * just before class declarations of plug-ins. Applications 40 | * like DocMaker then can pick it up through introspection. 41 | *

42 | * To indicate that the description applies to all derived 43 | * classes, the isInheritable flag is set true by default. 44 | * This does not always apply, for instance when the description 45 | * contains text like "Should not be used directly, but by 46 | * implementations". 47 | */ 48 | @Target({ElementType.TYPE}) 49 | @Retention(RetentionPolicy.RUNTIME) 50 | public @interface Description { 51 | 52 | /** 53 | * @return the description of the class 54 | */ 55 | String value(); 56 | 57 | /** 58 | * @return true to indicate this description applies to all its inherited classes as well, false otherwise 59 | */ 60 | boolean isInheritable() default true; 61 | } 62 | -------------------------------------------------------------------------------- /src/beast/base/core/Loggable.java: -------------------------------------------------------------------------------- 1 | package beast.base.core; 2 | 3 | import java.io.PrintStream; 4 | 5 | /** 6 | * @author Andrew Rambaut 7 | * @version $Id$ 8 | */ 9 | 10 | /** 11 | * interface for items that can be logged through a Logger * 12 | */ 13 | public interface Loggable { 14 | 15 | /** 16 | * write header information, e.g. labels of a parameter, 17 | * or Nexus tree preamble 18 | * 19 | * @param out log stream 20 | */ 21 | void init(PrintStream out); 22 | 23 | /** 24 | * log this sample for current state to PrintStream, 25 | * e.g. value of a parameter, list of parameters or Newick tree 26 | * 27 | * @param sample chain sample number 28 | * @param out log stream 29 | */ 30 | void log(long sample, PrintStream out); 31 | 32 | /** 33 | * close log. An end of log message can be left (as in End; for Nexus trees) 34 | * 35 | * @param out log stream 36 | */ 37 | void close(PrintStream out); 38 | } 39 | -------------------------------------------------------------------------------- /src/beast/base/core/Param.java: -------------------------------------------------------------------------------- 1 | package beast.base.core; 2 | 3 | 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | /** 10 | * This annotation should be used to provide information about parameters in the constructor of a BEAST object, 11 | * as an alternative way to represent inputs. 12 | * 13 | * Note that any object with a constructor with Param annotations should also have a 14 | * public default constructor without arguments to facilitate cloning models in BEAUti. 15 | * 16 | * Furthermore, every Param annotation should come with a public getter and setter, using 17 | * camelcase for name, with annotation CTor(@Param(name="shape",...) double shape) these 18 | * getter and setter signatures should be in the class: 19 | * 20 | * public double getShape() 21 | * public void setShape(double shape) 22 | * 23 | */ 24 | @Target({ElementType.PARAMETER}) 25 | @Retention(RetentionPolicy.RUNTIME) 26 | public @interface Param { 27 | 28 | /** 29 | * The name of this parameter, typically the same as the name 30 | * of the constructor argument. 31 | */ 32 | String name(); 33 | 34 | 35 | /** 36 | * The description of this parameter. Must be specified and contain 37 | * at least 4 words to pass the unit tests. 38 | */ 39 | String description(); 40 | 41 | /** 42 | * @return the default value as a string. An attempt is made to 43 | * convert the String value defaultValue() to the type associated 44 | * with the constructor argument. 45 | */ 46 | String defaultValue() default ""; 47 | 48 | /** 49 | * Indicates the value can be omitted, in which case the default 50 | * value is used (an attempt is made to convert the String value 51 | * defaultValue() to the type associated with the constructor 52 | * argument). 53 | * 54 | * Note that if there are different constructors and an argument 55 | * does not appear in the other constructor it has to be marked 56 | * as optional. 57 | */ 58 | boolean optional() default false; 59 | 60 | /** 61 | * @return true to indicate this description applies to all its 62 | * inherited classes as well, false otherwise 63 | */ 64 | boolean isInheritable() default true; 65 | } -------------------------------------------------------------------------------- /src/beast/base/core/ProgramStatus.java: -------------------------------------------------------------------------------- 1 | package beast.base.core; 2 | 3 | 4 | import java.util.concurrent.ExecutorService; 5 | import java.util.concurrent.Executors; 6 | 7 | import beast.pkgmgmt.Utils6; 8 | import beast.pkgmgmt.Version; 9 | 10 | 11 | /* 12 | * Contains information about the currently running program. 13 | */ 14 | public class ProgramStatus { 15 | 16 | /** program name, e.g. BEAUti or BEAST **/ 17 | static public String name = "unknown"; 18 | 19 | /** program version information **/ 20 | static public Version version; 21 | 22 | /** 23 | * number of threads used to run the likelihood beast.core * 24 | */ 25 | static public int m_nThreads = 1; 26 | 27 | /** 28 | * thread pool * 29 | */ 30 | public static ExecutorService g_exec = Executors.newFixedThreadPool(m_nThreads); 31 | 32 | /** 33 | * current directory for opening files * 34 | */ 35 | public static String g_sDir = System.getProperty("user.dir"); 36 | 37 | public static void setCurrentDir(String currentDir) { 38 | g_sDir = currentDir; 39 | Utils6.saveBeautiProperty("currentDir", currentDir); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/beast/base/evolution/alignment/AscertainedAlignment.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.alignment; 2 | 3 | import beast.base.core.Description; 4 | 5 | 6 | @Description("Alignemnt that allows ascertainment correction") 7 | /** 8 | * This class has merged with Alignment 9 | * @deprecated use Alignment() instead setting isAscertainedInput to true. 10 | */ 11 | @Deprecated 12 | public class AscertainedAlignment extends Alignment { 13 | 14 | } // class AscertainedAlignment 15 | -------------------------------------------------------------------------------- /src/beast/base/evolution/alignment/TreeTipData.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.alignment; 2 | 3 | 4 | import java.io.PrintStream; 5 | 6 | import org.w3c.dom.Node; 7 | 8 | import beast.base.core.Description; 9 | import beast.base.core.Input; 10 | import beast.base.core.Input.Validate; 11 | import beast.base.evolution.datatype.DataType; 12 | import beast.base.inference.StateNode; 13 | import beast.base.inference.parameter.Map; 14 | 15 | @Description("Generic class for associating data to tips of a tree, e.g. an Alignment.") 16 | public class TreeTipData extends Map { 17 | 18 | final public Input taxonSetInput = 19 | new Input<>("taxa", "An optional taxon-set used only to sort the sequences into the same order as they appear in the taxon-set.", new TaxonSet(), Validate.OPTIONAL); 20 | 21 | final public Input userDataTypeInput = new Input<>("userDataType", "non-standard, user specified data type, if specified 'dataType' is ignored"); 22 | 23 | /** Loggable implementation **/ 24 | 25 | @Override 26 | public void init(PrintStream out) { 27 | } 28 | 29 | @Override 30 | public void log(long sample, PrintStream out) { 31 | } 32 | 33 | @Override 34 | public void close(PrintStream out) { 35 | } 36 | 37 | 38 | /** Function implementation **/ 39 | 40 | @Override 41 | public int getDimension() { 42 | return 0; 43 | } 44 | 45 | @Override 46 | public double getArrayValue(int dim) { 47 | return 0; 48 | } 49 | 50 | /** Map implementation **/ 51 | 52 | @Override 53 | protected Class mapType() { 54 | return String.class; 55 | } 56 | 57 | 58 | /** StateNode implementation **/ 59 | 60 | @Override 61 | public void setEverythingDirty(boolean isDirty) { 62 | } 63 | 64 | @Override 65 | public StateNode copy() { 66 | return null; 67 | } 68 | 69 | @Override 70 | public void assignTo(StateNode other) { 71 | } 72 | 73 | @Override 74 | public void assignFrom(StateNode other) { 75 | } 76 | 77 | @Override 78 | public void assignFromFragile(StateNode other) { 79 | } 80 | 81 | @Override 82 | public void fromXML(Node node) { 83 | } 84 | 85 | @Override 86 | public int scale(double scale) { 87 | return 0; 88 | } 89 | 90 | @Override 91 | protected void store() { 92 | } 93 | 94 | @Override 95 | public void restore() { 96 | } 97 | 98 | } 99 | -------------------------------------------------------------------------------- /src/beast/base/evolution/branchratemodel/BranchRateModel.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.branchratemodel; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Function; 5 | import beast.base.core.Input; 6 | import beast.base.evolution.tree.Node; 7 | import beast.base.inference.CalculationNode; 8 | 9 | /** 10 | * @author Alexei Drummond 11 | */ 12 | @Description("Defines a mean rate for each branch in the beast.tree.") 13 | public interface BranchRateModel { 14 | 15 | public double getRateForBranch(Node node); 16 | 17 | @Description(value = "Base implementation of a clock model.", isInheritable = false) 18 | public abstract class Base extends CalculationNode implements BranchRateModel { 19 | final public Input meanRateInput = new Input<>("clock.rate", "mean clock rate (defaults to 1.0)"); 20 | 21 | // empty at the moment but brings together the required interfaces 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/beast/base/evolution/branchratemodel/StrictClockModel.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.branchratemodel; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Function; 5 | import beast.base.evolution.tree.Node; 6 | import beast.base.inference.parameter.RealParameter; 7 | 8 | /** 9 | * @author Alexei Drummond 10 | */ 11 | 12 | @Description("Defines a mean rate for each branch in the beast.tree.") 13 | public class StrictClockModel extends BranchRateModel.Base { 14 | 15 | //public Input muParameterInput = new Input<>("clock.rate", "the clock rate (defaults to 1.0)"); 16 | 17 | Function muParameter; 18 | 19 | @Override 20 | public void initAndValidate() { 21 | muParameter = meanRateInput.get(); 22 | if (muParameter != null) { 23 | if (muParameter instanceof RealParameter) { 24 | RealParameter mu = (RealParameter) muParameter; 25 | mu.setBounds(Math.max(0.0, mu.getLower()), mu.getUpper()); 26 | } 27 | mu = muParameter.getArrayValue(); 28 | } 29 | } 30 | 31 | @Override 32 | public double getRateForBranch(final Node node) { 33 | return mu; 34 | } 35 | 36 | @Override 37 | public boolean requiresRecalculation() { 38 | mu = muParameter.getArrayValue(); 39 | return true; 40 | } 41 | 42 | @Override 43 | protected void restore() { 44 | mu = muParameter.getArrayValue(); 45 | super.restore(); 46 | } 47 | 48 | @Override 49 | protected void store() { 50 | mu = muParameter.getArrayValue(); 51 | super.store(); 52 | } 53 | 54 | private double mu = 1.0; 55 | } 56 | -------------------------------------------------------------------------------- /src/beast/base/evolution/datatype/Aminoacid.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.datatype; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.evolution.datatype.DataType.Base; 5 | 6 | @Description("DataType for amino acids.") 7 | public class Aminoacid extends Base { 8 | 9 | public Aminoacid() { 10 | stateCount = 20; 11 | codeLength = 1; 12 | codeMap = "ACDEFGHIKLMNPQRSTVWY" + "X" + GAP_CHAR + MISSING_CHAR; 13 | 14 | mapCodeToStateSet = new int[23][]; 15 | for (int i = 0; i < 20; i++) { 16 | mapCodeToStateSet[i] = new int[1]; 17 | mapCodeToStateSet[i][0] = i; 18 | } 19 | int[] all = new int[20]; 20 | for (int i = 0; i < 20; i++) { 21 | all[i] = i; 22 | } 23 | mapCodeToStateSet[20] = all; 24 | mapCodeToStateSet[21] = all; 25 | mapCodeToStateSet[22] = all; 26 | } 27 | 28 | @Override 29 | public String getTypeDescription() { 30 | return "aminoacid"; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/beast/base/evolution/datatype/Binary.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.datatype; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.evolution.datatype.DataType.Base; 5 | 6 | @Description("Datatype for binary sequences") 7 | public class Binary extends Base { 8 | int[][] x = { 9 | {0}, // 0 10 | {1}, // 1 11 | {0, 1}, // - 12 | {0, 1}, // ? 13 | }; 14 | 15 | public Binary() { 16 | stateCount = 2; 17 | mapCodeToStateSet = x; 18 | codeLength = 1; 19 | codeMap = "01" + GAP_CHAR + MISSING_CHAR; 20 | } 21 | 22 | @Override 23 | public String getTypeDescription() { 24 | return "binary"; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/beast/base/evolution/datatype/IntegerData.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.datatype; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.evolution.datatype.DataType.Base; 5 | 6 | @Description("Datatype for integer sequences") 7 | public class IntegerData extends Base { 8 | 9 | public IntegerData() { 10 | stateCount = -1; 11 | mapCodeToStateSet = null; 12 | codeLength = -1; 13 | codeMap = null; 14 | } 15 | 16 | @Override 17 | public String getTypeDescription() { 18 | return "integer"; 19 | } 20 | 21 | @Override 22 | public boolean isAmbiguousCode(int code) { 23 | return code < 0; 24 | } 25 | 26 | @Override 27 | public String getCharacter(int code) { 28 | if (code < 0) { 29 | return "?"; 30 | } 31 | return code + ""; 32 | } 33 | 34 | @Override 35 | public int[] getStatesForCode(int code) { 36 | return new int[]{code}; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/beast/base/evolution/datatype/Nucleotide.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.datatype; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.evolution.datatype.DataType.Base; 5 | 6 | @Description("Nucleotide datatype for DNA sequences") 7 | public class Nucleotide extends Base { 8 | int[][] x = { 9 | {0}, // A 10 | {1}, // C 11 | {2}, // G 12 | {3}, // T 13 | {3}, // U 14 | {0, 2}, // R 15 | {1, 3}, // Y 16 | {0, 1}, // M 17 | {0, 3}, // W 18 | {1, 2}, // S 19 | {2, 3}, // K 20 | {1, 2, 3}, // B 21 | {0, 2, 3}, // D 22 | {0, 1, 3}, // H 23 | {0, 1, 2}, // V 24 | {0, 1, 2, 3}, // N 25 | {0, 1, 2, 3}, // X 26 | {0, 1, 2, 3}, // - 27 | {0, 1, 2, 3}, // ? 28 | }; 29 | 30 | public Nucleotide() { 31 | stateCount = 4; 32 | mapCodeToStateSet = x; 33 | codeLength = 1; 34 | codeMap = "ACGTURYMWSKBDHVNX" + GAP_CHAR + MISSING_CHAR; 35 | } 36 | 37 | @Override 38 | public String getTypeDescription() { 39 | return "nucleotide"; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/beast/base/evolution/datatype/TwoStateCovarion.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.datatype; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.evolution.datatype.DataType.Base; 5 | 6 | @Description("Datatype for two state covarion sequences") 7 | public class TwoStateCovarion extends Base { 8 | int[][] x = { 9 | {0, 2}, // 0 10 | {1, 3}, // 1 11 | {0}, // a 12 | {1}, // b 13 | {2}, // c 14 | {3}, // d 15 | {0, 1, 2, 3}, // - 16 | {0, 1, 2, 3}, // ? 17 | }; 18 | 19 | public TwoStateCovarion() { 20 | stateCount = 4; 21 | mapCodeToStateSet = x; 22 | codeLength = 1; 23 | codeMap = "01ABCD" + GAP_CHAR + MISSING_CHAR; 24 | } 25 | 26 | @Override 27 | public String getTypeDescription() { 28 | return "twoStateCovarion"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/beast/base/evolution/distance/HammingDistance.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.distance; 2 | 3 | import beast.base.core.Description; 4 | 5 | 6 | @Description("Hamming distance is the mean number of characters that differ between sequences. " + 7 | "Note that unknowns are not ignored, so if both are unknowns '?' the distance is zero.") 8 | public class HammingDistance extends Distance.Base { 9 | 10 | @Override 11 | public double pairwiseDistance(int taxon1, int taxon2) { 12 | double dist = 0; 13 | for (int i = 0; i < patterns.getPatternCount(); i++) { 14 | if (patterns.getPattern(taxon1, i) != patterns.getPattern(taxon2, i)) { 15 | dist += patterns.getPatternWeight(i); 16 | } 17 | } 18 | return dist / patterns.getSiteCount(); 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /src/beast/base/evolution/distance/SMMDistance.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.distance; 2 | 3 | import beast.base.core.Description; 4 | 5 | 6 | /** 7 | * @author Chieh-Hsi Wu 8 | */ 9 | @Description("Calculate the distance between different microsatellite alleles") 10 | public class SMMDistance extends Distance.Base { 11 | 12 | /** 13 | * constructor taking a pattern source 14 | * 15 | * @param patterns a pattern of a microsatellite locus 16 | */ 17 | @Override 18 | public double pairwiseDistance(int taxon1, int taxon2) { 19 | 20 | int[] pattern = patterns.getPattern(0); 21 | int state1 = pattern[taxon1]; 22 | 23 | int state2 = pattern[taxon2]; 24 | double distance = 0.0; 25 | 26 | if (!dataType.isAmbiguousCode(state1) && !dataType.isAmbiguousCode(state2)) 27 | distance = Math.abs(state1 - state2); 28 | 29 | return distance; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/beast/base/evolution/likelihood/GenericTreeLikelihood.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.likelihood; 2 | 3 | 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import beast.base.core.Description; 8 | import beast.base.core.Input; 9 | import beast.base.core.Input.Validate; 10 | import beast.base.evolution.alignment.Alignment; 11 | import beast.base.evolution.branchratemodel.BranchRateModel; 12 | import beast.base.evolution.sitemodel.SiteModelInterface; 13 | import beast.base.evolution.tree.TreeInterface; 14 | import beast.base.inference.Distribution; 15 | import beast.base.inference.State; 16 | 17 | 18 | 19 | 20 | 21 | @Description("Generic tree likelihood for an alignment given a generic SiteModel, " + 22 | "a beast tree and a branch rate model") 23 | // Use this as base class to define any non-standard TreeLikelihood. 24 | // Override Distribution.calculatLogP() to make this class functional. 25 | // 26 | // TODO: This could contain a generic traverse() method that takes dirty trees in account. 27 | // 28 | public class GenericTreeLikelihood extends Distribution { 29 | 30 | final public Input dataInput = new Input<>("data", "sequence data for the beast.tree", Validate.REQUIRED); 31 | 32 | final public Input treeInput = new Input<>("tree", "phylogenetic beast.tree with sequence data in the leafs", Validate.REQUIRED); 33 | 34 | final public Input siteModelInput = new Input<>("siteModel", "site model for leafs in the beast.tree", Validate.REQUIRED); 35 | 36 | final public Input branchRateModelInput = new Input<>("branchRateModel", 37 | "A model describing the rates on the branches of the beast.tree."); 38 | 39 | 40 | 41 | @Override 42 | public List getArguments() {return null;} 43 | 44 | @Override 45 | public List getConditions() {return null;} 46 | 47 | @Override 48 | public void sample(State state, Random random) {} 49 | 50 | } 51 | -------------------------------------------------------------------------------- /src/beast/base/evolution/operator/kernel/BactrianTipDatesRandomWalker.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.operator.kernel; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Input; 5 | import beast.base.evolution.operator.TipDatesRandomWalker; 6 | import beast.base.evolution.tree.Node; 7 | import beast.base.inference.operator.kernel.KernelDistribution; 8 | import beast.base.util.Randomizer; 9 | 10 | @Description("Randomly moves tip dates on a tree by randomly selecting one from (a subset of) taxa using a Bactrian proposal") 11 | public class BactrianTipDatesRandomWalker extends TipDatesRandomWalker { 12 | public final Input kernelDistributionInput = new Input<>("kernelDistribution", "provides sample distribution for proposals", 13 | KernelDistribution.newDefaultKernelDistribution()); 14 | 15 | protected KernelDistribution kernelDistribution; 16 | 17 | @Override 18 | public void initAndValidate() { 19 | kernelDistribution = kernelDistributionInput.get(); 20 | 21 | super.initAndValidate(); 22 | } 23 | 24 | public double proposal() { 25 | // randomly select leaf node 26 | int i = Randomizer.nextInt(taxonIndices.length); 27 | Node node = treeInput.get().getNode(taxonIndices[i]); 28 | 29 | double value = node.getHeight(); 30 | double newValue = value + kernelDistribution.getRandomDelta(i, value, windowSize); 31 | 32 | if (newValue > node.getParent().getHeight()) { // || newValue < 0.0) { 33 | if (reflectValue) { 34 | newValue = reflectValue(newValue, 0.0, node.getParent().getHeight()); 35 | } else { 36 | return Double.NEGATIVE_INFINITY; 37 | } 38 | } 39 | if (newValue == value) { 40 | // this saves calculating the posterior 41 | return Double.NEGATIVE_INFINITY; 42 | } 43 | node.setHeight(newValue); 44 | 45 | return 0.0; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/beast/base/evolution/speciation/CalibrationPoint.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.speciation; 2 | 3 | import beast.base.core.BEASTObject; 4 | import beast.base.core.Description; 5 | import beast.base.core.Input; 6 | import beast.base.evolution.alignment.TaxonSet; 7 | import beast.base.inference.distribution.ParametricDistribution; 8 | 9 | /** 10 | * @author Joseph Heled 11 | */ 12 | 13 | @Description("Specification of a single calibration point of the calibrated Yule.") 14 | public class CalibrationPoint extends BEASTObject { 15 | final public Input taxonsetInput = new Input<>("taxonset", 16 | "Set of taxa. The prior distribution is applied to their TMRCA.", Input.Validate.REQUIRED); 17 | 18 | final public Input distInput = new Input<>("distr", 19 | "Prior distribution applied to time of clade MRCA", Input.Validate.REQUIRED); 20 | 21 | // public Input m_bIsMonophyleticInput = new Input<>("monophyletic", 22 | // "whether the taxon set is monophyletic (forms a clade without other taxa) or nor. Default is false.", false); 23 | 24 | final public Input forParentInput = new Input<>("parentOf", 25 | "Use time of clade parent. Default is false.", false); 26 | 27 | 28 | private TaxonSet t; 29 | private boolean forPar; 30 | private ParametricDistribution pd; 31 | 32 | public CalibrationPoint() {} 33 | 34 | @Override 35 | public void initAndValidate() { 36 | t = taxonsetInput.get(); 37 | forPar = forParentInput.get(); 38 | pd = distInput.get(); 39 | } 40 | 41 | public TaxonSet taxa() { 42 | return t; 43 | } 44 | 45 | public boolean forParent() { 46 | return forPar; 47 | } 48 | 49 | public ParametricDistribution dist() { 50 | return pd; 51 | } 52 | 53 | public double logPdf(final double x) { 54 | return pd.logDensity(x); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/beast/base/evolution/speciation/RandomGeneTree.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.speciation; 2 | 3 | import java.util.List; 4 | 5 | import beast.base.core.Description; 6 | import beast.base.core.Input; 7 | import beast.base.core.Input.Validate; 8 | import beast.base.evolution.tree.Node; 9 | import beast.base.evolution.tree.Tree; 10 | import beast.base.evolution.tree.coalescent.PopulationFunction; 11 | import beast.base.evolution.tree.coalescent.RandomTree; 12 | 13 | 14 | 15 | @Description("Generates a random gene tree conditioned on a species tree, such " + 16 | "that the root of the species tree is lower than any coalescent events in " + 17 | "the gene tree") 18 | public class RandomGeneTree extends RandomTree { 19 | final public Input speciesTreeInput = new Input<>("speciesTree", "The species tree in which this random gene tree needs to fit", Validate.REQUIRED); 20 | 21 | @Override 22 | public void initAndValidate() { 23 | super.initAndValidate(); 24 | } 25 | 26 | @Override 27 | public Node simulateCoalescentWithMax(List nodes, PopulationFunction demographic, final double maxHeight) { 28 | // sanity check - disjoint trees 29 | 30 | // if( ! Tree.Utils.allDisjoint(nodes) ) { 31 | // throw new RuntimeException("non disjoint trees"); 32 | // } 33 | 34 | if (nodes.size() == 0) { 35 | throw new IllegalArgumentException("empty nodes set"); 36 | } 37 | 38 | final double lowestHeight = speciesTreeInput.get().getRoot().getHeight(); 39 | 40 | for (int attempts = 0; attempts < 1000; ++attempts) { 41 | try { 42 | final List rootNode = simulateCoalescent(nodes, demographic, lowestHeight, maxHeight); 43 | if (rootNode.size() == 1) { 44 | return rootNode.get(0); 45 | } 46 | } catch (ConstraintViolatedException e) { 47 | // TODO: handle exception 48 | } 49 | } 50 | 51 | throw new RuntimeException("failed to merge trees after 1000 tries!"); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /src/beast/base/evolution/speciation/TreeTopFinder.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.speciation; 2 | 3 | 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | 7 | import beast.base.core.Description; 8 | import beast.base.core.Input; 9 | import beast.base.evolution.tree.Tree; 10 | import beast.base.inference.CalculationNode; 11 | 12 | 13 | @Description("Finds height of highest tree among a set of trees") 14 | public class TreeTopFinder extends CalculationNode { 15 | final public Input> treeInputs = new Input<>("tree", "set of trees to search among", new ArrayList<>()); 16 | 17 | List trees; 18 | 19 | double oldHeight; 20 | double height; 21 | 22 | @Override 23 | public void initAndValidate() { 24 | oldHeight = Double.NaN; 25 | trees = treeInputs.get(); 26 | height = calcHighestTreeHeight(); 27 | } 28 | 29 | public double getHighestTreeHeight() { 30 | return calcHighestTreeHeight(); 31 | } 32 | 33 | private double calcHighestTreeHeight() { 34 | double top = 0; 35 | for (Tree tree : trees) { 36 | top = Math.max(tree.getRoot().getHeight(), top); 37 | } 38 | return top; 39 | } 40 | 41 | @Override 42 | protected boolean requiresRecalculation() { 43 | double top = calcHighestTreeHeight(); 44 | if (top != height) { 45 | height = top; 46 | return true; 47 | } 48 | return false; 49 | } 50 | 51 | @Override 52 | protected void store() { 53 | oldHeight = height; 54 | super.store(); 55 | } 56 | 57 | @Override 58 | protected void restore() { 59 | height = oldHeight; 60 | super.restore(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/beast/base/evolution/substitutionmodel/EigenSystem.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.substitutionmodel; 2 | 3 | /** 4 | * @author Andrew Rambaut 5 | * @version $Id$ 6 | */ 7 | public interface EigenSystem { 8 | /** 9 | * Set the instantaneous rate matrix 10 | * This changes the values in matrix as side effect 11 | * @param matrix 12 | */ 13 | EigenDecomposition decomposeMatrix(double[][] matrix); 14 | } 15 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/TreeDistribution.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.tree; 2 | 3 | 4 | import java.util.List; 5 | import java.util.Random; 6 | 7 | import beast.base.core.Description; 8 | import beast.base.core.Input; 9 | import beast.base.core.Input.Validate; 10 | import beast.base.inference.Distribution; 11 | import beast.base.inference.State; 12 | 13 | 14 | @Description("Distribution on a tree, typically a prior such as Coalescent or Yule") 15 | public class TreeDistribution extends Distribution { 16 | final public Input treeInput = new Input<>("tree", "tree over which to calculate a prior or likelihood"); 17 | final public Input treeIntervalsInput = new Input<>("treeIntervals", "Intervals for a phylogenetic beast tree", Validate.XOR, treeInput); 18 | 19 | @Override 20 | public List getArguments() { 21 | return null; 22 | } 23 | 24 | @Override 25 | public List getConditions() { 26 | return null; 27 | } 28 | 29 | @Override 30 | public void sample(State state, Random random) { 31 | } 32 | 33 | @Override 34 | protected boolean requiresRecalculation() { 35 | final TreeIntervals ti = treeIntervalsInput.get(); 36 | if (ti != null) { 37 | //boolean d = ti.isDirtyCalculation(); 38 | //assert d; 39 | assert ti.isDirtyCalculation(); 40 | return true; 41 | } 42 | return treeInput.get().somethingIsDirty(); 43 | } 44 | 45 | /** Indicate that the tree distribution can deal with dated tips in the tree 46 | * Some tree distributions like the Yule prior cannot handle this. 47 | * @return true by default 48 | */ 49 | public boolean canHandleTipDates() { 50 | return true; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/TreeHeightLogger.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.tree; 2 | 3 | 4 | 5 | import java.io.PrintStream; 6 | 7 | import beast.base.core.Description; 8 | import beast.base.core.Function; 9 | import beast.base.core.Input; 10 | import beast.base.core.Loggable; 11 | import beast.base.core.Input.Validate; 12 | import beast.base.inference.CalculationNode; 13 | 14 | 15 | @Description("Logger to report height of a tree -- deprecated: use TreeStatLogger instead") 16 | @Deprecated 17 | public class TreeHeightLogger extends CalculationNode implements Loggable, Function { 18 | final public Input treeInput = new Input<>("tree", "tree to report height for.", Validate.REQUIRED); 19 | 20 | @Override 21 | public void initAndValidate() { 22 | // nothing to do 23 | } 24 | 25 | @Override 26 | public void init(PrintStream out) { 27 | final Tree tree = treeInput.get(); 28 | if (getID() == null || getID().matches("\\s*")) { 29 | out.print(tree.getID() + ".height\t"); 30 | } else { 31 | out.print(getID() + "\t"); 32 | } 33 | } 34 | 35 | @Override 36 | public void log(long sample, PrintStream out) { 37 | final Tree tree = treeInput.get(); 38 | out.print(tree.getRoot().getHeight() + "\t"); 39 | } 40 | 41 | @Override 42 | public void close(PrintStream out) { 43 | // nothing to do 44 | } 45 | 46 | @Override 47 | public int getDimension() { 48 | return 1; 49 | } 50 | 51 | @Override 52 | public double getArrayValue() { 53 | return treeInput.get().getRoot().getHeight(); 54 | } 55 | 56 | @Override 57 | public double getArrayValue(int dim) { 58 | return treeInput.get().getRoot().getHeight(); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/TreeInterface.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.tree; 2 | 3 | 4 | 5 | import java.util.List; 6 | 7 | import beast.base.evolution.alignment.TaxonSet; 8 | 9 | public interface TreeInterface { 10 | String getID(); 11 | 12 | int getLeafNodeCount(); 13 | int getInternalNodeCount(); 14 | int getNodeCount(); 15 | 16 | Node getRoot(); 17 | Node getNode(int i); 18 | Node [] getNodesAsArray(); 19 | 20 | List getExternalNodes(); 21 | List getInternalNodes(); 22 | 23 | TaxonSet getTaxonset(); 24 | 25 | boolean somethingIsDirty(); 26 | 27 | public void getMetaData(Node node, Double[] t, String pattern); 28 | public void setMetaData(Node node, Double[] t, String pattern); 29 | 30 | /* 31 | * Note that leaf nodes are always numbered 0,...,nodeCount-1 32 | * Internal nodes are numbered higher, but the root has no guaranteed 33 | * number. 34 | */ 35 | 36 | /** 37 | * @param node top of tree/sub tree (null defaults to whole tree) 38 | * @param nodes array to fill (null will result in creating a new one) 39 | * @return tree nodes in post-order, children before parents 40 | */ 41 | default Node[] listNodesPostOrder(Node node, Node[] nodes) { 42 | if (node == null) { 43 | node = getRoot(); 44 | } 45 | if (nodes == null) { 46 | // overall node count is cached, faster 47 | final int n = node == getRoot() ? getNodeCount() : node.getNodeCount(); 48 | nodes = new Node[n]; 49 | } 50 | getNodesPostOrder(node, nodes, 0); 51 | return nodes; 52 | } 53 | 54 | static int getNodesPostOrder(final Node node, final Node[] nodes, int pos) { 55 | //node.m_tree = this; 56 | for (final Node child : node.getChildren()) { 57 | pos = getNodesPostOrder(child, nodes, pos); 58 | } 59 | nodes[pos] = node; 60 | return pos + 1; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/TreeMetric.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.tree; 2 | 3 | /** 4 | * @author Alexei Drummond 5 | */ 6 | public interface TreeMetric { 7 | 8 | /** 9 | * Distance between two trees that may have different taxa sets but must have an overlap of taxa. 10 | * @param tree1 11 | * @param tree2 12 | * @return 13 | */ 14 | public double distance(TreeInterface tree1, TreeInterface tree2); 15 | 16 | 17 | /** 18 | * Distance between a tree and a reference tree. Must set the reference tree first using setReference 19 | * @param tree1 20 | * @return 21 | */ 22 | public double distance(TreeInterface tree); 23 | 24 | 25 | /** 26 | * Set the reference tree and cache. Faster than calling distance(tree1, tree2) everytime 27 | * @param ref 28 | */ 29 | public void setReference(TreeInterface ref); 30 | 31 | 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/coalescent/ScaledPopulationFunction.java: -------------------------------------------------------------------------------- 1 | package beast.base.evolution.tree.coalescent; 2 | 3 | 4 | import java.util.List; 5 | 6 | import beast.base.core.BEASTInterface; 7 | import beast.base.core.Description; 8 | import beast.base.core.Function; 9 | import beast.base.core.Input; 10 | import beast.base.core.Input.Validate; 11 | import beast.base.inference.CalculationNode; 12 | import beast.base.inference.parameter.RealParameter; 13 | 14 | 15 | /** 16 | * @author Joseph Heled 17 | * Date: 2/03/2011 18 | */ 19 | 20 | @Description("Scale a demographic function by a constant factor") 21 | public class ScaledPopulationFunction extends PopulationFunction.Abstract { 22 | final public Input popParameterInput = new Input<>("population", 23 | "population function to scale. ", Validate.REQUIRED); 24 | 25 | final public Input scaleFactorInput = new Input<>("factor", 26 | "scale population by this facor.", Validate.REQUIRED); 27 | 28 | public ScaledPopulationFunction() { 29 | } 30 | 31 | // Implementation of abstract methods 32 | 33 | @Override 34 | public List getParameterIds() { 35 | List ids = popParameterInput.get().getParameterIds(); 36 | if (scaleFactorInput.get() instanceof BEASTInterface) { 37 | ids.add(((BEASTInterface)scaleFactorInput.get()).getID()); 38 | } 39 | return ids; 40 | } 41 | 42 | @Override 43 | public double getPopSize(double t) { 44 | return popParameterInput.get().getPopSize(t) * scaleFactorInput.get().getArrayValue(); 45 | } 46 | 47 | @Override 48 | public double getIntensity(double t) { 49 | double intensity = popParameterInput.get().getIntensity(t); 50 | double scale = scaleFactorInput.get().getArrayValue(); 51 | return intensity / scale; 52 | } 53 | 54 | @Override 55 | public double getInverseIntensity(double x) { 56 | throw new RuntimeException("unimplemented"); 57 | } 58 | 59 | @Override 60 | protected boolean requiresRecalculation() { 61 | return ((CalculationNode) popParameterInput.get()).isDirtyCalculation() 62 | || ((CalculationNode)scaleFactorInput.get()).isDirtyCalculation(); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/treeparser/NewickLexer.g4: -------------------------------------------------------------------------------- 1 | lexer grammar NewickLexer; 2 | 3 | // Default mode rules 4 | 5 | SEMI: ';' ; 6 | COMMA: ',' ; 7 | OPENP: '(' ; 8 | CLOSEP: ')' ; 9 | COLON: ':' ; 10 | 11 | FLOAT_SCI: '-'? ((NNINT? ('.' D+)) | (NNINT ('.' D+)?)) ([eE] ('-'|'+')? D+); 12 | FLOAT : '-'? ((NNINT? ('.' D+)) | (NNINT ('.' D*))); 13 | INT : '-'? NNINT; 14 | fragment NNINT : '0' | NZD D* ; 15 | fragment NZD : [1-9] ; 16 | fragment D : [0-9] ; 17 | 18 | OPENA: '[&' -> mode(ATTRIB_MODE); 19 | 20 | WHITESPACE : [ \t\r\n]+ -> skip ; 21 | 22 | STRING : 23 | [a-zA-Z0-9|#*%/.\-+_&]+ // these chars don't need quotes 24 | | '"' .*? '"' 25 | | '\'' .*? '\'' 26 | ; 27 | 28 | // Attrib mode rules 29 | 30 | mode ATTRIB_MODE; 31 | 32 | EQ: '=' ; 33 | ACOMMA: ',' ; 34 | OPENV: '{' ; 35 | CLOSEV: '}' ; 36 | 37 | AFLOAT_SCI: '-'? ((NNINT? ('.' D+)) | (NNINT ('.' D+)?)) ([eE] '-'? D+); 38 | AFLOAT : '-'? ((NNINT? ('.' D+)) | (NNINT ('.' D*))); 39 | AINT : '-'? NNINT; 40 | 41 | AWHITESPACE : [ \t\r\n]+ -> skip ; 42 | 43 | ASTRING : 44 | [a-zA-Z0-9|#*%/.\-+_&:]+ // these chars don't need quotes 45 | | '"' .*? '"' 46 | | '\'' .*? '\'' 47 | ; 48 | 49 | CLOSEA: ']' -> mode(DEFAULT_MODE); 50 | 51 | ATTRIBWS : [ \t\r\n]+ -> skip ; 52 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/treeparser/NewickParser.g4: -------------------------------------------------------------------------------- 1 | parser grammar NewickParser; 2 | 3 | options { tokenVocab=NewickLexer; } 4 | 5 | tree: node ';'? EOF; 6 | 7 | node: ('(' node (COMMA node)* ')')? post ; 8 | 9 | post: label? nodeMeta=meta? (':' lengthMeta=meta? length=number)? ; 10 | 11 | label: number | STRING ; 12 | 13 | meta: '[&' attrib (ACOMMA attrib)* ']' ; 14 | 15 | attrib: attribKey=ASTRING '=' attribValue ; 16 | 17 | attribValue: attribNumber | ASTRING | vector; 18 | 19 | number: INT | FLOAT | FLOAT_SCI; 20 | attribNumber: AINT | AFLOAT | AFLOAT_SCI; 21 | 22 | vector: '{' attribValue (ACOMMA attribValue)* '}' ; 23 | 24 | -------------------------------------------------------------------------------- /src/beast/base/evolution/tree/treeparser/README: -------------------------------------------------------------------------------- 1 | To generate the java code from the parser, in this directory run 2 | 3 | java -jar antlr-complete.jar -o /tmp -visitor -listener -package beast.base.evolution.tree.treeparser *.g4 4 | 5 | where antlr-complete.jar is the complete version of jar, including the parser generator (not just the runtime). -------------------------------------------------------------------------------- /src/beast/base/inference/Evaluator.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference; 2 | 3 | /** 4 | * @author Andrew Rambaut 5 | * @version $Id$ 6 | */ 7 | public interface Evaluator { 8 | double evaluate(); 9 | } 10 | -------------------------------------------------------------------------------- /src/beast/base/inference/Runnable.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference; 2 | 3 | import beast.base.core.BEASTObject; 4 | import beast.base.core.Description; 5 | 6 | @Description("Entry point for running a Beast task, for instance an MCMC or other probabilistic " + 7 | "analysis, a simulation, etc.") 8 | public abstract class Runnable extends BEASTObject { 9 | 10 | /** entry point for anything runnable **/ 11 | abstract public void run() throws Exception; 12 | 13 | 14 | /** make sure whatever is runnable is valid, but do not run yet **/ 15 | public void validate() throws Exception {} 16 | 17 | /** 18 | * Set up information related to the file for (re)storing the State. 19 | * The Runnable implementation is responsible for making its 20 | * State synchronising with the file * 21 | * @param fileName 22 | * @param isRestoreFromFile 23 | */ 24 | public void setStateFile(final String fileName, final boolean isRestoreFromFile) { 25 | if (System.getProperty("state.file.name") != null) { 26 | stateFileName = System.getProperty("state.file.name"); 27 | } else { 28 | if (System.getProperty("file.name.prefix") != null) { 29 | stateFileName = System.getProperty("file.name.prefix") + fileName; 30 | } else { 31 | stateFileName = fileName; 32 | } 33 | } 34 | restoreFromFile = isRestoreFromFile; 35 | } 36 | 37 | /** 38 | * flag to indicate that the State should be restored from File at the start of the analysis * 39 | */ 40 | protected boolean restoreFromFile = false; 41 | 42 | /** 43 | * name of the file store the state in * 44 | */ 45 | protected String stateFileName = "state.backup.xml"; 46 | 47 | /** 48 | * indicate whether this runnable distinguishes partitions, like MCMC, or not 49 | * **/ 50 | public boolean hasPartitions() {return true;} 51 | } 52 | -------------------------------------------------------------------------------- /src/beast/base/inference/StateNodeInitialiser.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference; 2 | 3 | import java.util.List; 4 | 5 | /** 6 | * Typically, StateNodes are initialised through their inputs. However, there are initialisation scenarios 7 | * too complex for this approach to work. For example, initialisation may require additional information not 8 | * provided by the inputs, or several dependent beastObjects need to initialise together, 9 | * such as gene trees and a species tree. 10 | *

11 | * StateNodeInitialisers take one or more StateNodes as input and initializes them in initStateNodes(). 12 | * getInitialisedStateNodes() reports back which nodes has been initialized, but this is currently only used to 13 | * check for multiple initialiser for the same object. 14 | *

15 | * Like any other isEASTObject, a state initialiser must have an initAndValidate(), which is called once. 16 | * getInitialisedStateNodes(), on the other hand, may be called multiple times as its inputs change while the system 17 | * tries to establish a valid starting state. initAndValidate is executed in order that the XML parser see objects, 18 | * so the inputs are not guaranteed to be initialized at this time. initStateNodes is executed in order of appearance 19 | * in MCMC, so inputs requiring initialization are properly initialized when initStateNodes is called. 20 | * 21 | * @author remco 22 | */ 23 | public interface StateNodeInitialiser { 24 | 25 | /** 26 | * Called to set up start state. May be called multiple times. * 27 | */ 28 | void initStateNodes(); 29 | 30 | /** 31 | * @return list of StateNodes that are initialised 32 | * This information is used to ensure StateNode are not initialised more than once. 33 | * @param stateNodes 34 | */ 35 | public void getInitialisedStateNodes(List stateNodes); 36 | } 37 | -------------------------------------------------------------------------------- /src/beast/base/inference/distribution/Beta.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.distribution; 2 | 3 | import org.apache.commons.math.distribution.BetaDistributionImpl; 4 | import org.apache.commons.math.distribution.ContinuousDistribution; 5 | 6 | import beast.base.core.Description; 7 | import beast.base.core.Function; 8 | import beast.base.core.Input; 9 | import beast.base.inference.parameter.RealParameter; 10 | 11 | 12 | 13 | @Description("Beta distribution, used as prior. p(x;alpha,beta) = \frac{x^{alpha-1}(1-x)^{beta-1}} {B(alpha,beta)} " + 14 | "where B() is the beta function. " + 15 | "If the input x is a multidimensional parameter, each of the dimensions is considered as a " + 16 | "separate independent component.") 17 | public class Beta extends ParametricDistribution { 18 | final public Input alphaInput = new Input<>("alpha", "first shape parameter, defaults to 1"); 19 | final public Input betaInput = new Input<>("beta", "the other shape parameter, defaults to 1"); 20 | 21 | org.apache.commons.math.distribution.BetaDistribution m_dist = new BetaDistributionImpl(1, 1); 22 | 23 | @Override 24 | public void initAndValidate() { 25 | refresh(); 26 | } 27 | 28 | /** 29 | * make sure internal state is up to date * 30 | */ 31 | @SuppressWarnings("deprecation") 32 | void refresh() { 33 | double alpha; 34 | double beta; 35 | if (alphaInput.get() == null) { 36 | alpha = 1; 37 | } else { 38 | alpha = alphaInput.get().getArrayValue(); 39 | } 40 | if (betaInput.get() == null) { 41 | beta = 1; 42 | } else { 43 | beta = betaInput.get().getArrayValue(); 44 | } 45 | m_dist.setAlpha(alpha); 46 | m_dist.setBeta(beta); 47 | } 48 | 49 | @Override 50 | public ContinuousDistribution getDistribution() { 51 | refresh(); 52 | return m_dist; 53 | } 54 | 55 | @Override 56 | protected double getMeanWithoutOffset() { 57 | return m_dist.getAlpha() / (m_dist.getAlpha() + m_dist.getBeta()); 58 | } 59 | } // class Beta 60 | -------------------------------------------------------------------------------- /src/beast/base/inference/distribution/ChiSquare.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.distribution; 2 | 3 | 4 | import org.apache.commons.math.distribution.ChiSquaredDistributionImpl; 5 | import org.apache.commons.math.distribution.ContinuousDistribution; 6 | 7 | import beast.base.core.Description; 8 | import beast.base.core.Input; 9 | import beast.base.inference.parameter.IntegerParameter; 10 | 11 | 12 | 13 | @Description("Chi square distribution, f(x; k) = \\frac{1}{2^{k/2}Gamma(k/2)} x^{k/2-1} e^{-x/2} " + 14 | "If the input x is a multidimensional parameter, each of the dimensions is considered as a " + 15 | "separate independent component.") 16 | public class ChiSquare extends ParametricDistribution { 17 | final public Input dfInput = new Input<>("df", "degrees if freedin, defaults to 1"); 18 | 19 | org.apache.commons.math.distribution.ChiSquaredDistribution m_dist = new ChiSquaredDistributionImpl(1); 20 | 21 | @Override 22 | public void initAndValidate() { 23 | refresh(); 24 | } 25 | 26 | /** 27 | * make sure internal state is up to date * 28 | */ 29 | @SuppressWarnings("deprecation") 30 | void refresh() { 31 | int dF; 32 | if (dfInput.get() == null) { 33 | dF = 1; 34 | } else { 35 | dF = dfInput.get().getValue(); 36 | if (dF <= 0) { 37 | dF = 1; 38 | } 39 | } 40 | m_dist.setDegreesOfFreedom(dF); 41 | } 42 | 43 | @Override 44 | public ContinuousDistribution getDistribution() { 45 | refresh(); 46 | return m_dist; 47 | } 48 | 49 | } // class ChiSquare 50 | -------------------------------------------------------------------------------- /src/beast/base/inference/distribution/LogNormal.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.distribution; 2 | 3 | import beast.base.core.Description; 4 | 5 | /** 6 | * A subclass of LogNormalDistributionModel with a shorter, more user-friendly name. 7 | * This class provides exactly the same functionality as LogNormalDistributionModel 8 | * but can be referenced as "LogNormal" in XML and model scripts. 9 | */ 10 | @Description("A log-normal distribution with mean and variance parameters. Alias for LogNormalDistributionModel.") 11 | public class LogNormal extends LogNormalDistributionModel { 12 | // No need to override anything - this class simply provides a nicer name 13 | // while inheriting all functionality from LogNormalDistributionModel 14 | } -------------------------------------------------------------------------------- /src/beast/base/inference/distribution/OneOnX.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.distribution; 2 | 3 | 4 | import org.apache.commons.math.MathException; 5 | import org.apache.commons.math.distribution.ContinuousDistribution; 6 | import org.apache.commons.math.distribution.Distribution; 7 | 8 | import beast.base.core.Description; 9 | 10 | 11 | 12 | @Description("OneOnX distribution. f(x) = C/x for some normalizing constant C. " + 13 | "If the input x is a multidimensional parameter, each of the dimensions is considered as a " + 14 | "separate independent component.") 15 | public class OneOnX extends ParametricDistribution { 16 | 17 | ContinuousDistribution dist = new OneOnXImpl(); 18 | 19 | @Override 20 | public void initAndValidate() { 21 | } 22 | 23 | @Override 24 | public Distribution getDistribution() { 25 | return dist; 26 | } 27 | 28 | class OneOnXImpl implements ContinuousDistribution { 29 | 30 | @Override 31 | public double cumulativeProbability(double x) throws MathException { 32 | throw new MathException("Not implemented yet"); 33 | } 34 | 35 | @Override 36 | public double cumulativeProbability(double x0, double x1) throws MathException { 37 | throw new MathException("Not implemented yet"); 38 | } 39 | 40 | @Override 41 | public double inverseCumulativeProbability(double p) throws MathException { 42 | throw new MathException("Not implemented yet"); 43 | } 44 | 45 | @Override 46 | public double density(double x) { 47 | return 1 / x; 48 | } 49 | 50 | @Override 51 | public double logDensity(double x) { 52 | return -Math.log(x); 53 | } 54 | } // class OneOnXImpl 55 | 56 | 57 | } // class OneOnX 58 | -------------------------------------------------------------------------------- /src/beast/base/inference/distribution/Poisson.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.distribution; 2 | 3 | 4 | import org.apache.commons.math.distribution.PoissonDistributionImpl; 5 | 6 | import beast.base.core.Description; 7 | import beast.base.core.Function; 8 | import beast.base.core.Input; 9 | import beast.base.inference.parameter.RealParameter; 10 | 11 | 12 | @Description("Poisson distribution, used as prior f(k; lambda)=\\frac{lambda^k e^{-lambda}}{k!} " + 13 | "If the input x is a multidimensional parameter, each of the dimensions is considered as a " + 14 | "separate independent component.") 15 | public class Poisson extends ParametricDistribution { 16 | final public Input lambdaInput = new Input<>("lambda", "rate parameter, defaults to 1"); 17 | 18 | org.apache.commons.math.distribution.PoissonDistribution dist = new PoissonDistributionImpl(1); 19 | 20 | 21 | // Must provide empty constructor for construction by XML. Note that this constructor DOES NOT call initAndValidate(); 22 | public Poisson() { 23 | } 24 | 25 | public Poisson(RealParameter lambda) { 26 | 27 | try { 28 | initByName("lambda", lambda); 29 | } catch (Exception e) { 30 | e.printStackTrace(); 31 | throw new RuntimeException("Failed to initByName lambda parameter when constructing Poisson instance."); 32 | } 33 | } 34 | 35 | @Override 36 | public void initAndValidate() { 37 | refresh(); 38 | } 39 | 40 | /** 41 | * make sure internal state is up to date * 42 | */ 43 | @SuppressWarnings("deprecation") 44 | void refresh() { 45 | double m_fLambda; 46 | if (lambdaInput.get() == null) { 47 | m_fLambda = 1; 48 | } else { 49 | m_fLambda = lambdaInput.get().getArrayValue(); 50 | if (m_fLambda < 0) { 51 | m_fLambda = 1; 52 | } 53 | } 54 | dist.setMean(m_fLambda); 55 | } 56 | 57 | @Override 58 | public org.apache.commons.math.distribution.Distribution getDistribution() { 59 | refresh(); 60 | return dist; 61 | } 62 | 63 | @Override 64 | public double getMeanWithoutOffset() { 65 | return lambdaInput.get().getArrayValue(); 66 | } 67 | 68 | } // class Poisson 69 | -------------------------------------------------------------------------------- /src/beast/base/inference/operator/IntRandomWalkOperator.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.operator; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Input; 5 | import beast.base.core.Input.Validate; 6 | import beast.base.inference.Operator; 7 | import beast.base.inference.parameter.IntegerParameter; 8 | import beast.base.inference.util.InputUtil; 9 | import beast.base.util.Randomizer; 10 | 11 | 12 | @Description("A random walk operator that selects a random dimension of the integer parameter and perturbs the value a " + 13 | "random amount within +/- windowSize.") 14 | public class IntRandomWalkOperator extends Operator { 15 | final public Input windowSizeInput = 16 | new Input<>("windowSize", "the size of the window both up and down", Validate.REQUIRED); 17 | final public Input parameterInput = 18 | new Input<>("parameter", "the parameter to operate a random walk on.", Validate.REQUIRED); 19 | 20 | int windowSize = 1; 21 | 22 | @Override 23 | public void initAndValidate() { 24 | windowSize = windowSizeInput.get(); 25 | } 26 | 27 | /** 28 | * override this for proposals, 29 | * returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted * 30 | */ 31 | @Override 32 | public double proposal() { 33 | 34 | final IntegerParameter param = (IntegerParameter) InputUtil.get(parameterInput,this); 35 | 36 | final int i = Randomizer.nextInt(param.getDimension()); 37 | final int value = param.getValue(i); 38 | final int newValue = value + Randomizer.nextInt(2 * windowSize + 1) - windowSize; 39 | 40 | if (newValue < param.getLower() || newValue > param.getUpper()) { 41 | // invalid move, can be rejected immediately 42 | return Double.NEGATIVE_INFINITY; 43 | } 44 | if (newValue == value) { 45 | // this saves calculating the posterior 46 | return Double.NEGATIVE_INFINITY; 47 | } 48 | 49 | param.setValue(i, newValue); 50 | 51 | return 0.0; 52 | } 53 | 54 | @Override 55 | public void optimize(final double logAlpha) { 56 | // nothing to optimise 57 | } 58 | 59 | } // class IntRandomWalkOperator -------------------------------------------------------------------------------- /src/beast/base/inference/operator/IntUniformOperator.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.operator; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Input; 5 | import beast.base.core.Log; 6 | import beast.base.core.Input.Validate; 7 | import beast.base.inference.Operator; 8 | import beast.base.inference.parameter.IntegerParameter; 9 | import beast.base.inference.util.InputUtil; 10 | import beast.base.util.Randomizer; 11 | 12 | 13 | @Description("A uniform random operator that selects a random dimension of the integer parameter and picks a new random value within the bounds.") 14 | @Deprecated 15 | public class IntUniformOperator extends Operator { 16 | final public Input parameterInput = new Input<>("parameter", "the parameter to operate a random walk on.", Validate.REQUIRED); 17 | 18 | 19 | @Override 20 | public void initAndValidate() { 21 | Log.warning.println("\n\nIntUniformOperator is depracated. Use UniformOperator instead.\n\n"); 22 | } 23 | 24 | /** 25 | * override this for proposals, 26 | * returns log of hastingRatio, or Double.NEGATIVE_INFINITY if proposal should not be accepted * 27 | */ 28 | @Override 29 | public double proposal() { 30 | 31 | IntegerParameter param = (IntegerParameter) InputUtil.get(parameterInput, this); 32 | 33 | int i = Randomizer.nextInt(param.getDimension()); 34 | int newValue = Randomizer.nextInt(param.getUpper() - param.getLower() + 1) + param.getLower(); 35 | 36 | param.setValue(i, newValue); 37 | 38 | return 0.0; 39 | } 40 | 41 | @Override 42 | public void optimize(double logAlpha) { 43 | // nothing to optimise 44 | } 45 | 46 | } // class IntUniformOperator -------------------------------------------------------------------------------- /src/beast/base/inference/operator/kernel/KernelOperator.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.operator.kernel; 2 | 3 | import beast.base.core.Description; 4 | import beast.base.core.Input; 5 | import beast.base.inference.Operator; 6 | 7 | 8 | @Description("Operator with a flexible kernel distribution") 9 | public abstract class KernelOperator extends Operator { 10 | public final Input kernelDistributionInput = new Input<>("kernelDistribution", "provides sample distribution for proposals", 11 | KernelDistribution.newDefaultKernelDistribution()); 12 | 13 | protected KernelDistribution kernelDistribution; 14 | 15 | @Override 16 | public void initAndValidate() { 17 | kernelDistribution = kernelDistributionInput.get(); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/beast/base/inference/parameter/BooleanParameterList.java: -------------------------------------------------------------------------------- 1 | package beast.base.inference.parameter; 2 | 3 | import java.util.List; 4 | 5 | import beast.base.core.Description; 6 | 7 | /** 8 | * @author Tim Vaughan 9 | */ 10 | @Description("State node describing a list of boolean parameters.") 11 | public class BooleanParameterList extends GeneralParameterList { 12 | 13 | @Override 14 | public void initAndValidate() { 15 | lowerBound = false; 16 | upperBound = true; 17 | 18 | super.initAndValidate(); 19 | } 20 | 21 | @Override 22 | protected void readStateFromString(String[] boundsString, 23 | List parameterValueStrings, 24 | List keys) { 25 | 26 | lowerBound = Boolean.parseBoolean(boundsString[0]); 27 | upperBound = Boolean.parseBoolean(boundsString[1]); 28 | 29 | pList.clear(); 30 | 31 | for (int pidx=0; pidx 10 | */ 11 | @Description("State node describing a list of integer-valued parameters.") 12 | public class IntegerParameterList extends GeneralParameterList { 13 | 14 | final public Input lowerBoundInput = new Input<>("lower", 15 | "Lower bound on parameter values.", Integer.MIN_VALUE+1); 16 | final public Input upperBoundInput = new Input<>("upper", 17 | "Upper bound on parameter values.", Integer.MAX_VALUE-1); 18 | 19 | @Override 20 | public void initAndValidate() { 21 | lowerBound = lowerBoundInput.get(); 22 | upperBound = upperBoundInput.get(); 23 | 24 | super.initAndValidate(); 25 | } 26 | 27 | @Override 28 | protected void readStateFromString(String[] boundsString, 29 | List parameterValueStrings, 30 | List keys) { 31 | 32 | lowerBound = Integer.parseInt(boundsString[0]); 33 | upperBound = Integer.parseInt(boundsString[1]); 34 | 35 | pList.clear(); 36 | 37 | for (int pidx=0; pidx 10 | */ 11 | @Description("State node describing a list of real-valued parameters.") 12 | public class RealParameterList extends GeneralParameterList { 13 | 14 | final public Input lowerBoundInput = new Input<>("lower", 15 | "Lower bound on parameter values.", Double.NEGATIVE_INFINITY); 16 | final public Input upperBoundInput = new Input<>("upper", 17 | "Upper bound on parameter values.", Double.POSITIVE_INFINITY); 18 | 19 | @Override 20 | public void initAndValidate() { 21 | lowerBound = lowerBoundInput.get(); 22 | upperBound = upperBoundInput.get(); 23 | 24 | super.initAndValidate(); 25 | } 26 | 27 | @Override 28 | protected void readStateFromString(String[] boundsString, 29 | List parameterValueStrings, 30 | List keys) { 31 | 32 | lowerBound = Double.parseDouble(boundsString[0]); 33 | upperBound = Double.parseDouble(boundsString[1]); 34 | 35 | pList.clear(); 36 | 37 | for (int pidx=0; pidx 16 | * Only Operators should call this method. 17 | * Also Operators should never call Input.get(), always Input.get(operator). 18 | * 19 | * @param operator 20 | * @return 21 | */ 22 | static public StateNode get(Input input, final Operator operator) { 23 | return ((StateNode) input.get()).getCurrentEditable(operator); 24 | } 25 | 26 | /** 27 | * Return the dirtiness state for this input. 28 | * For a StateNode or list of StateNodes, report whether for any something is dirty, 29 | * for a CalcationNode or list of CalculationNodes, report whether any is dirty. 30 | * Otherwise, return false. 31 | * * 32 | */ 33 | static public boolean isDirty(Input input) { 34 | final Object value = input.get(); 35 | 36 | if (value == null) { 37 | return false; 38 | } 39 | 40 | if (value instanceof StateNode) { 41 | return ((StateNode) value).somethingIsDirty(); 42 | } 43 | 44 | if (value instanceof CalculationNode) { 45 | return ((CalculationNode) value).isDirtyCalculation(); 46 | } 47 | 48 | if (value instanceof List) { 49 | for (final Object obj : (List) value) { 50 | if (obj instanceof CalculationNode && ((CalculationNode) obj).isDirtyCalculation()) { 51 | return true; 52 | } else if (obj instanceof StateNode && ((StateNode) obj).somethingIsDirty()) { 53 | return true; 54 | } 55 | } 56 | } 57 | 58 | return false; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /src/beast/base/math/MathUtils.java: -------------------------------------------------------------------------------- 1 | package beast.base.math; 2 | 3 | /** 4 | * Methods from MathUtils in BEAST1 5 | */ 6 | public class MathUtils { 7 | /** 8 | * Returns sqrt(a^2 + b^2) without under/overflow. 9 | */ 10 | public static double hypot(double a, double b) { 11 | double r; 12 | 13 | if (Math.abs(a) > Math.abs(b)) { 14 | r = b/a; 15 | r = Math.abs(a)*Math.sqrt(1+r*r); 16 | } else if (b != 0) { 17 | r = a/b; 18 | r = Math.abs(b)*Math.sqrt(1+r*r); 19 | } else { 20 | r = 0.0; 21 | } 22 | return r; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/beast/base/math/matrixalgebra/CholeskyDecomposition.java: -------------------------------------------------------------------------------- 1 | package beast.base.math.matrixalgebra; 2 | 3 | import beast.base.core.Description; 4 | 5 | /** 6 | * Created by IntelliJ IDEA. 7 | * User: msuchard 8 | * Date: Jan 12, 2007 9 | * Time: 9:05:44 PM 10 | * To change this template use File | Settings | File Templates. 11 | */ 12 | @Description("Class ported from BEAST1") 13 | public class CholeskyDecomposition { 14 | 15 | /** 16 | * Dimension of square matrix 17 | */ 18 | private int n; 19 | 20 | public boolean isSPD() { 21 | return isspd; 22 | } 23 | 24 | /** 25 | * Symmetric and positive definite flag. 26 | */ 27 | private boolean isspd; 28 | 29 | public double[][] getL() { 30 | return L; 31 | } 32 | 33 | private double[][] L; 34 | 35 | public CholeskyDecomposition(double[][] A) throws IllegalDimension { 36 | 37 | n = A.length; 38 | L = new double[n][n]; 39 | isspd = (A[0].length == n); 40 | if (!isspd) 41 | throw new IllegalDimension("Cholesky decomposition is only defined for square matrices"); 42 | // Main loop. 43 | for (int j = 0; j < n; j++) { 44 | double[] Lrowj = L[j]; 45 | double d = 0.0; 46 | for (int k = 0; k < j; k++) { 47 | double[] Lrowk = L[k]; 48 | double s = 0.0; 49 | for (int i = 0; i < k; i++) { 50 | s += Lrowk[i] * Lrowj[i]; 51 | } 52 | Lrowj[k] = s = (A[j][k] - s) / L[k][k]; 53 | d = d + s * s; 54 | isspd = isspd & (A[k][j] == A[j][k]); 55 | } 56 | d = A[j][j] - d; 57 | isspd = isspd & (d > 0.0); 58 | L[j][j] = Math.sqrt(Math.max(d, 0.0)); 59 | /*for (int k = j+1; k < n; k++) { 60 | L[j][k] = 0.0; 61 | }*/ 62 | } 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /src/beast/base/math/matrixalgebra/IllegalDimension.java: -------------------------------------------------------------------------------- 1 | /* 2 | * IllegalDimension.java 3 | * 4 | * Copyright (C) 2002-2006 Alexei Drummond and Andrew Rambaut 5 | * 6 | * This file is part of BEAST. 7 | * See the NOTICE file distributed with this work for additional 8 | * information regarding copyright ownership and licensing. 9 | * 10 | * BEAST is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as 12 | * published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * BEAST is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with BEAST; if not, write to the 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 | * Boston, MA 02110-1301 USA 24 | */ 25 | 26 | package beast.base.math.matrixalgebra; 27 | 28 | /** 29 | * @author Didier H. Besset 30 | */ 31 | public class IllegalDimension extends Exception { 32 | 33 | /** 34 | * 35 | */ 36 | private static final long serialVersionUID = 8101918570370620261L; 37 | /** 38 | * DhbIllegalDimension constructor comment. 39 | */ 40 | public IllegalDimension() { 41 | super(); 42 | } 43 | /** 44 | * DhbIllegalDimension constructor comment. 45 | * @param s java.lang.String 46 | */ 47 | public IllegalDimension(String s) { 48 | super(s); 49 | } 50 | } -------------------------------------------------------------------------------- /src/beast/base/math/matrixalgebra/NonSymmetricComponents.java: -------------------------------------------------------------------------------- 1 | /* 2 | * NonSymmetricComponents.java 3 | * 4 | * Copyright (C) 2002-2006 Alexei Drummond and Andrew Rambaut 5 | * 6 | * This file is part of BEAST. 7 | * See the NOTICE file distributed with this work for additional 8 | * information regarding copyright ownership and licensing. 9 | * 10 | * BEAST is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as 12 | * published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * BEAST is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with BEAST; if not, write to the 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 | * Boston, MA 02110-1301 USA 24 | */ 25 | 26 | package beast.base.math.matrixalgebra; 27 | 28 | /** 29 | * @author Didier H. Besset 30 | */ 31 | public class NonSymmetricComponents extends Exception { 32 | 33 | /** 34 | * 35 | */ 36 | private static final long serialVersionUID = 9046634992672041256L; 37 | /** 38 | * DhbNonSymmetricComponents constructor comment. 39 | */ 40 | public NonSymmetricComponents() { 41 | super(); 42 | } 43 | /** 44 | * DhbNonSymmetricComponents constructor comment. 45 | * @param s java.lang.String 46 | */ 47 | public NonSymmetricComponents(String s) { 48 | super(s); 49 | } 50 | } -------------------------------------------------------------------------------- /src/beast/base/parser/InputType.java: -------------------------------------------------------------------------------- 1 | package beast.base.parser; 2 | 3 | /** helper class that shares common properties of Inputs and Param annotations **/ 4 | public class InputType { 5 | 6 | /** name of Input or Param annotation **/ 7 | String name; 8 | 9 | /** type of Input or Param annotation **/ 10 | Class type; 11 | 12 | /** whether this is Input or Param annotation **/ 13 | boolean isInput; 14 | 15 | /** default value when no value is specified, if any **/ 16 | Object defaultValue; 17 | 18 | /** c'tor **/ 19 | public InputType(String name, Class type, boolean isInput, Object defaultValue) { 20 | this.name = name; 21 | this.type = type; 22 | this.isInput = isInput; 23 | this.defaultValue = defaultValue; 24 | } 25 | 26 | 27 | /** getters & setters **/ 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public Class getType() { 37 | return type; 38 | } 39 | 40 | public void setType(Class type) { 41 | this.type = type; 42 | } 43 | 44 | public boolean isInput() { 45 | return isInput; 46 | } 47 | 48 | public void setInput(boolean isInput) { 49 | this.isInput = isInput; 50 | } 51 | 52 | 53 | public Object getDefaultValue() { 54 | return defaultValue; 55 | } 56 | 57 | 58 | public void setDefaultValue(Object defaultValue) { 59 | this.defaultValue = defaultValue; 60 | } 61 | 62 | @Override 63 | public String toString() { 64 | return getName() + " " + getType().getName() + " " + isInput() + " " + getDefaultValue(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/beast/base/parser/NexusParserListener.java: -------------------------------------------------------------------------------- 1 | package beast.base.parser; 2 | 3 | import beast.base.evolution.tree.Tree; 4 | 5 | /** 6 | * @author Alexei Drummond 7 | */ 8 | public interface NexusParserListener { 9 | 10 | /** 11 | * This method is called to alert a listener that a tree has been parsed by the nexus parser 12 | * @param treeIndex the index of the tree (starting from zero) 13 | * @param tree the tree that has been parsed 14 | */ 15 | void treeParsed(int treeIndex, Tree tree); 16 | } 17 | -------------------------------------------------------------------------------- /src/beast/base/parser/OutputUtils.java: -------------------------------------------------------------------------------- 1 | package beast.base.parser; 2 | 3 | 4 | import java.text.DecimalFormat; 5 | import java.text.DecimalFormatSymbols; 6 | import java.util.List; 7 | import java.util.Locale; 8 | 9 | /** 10 | * some useful methods 11 | * 12 | * @author Remco Bouckaert 13 | * @author Walter Xie 14 | */ 15 | public class OutputUtils { 16 | public final static String SPACE = " "; 17 | 18 | public static String format(String s) { 19 | return format(s, SPACE); 20 | } 21 | public static String format(String s, String space) { 22 | while (s.length() < 8) { 23 | s += " "; 24 | } 25 | return s + space; 26 | } 27 | 28 | public static String format(Double d) { 29 | if (Double.isNaN(d)) { 30 | return "NaN "; 31 | } 32 | if (Math.abs(d) > 1e-4 || d == 0) { 33 | DecimalFormat f = new DecimalFormat("#0.######", new DecimalFormatSymbols(Locale.US)); 34 | String str = f.format(d); 35 | if (str.length() > 8) { 36 | str = str.substring(0, 8); 37 | } 38 | while (str.length() < 8) { 39 | str += " "; 40 | } 41 | return str; 42 | } else { 43 | DecimalFormat f = new DecimalFormat("0.##E0", new DecimalFormatSymbols(Locale.US)); 44 | String str = f.format(d); 45 | if (str.length() > 8) { 46 | String [] strs = str.split("E"); 47 | str = strs[0].substring(0, 8 - strs[1].length() - 1) + "E" + strs[1]; 48 | } 49 | while (str.length() < 8) { 50 | str += " "; 51 | } 52 | return str; 53 | } 54 | } 55 | 56 | public static String toString(List list) { 57 | String s = ""; 58 | for (int i = 0; i < list.size(); i++) { 59 | if (i > 0) s += ", "; 60 | Object o = list.get(i); 61 | s += o.toString(); 62 | } 63 | return s; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/beast/base/parser/PartitionContext.java: -------------------------------------------------------------------------------- 1 | package beast.base.parser; 2 | 3 | 4 | import beast.base.core.BEASTInterface; 5 | import beast.base.evolution.likelihood.GenericTreeLikelihood; 6 | 7 | public class PartitionContext { 8 | public String partition; 9 | public String siteModel; 10 | public String clockModel; 11 | public String tree; 12 | 13 | public PartitionContext() {} 14 | 15 | public PartitionContext(String partition) { 16 | this.partition = partition; 17 | siteModel = partition; 18 | clockModel = partition; 19 | tree = partition; 20 | } 21 | 22 | public PartitionContext(String partition, 23 | String siteModel, 24 | String clockModel, 25 | String tree 26 | ) { 27 | this.partition = partition; 28 | this.siteModel = siteModel; 29 | this.clockModel = clockModel; 30 | this.tree = tree; 31 | } 32 | 33 | public PartitionContext(GenericTreeLikelihood treeLikelihood) { 34 | String id = treeLikelihood.dataInput.get().getID(); 35 | id = parsePartition(id); 36 | this.partition = id; 37 | if (treeLikelihood.branchRateModelInput.get() != null) { 38 | id = treeLikelihood.branchRateModelInput.get().getID(); 39 | id = parsePartition(id); 40 | } 41 | this.clockModel = id; 42 | id = ((BEASTInterface) treeLikelihood.siteModelInput.get()).getID(); 43 | id = parsePartition(id); 44 | this.siteModel = id; 45 | id = treeLikelihood.treeInput.get().getID(); 46 | id = parsePartition(id); 47 | this.tree = id; 48 | } 49 | 50 | 51 | static public String parsePartition(String id) { 52 | String partition = id.substring(id.indexOf('.') + 1); 53 | if (partition.indexOf(':') >= 0) { 54 | partition = partition.substring(partition.indexOf(':') + 1); 55 | } 56 | return partition; 57 | } 58 | 59 | @Override 60 | public String toString() { 61 | return partition + "," + siteModel + "," + clockModel + "," + tree; 62 | } 63 | 64 | @Override 65 | public boolean equals(Object obj) { 66 | if (obj == null) { 67 | return false; 68 | } 69 | if (obj instanceof PartitionContext) { 70 | PartitionContext other = (PartitionContext) obj; 71 | return other.partition.equals(partition) && 72 | other.siteModel.equals(siteModel) && 73 | other.clockModel.equals(clockModel) && 74 | other.tree.equals(tree); 75 | } 76 | return false; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/beast/base/parser/XMLModelLogger.java: -------------------------------------------------------------------------------- 1 | package beast.base.parser; 2 | 3 | import beast.base.core.BEASTInterface; 4 | import beast.base.inference.ModelLogger; 5 | 6 | 7 | /** Hack to get around dependency of beast.inferece.Logger to XMLProducer **/ 8 | public class XMLModelLogger extends ModelLogger { 9 | 10 | 11 | @Override 12 | protected int canHandleObject(Object o) { 13 | if (o instanceof BEASTInterface) { 14 | return 1; 15 | } 16 | return -1; 17 | } 18 | 19 | 20 | @Override 21 | public String modelToStringImp(Object o) { 22 | return new XMLProducer().modelToXML((BEASTInterface) o); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/beast/base/util/CollectionUtils.java: -------------------------------------------------------------------------------- 1 | package beast.base.util; 2 | 3 | 4 | import java.util.Arrays; 5 | import java.util.BitSet; 6 | import java.util.List; 7 | 8 | /** 9 | * some useful methods 10 | */ 11 | public class CollectionUtils { 12 | 13 | // not use set because hard to get element given index 14 | public static List intersection(List list1, List list2) { 15 | list1.retainAll(list2); 16 | return list1; 17 | } 18 | 19 | public static List intersection(E[] array1, E[] array2) { 20 | return intersection(Arrays.asList(array1), Arrays.asList(array2)); 21 | } 22 | 23 | public static int indexof(E label, E[] m_sLabels) { 24 | for (int i = 0; i < m_sLabels.length ; i++) { 25 | if (m_sLabels[i].equals(label)) { 26 | return i; 27 | } 28 | } 29 | return -1; 30 | } 31 | 32 | /** 33 | * 34 | * @param array the array to be converted into list 35 | * @param fromIndex the index of the first element, inclusive, to be sorted 36 | * @param toIndex the index of the last element, exclusive, to be sorted 37 | * @return 38 | */ 39 | public static List toList(E[] array, int fromIndex, int toIndex) { 40 | List list = Arrays.asList(array); 41 | return list.subList(fromIndex, toIndex); 42 | } 43 | 44 | /** 45 | * very inefficient, but Java wonderful bitset has no subset op 46 | * perhaps using bit iterator would be faster, I can't be bothered. 47 | * @param x 48 | * @param y 49 | * @return 50 | */ 51 | public static boolean isSubSet(BitSet x, BitSet y) { 52 | y = (BitSet) y.clone(); 53 | y.and(x); 54 | return y.equals(x); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/beast/base/util/CredibleSet.java: -------------------------------------------------------------------------------- 1 | package beast.base.util; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | /** 7 | * Credible Set results 8 | * 9 | * @author Walter Xie 10 | */ 11 | public class CredibleSet { 12 | 13 | public List credibleSetList; 14 | 15 | final double credSetProbability; 16 | 17 | public int sumFrequency = 0; 18 | 19 | public int targetIndex = -1; 20 | public double targetProb = 0.0; 21 | public double targetCum = 1.0; 22 | 23 | public CredibleSet(double credSetProbability) { 24 | credibleSetList = new ArrayList<>(); 25 | this.credSetProbability = credSetProbability; 26 | } 27 | 28 | public void setCredibleSetList(T target, FrequencySet frequencySet) { 29 | int total = frequencySet.getSumFrequency(); 30 | 31 | for (int i = 0; i < frequencySet.size(); i++) { 32 | final int freq = frequencySet.getFrequency(i); 33 | final double prop = ((double) freq) / total; 34 | 35 | sumFrequency += freq; 36 | final double sumProp = ((double) sumFrequency) / (double)total; 37 | 38 | T obj = frequencySet.get(i); 39 | credibleSetList.add(obj); 40 | if (target != null && obj.equals(target)) { 41 | targetIndex = i + 1; 42 | targetProb = prop; 43 | targetCum = sumProp; 44 | } 45 | 46 | if (sumProp >= credSetProbability) { 47 | break; 48 | } 49 | } 50 | } 51 | 52 | /** 53 | * get frequency of ith object 54 | */ 55 | public int getFrequency(int i, FrequencySet frequencySet) { 56 | return frequencySet.getFrequency(credibleSetList.get(i)); 57 | } 58 | } -------------------------------------------------------------------------------- /src/beast/base/util/FileUtils.java: -------------------------------------------------------------------------------- 1 | package beast.base.util; 2 | 3 | import java.io.BufferedReader; 4 | import java.io.File; 5 | import java.io.FileReader; 6 | import java.io.FileWriter; 7 | import java.io.IOException; 8 | 9 | public class FileUtils { 10 | 11 | 12 | static public String load(String fileName) throws IOException { 13 | return load(new File(fileName)); 14 | } // load 15 | 16 | static public String load(File file) throws IOException { 17 | BufferedReader fin = new BufferedReader(new FileReader(file)); 18 | StringBuffer buf = new StringBuffer(); 19 | String str = null; 20 | while (fin.ready()) { 21 | str = fin.readLine(); 22 | buf.append(str); 23 | buf.append('\n'); 24 | } 25 | fin.close(); 26 | return buf.toString(); 27 | } // load 28 | 29 | 30 | public void save(String fileName, String text) throws IOException { 31 | save(new File(fileName), text); 32 | } // save 33 | 34 | public void save(File file, String text) throws IOException { 35 | FileWriter outfile = new FileWriter(file); 36 | outfile.write(text); 37 | outfile.close(); 38 | } // save 39 | } 40 | -------------------------------------------------------------------------------- /src/beast/pkgmgmt/PackageDependency.java: -------------------------------------------------------------------------------- 1 | package beast.pkgmgmt; 2 | 3 | 4 | /** 5 | * modified by Walter Xie 6 | */ 7 | /** BEAUti beastObject dependency class **/ 8 | public class PackageDependency { 9 | public final String dependencyName; 10 | public final PackageVersion atLeast, atMost; 11 | 12 | public PackageDependency(String dependencyName, 13 | PackageVersion minimumVersion, 14 | PackageVersion maximumVersion) { 15 | if (dependencyName.equals("beast2")) { 16 | dependencyName = PackageManager.BEAST_PACKAGE_NAME; 17 | } 18 | this.dependencyName = dependencyName; 19 | 20 | atLeast = minimumVersion; 21 | atMost = maximumVersion; 22 | } 23 | 24 | /** 25 | * Test to see whether given version of package satisfies 26 | * version range of this package dependency. 27 | * 28 | * @param version version of package to check 29 | * @return true iff version meets criterion 30 | */ 31 | public boolean isMetBy(PackageVersion version) { 32 | return (atLeast == null || version.compareTo(atLeast)>=0) 33 | && (atMost == null || version.compareTo(atMost)<=0); 34 | } 35 | 36 | public String getRangeString() { 37 | if (atLeast != null && atMost != null) 38 | return "versions " + atLeast + " to " + atMost; 39 | 40 | if (atLeast != null) 41 | return "version " + atLeast + " or greater"; 42 | 43 | return "version " + atMost + " or lesser"; 44 | } 45 | 46 | @Override 47 | public String toString() { 48 | return dependencyName + " " + getRangeString(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/beast/pkgmgmt/icons/beauti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/CompEvol/beast2/2e27586452142b5642989bf600fc41df23243254/src/beast/pkgmgmt/icons/beauti.png -------------------------------------------------------------------------------- /src/beast/pkgmgmt/launcher/AppLauncherLauncher.java: -------------------------------------------------------------------------------- 1 | package beast.pkgmgmt.launcher; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.InvocationTargetException; 5 | 6 | public class AppLauncherLauncher extends BeastLauncher { 7 | /** 8 | * Loads beast.jar and launches AppStore 9 | * 10 | * This class should be compiled against 1.6 and packaged by itself. The 11 | * remained of BEAST can be compiled against Java 1.7 or higher 12 | * @throws IOException 13 | * @throws InvocationTargetException 14 | * @throws IllegalArgumentException 15 | * @throws IllegalAccessException 16 | * @throws ClassNotFoundException 17 | * @throws SecurityException 18 | * @throws NoSuchMethodException 19 | * **/ 20 | public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { 21 | if (javaVersionCheck("AppLauncher")) { 22 | String classpath = getPath(false, null); 23 | run(classpath, "beastfx.app.tools.AppLauncher", args); 24 | } 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/beast/pkgmgmt/launcher/BeautiLauncher.java: -------------------------------------------------------------------------------- 1 | package beast.pkgmgmt.launcher; 2 | 3 | 4 | 5 | import java.io.IOException; 6 | import java.lang.reflect.InvocationTargetException; 7 | 8 | /** 9 | * Loads beast.jar and launches BEAUti through the Beauti class 10 | * 11 | * This class should be compiled against 1.6 and packaged by itself. 12 | * The remained of BEAST can be compiled against Java 1.8 13 | * **/ 14 | public class BeautiLauncher extends BeastLauncher { 15 | 16 | public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { 17 | // Utils6.startSplashScreen(); 18 | if (javaVersionCheck("BEAUti")) { 19 | // loadBEASTJars(); 20 | BeastLauncher.testCudaStatusOnMac(); 21 | String classpath = getPath(false, null); 22 | run(classpath, "beastfx.app.beauti.Beauti", args); 23 | } 24 | // Utils6.endSplashScreen(); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/beast/pkgmgmt/launcher/LogCombinerLauncher.java: -------------------------------------------------------------------------------- 1 | package beast.pkgmgmt.launcher; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.InvocationTargetException; 5 | 6 | /** Launches log-combiner 7 | * @see BeastLauncher 8 | * **/ 9 | public class LogCombinerLauncher extends BeastLauncher { 10 | 11 | public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { 12 | if (javaVersionCheck("LogCombiner")) { 13 | String classpath = getPath(false, null); 14 | run(classpath, "beastfx.app.tools.LogCombiner", args); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /src/beast/pkgmgmt/launcher/TreeAnnotatorLauncher.java: -------------------------------------------------------------------------------- 1 | package beast.pkgmgmt.launcher; 2 | 3 | import java.io.IOException; 4 | import java.lang.reflect.InvocationTargetException; 5 | 6 | /** Launches TreeAnnotator 7 | * @see BeastLauncher 8 | * **/ 9 | public class TreeAnnotatorLauncher extends BeastLauncher { 10 | 11 | public static void main(String[] args) throws NoSuchMethodException, SecurityException, ClassNotFoundException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException { 12 | if (javaVersionCheck("TreeAnnotator")) { 13 | String classpath = getPath(false, null); 14 | run(classpath, "beastfx.app.treeannotator.TreeAnnotator", args); 15 | } 16 | } 17 | 18 | } 19 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/analysis/BivariateRealFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.analysis; 19 | 20 | import org.apache.commons.math.FunctionEvaluationException; 21 | 22 | 23 | /** 24 | * An interface representing a bivariate real function. 25 | * 26 | * @version $Revision: 924453 $ $Date: 2010-03-17 16:05:20 -0400 (Wed, 17 Mar 2010) $ 27 | * @since 2.1 28 | */ 29 | public interface BivariateRealFunction { 30 | 31 | /** 32 | * Compute the value for the function. 33 | * 34 | * @param x abscissa for which the function value should be computed 35 | * @param y ordinate for which the function value should be computed 36 | * @return the value 37 | * @throws FunctionEvaluationException if the function evaluation fails 38 | */ 39 | double value(double x, double y) throws FunctionEvaluationException; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/analysis/DifferentiableUnivariateRealFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.analysis; 18 | 19 | /** 20 | * Extension of {@link UnivariateRealFunction} representing a differentiable univariate real function. 21 | * 22 | * @version $Revision: 811786 $ $Date: 2009-09-06 05:36:08 -0400 (Sun, 06 Sep 2009) $ 23 | */ 24 | public interface DifferentiableUnivariateRealFunction 25 | extends UnivariateRealFunction { 26 | 27 | /** 28 | * Returns the derivative of the function 29 | * 30 | * @return the derivative function 31 | */ 32 | UnivariateRealFunction derivative(); 33 | 34 | } 35 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/analysis/MultivariateRealFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.analysis; 19 | 20 | import org.apache.commons.math.FunctionEvaluationException; 21 | 22 | /** 23 | * An interface representing a multivariate real function. 24 | * 25 | * @version $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $ 26 | * @since 2.0 27 | */ 28 | public interface MultivariateRealFunction { 29 | 30 | /** 31 | * Compute the value for the function at the given point. 32 | * 33 | * @param point point at which the function must be evaluated 34 | * @return function value for the given point 35 | * @throws FunctionEvaluationException if the function evaluation fails 36 | * @throws IllegalArgumentException if points dimension is wrong 37 | */ 38 | double value(double[] point) 39 | throws FunctionEvaluationException, IllegalArgumentException; 40 | 41 | } 42 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/analysis/UnivariateRealFunction.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.analysis; 18 | 19 | import org.apache.commons.math.FunctionEvaluationException; 20 | 21 | /** 22 | * An interface representing a univariate real function. 23 | * 24 | * @version $Revision: 811786 $ $Date: 2009-09-06 05:36:08 -0400 (Sun, 06 Sep 2009) $ 25 | */ 26 | public interface UnivariateRealFunction { 27 | 28 | /** 29 | * Compute the value for the function. 30 | * 31 | * @param x the point for which the function value should be computed 32 | * @return the value 33 | * @throws FunctionEvaluationException if the function evaluation fails 34 | */ 35 | double value(double x) throws FunctionEvaluationException; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/analysis/solvers/UnivariateRealSolverFactoryImpl.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.analysis.solvers; 18 | 19 | /** 20 | * A concrete {@link UnivariateRealSolverFactory}. This is the default solver factory 21 | * used by commons-math. 22 | *

23 | * The default solver returned by this factory is a {@link BrentSolver}.

24 | * 25 | * @version $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $ 26 | */ 27 | public class UnivariateRealSolverFactoryImpl extends UnivariateRealSolverFactory { 28 | 29 | /** 30 | * Default constructor. 31 | */ 32 | public UnivariateRealSolverFactoryImpl() { 33 | } 34 | 35 | /** 36 | * {@inheritDoc} 37 | */ 38 | @Override 39 | public UnivariateRealSolver newDefaultSolver() { 40 | return newBrentSolver(); 41 | } 42 | 43 | /** 44 | * {@inheritDoc} 45 | */ 46 | @Override 47 | public UnivariateRealSolver newBisectionSolver() { 48 | return new BisectionSolver(); 49 | } 50 | 51 | /** 52 | * {@inheritDoc} 53 | */ 54 | @Override 55 | public UnivariateRealSolver newBrentSolver() { 56 | return new BrentSolver(); 57 | } 58 | 59 | /** 60 | * {@inheritDoc} 61 | */ 62 | @Override 63 | public UnivariateRealSolver newNewtonSolver() { 64 | return new NewtonSolver(); 65 | } 66 | 67 | /** 68 | * {@inheritDoc} 69 | */ 70 | @Override 71 | public UnivariateRealSolver newSecantSolver() { 72 | return new SecantSolver(); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/BinomialDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * The Binomial Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface BinomialDistribution extends IntegerDistribution { 33 | /** 34 | * Access the number of trials for this distribution. 35 | * 36 | * @return the number of trials. 37 | */ 38 | int getNumberOfTrials(); 39 | 40 | /** 41 | * Access the probability of success for this distribution. 42 | * 43 | * @return the probability of success. 44 | */ 45 | double getProbabilityOfSuccess(); 46 | 47 | /** 48 | * Change the number of trials for this distribution. 49 | * 50 | * @param trials the new number of trials. 51 | * @deprecated as of v2.1 52 | */ 53 | @Deprecated 54 | void setNumberOfTrials(int trials); 55 | 56 | /** 57 | * Change the probability of success for this distribution. 58 | * 59 | * @param p the new probability of success. 60 | * @deprecated as of v2.1 61 | */ 62 | @Deprecated 63 | void setProbabilityOfSuccess(double p); 64 | } 65 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/CauchyDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.distribution; 19 | 20 | /** 21 | * Cauchy Distribution. 22 | *

23 | *

24 | * References: 25 | *

29 | *

30 | * 31 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 32 | * @since 1.1 33 | */ 34 | public interface CauchyDistribution extends ContinuousDistribution { 35 | 36 | /** 37 | * Access the median. 38 | * 39 | * @return median for this distribution 40 | */ 41 | double getMedian(); 42 | 43 | /** 44 | * Access the scale parameter. 45 | * 46 | * @return scale parameter for this distribution 47 | */ 48 | double getScale(); 49 | 50 | /** 51 | * Modify the median. 52 | * 53 | * @param median for this distribution 54 | * @deprecated as of v2.1 55 | */ 56 | @Deprecated 57 | void setMedian(double median); 58 | 59 | /** 60 | * Modify the scale parameter. 61 | * 62 | * @param s scale parameter for this distribution 63 | * @deprecated as of v2.1 64 | */ 65 | @Deprecated 66 | void setScale(double s); 67 | } 68 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/ChiSquaredDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * The Chi-Squared Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface ChiSquaredDistribution extends ContinuousDistribution /*, HasDensity*/ { 33 | /** 34 | * Modify the degrees of freedom. 35 | * 36 | * @param degreesOfFreedom the new degrees of freedom. 37 | * @deprecated as of v2.1 38 | */ 39 | @Deprecated 40 | void setDegreesOfFreedom(double degreesOfFreedom); 41 | 42 | /** 43 | * Access the degrees of freedom. 44 | * 45 | * @return the degrees of freedom. 46 | */ 47 | double getDegreesOfFreedom(); 48 | 49 | /** 50 | * Return the probability density for a particular point. 51 | * 52 | * @param x The point at which the density should be computed. 53 | * @return The pdf at point x. 54 | */ 55 | double density(Double x); 56 | } 57 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/ContinuousDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | import org.apache.commons.math.MathException; 20 | 21 | /** 22 | *

Base interface for continuous distributions.

23 | *

24 | *

Note: this interface will be extended in version 3.0 to include 25 | *
public double density(double x)
RRB: already added this. 26 | * that is, from version 3.0 forward, continuous distributions must 27 | * include implementations of probability density functions. As of version 28 | * 2.1, all continuous distribution implementations included in commons-math 29 | * provide implementations of this method.

30 | * 31 | * @version $Revision: 924362 $ $Date: 2010-03-17 12:45:31 -0400 (Wed, 17 Mar 2010) $ 32 | */ 33 | public interface ContinuousDistribution extends Distribution { 34 | 35 | /** 36 | * For this distribution, X, this method returns x such that P(X < x) = p. 37 | * 38 | * @param p the cumulative probability. 39 | * @return x. 40 | * @throws MathException if the inverse cumulative probability can not be 41 | * computed due to convergence or other numerical errors. 42 | */ 43 | double inverseCumulativeProbability(double p) throws MathException; 44 | 45 | /** 46 | * Return the probability density for a particular point. 47 | * 48 | * @param x The point at which the density should be computed. 49 | * @return The pdf at point x. 50 | */ 51 | double density(double x); 52 | 53 | double logDensity(double x);// {return Math.log(density(x)); 54 | } -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/DiscreteDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | 20 | /** 21 | * Base interface for discrete distributions. 22 | * 23 | * @version $Revision: 811685 $ $Date: 2009-09-05 13:36:48 -0400 (Sat, 05 Sep 2009) $ 24 | */ 25 | public interface DiscreteDistribution extends Distribution { 26 | /** 27 | * For a random variable X whose values are distributed according 28 | * to this distribution, this method returns P(X = x). In other words, this 29 | * method represents the probability mass function, or PMF for the distribution. 30 | * 31 | * @param x the value at which the probability mass function is evaluated. 32 | * @return the value of the probability mass function at x 33 | */ 34 | double probability(double x); 35 | } 36 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/ExponentialDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * The Exponential Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface ExponentialDistribution extends ContinuousDistribution /*, HasDensity*/ { 33 | /** 34 | * Modify the mean. 35 | * 36 | * @param mean the new mean. 37 | * @deprecated as of v2.1 38 | */ 39 | @Deprecated 40 | void setMean(double mean); 41 | 42 | /** 43 | * Access the mean. 44 | * 45 | * @return the mean. 46 | */ 47 | double getMean(); 48 | 49 | /** 50 | * Return the probability density for a particular point. 51 | * 52 | * @param x The point at which the density should be computed. 53 | * @return The pdf at point x. 54 | */ 55 | double density(Double x); 56 | } 57 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/FDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * F-Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface FDistribution extends ContinuousDistribution { 33 | /** 34 | * Modify the numerator degrees of freedom. 35 | * 36 | * @param degreesOfFreedom the new numerator degrees of freedom. 37 | * @deprecated as of v2.1 38 | */ 39 | @Deprecated 40 | void setNumeratorDegreesOfFreedom(double degreesOfFreedom); 41 | 42 | /** 43 | * Access the numerator degrees of freedom. 44 | * 45 | * @return the numerator degrees of freedom. 46 | */ 47 | double getNumeratorDegreesOfFreedom(); 48 | 49 | /** 50 | * Modify the denominator degrees of freedom. 51 | * 52 | * @param degreesOfFreedom the new denominator degrees of freedom. 53 | * @deprecated as of v2.1 54 | */ 55 | @Deprecated 56 | void setDenominatorDegreesOfFreedom(double degreesOfFreedom); 57 | 58 | /** 59 | * Access the denominator degrees of freedom. 60 | * 61 | * @return the denominator degrees of freedom. 62 | */ 63 | double getDenominatorDegreesOfFreedom(); 64 | } 65 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/GammaDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * The Gamma Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface GammaDistribution extends ContinuousDistribution /*, HasDensity*/ { 33 | /** 34 | * Modify the shape parameter, alpha. 35 | * 36 | * @param alpha the new shape parameter. 37 | * @deprecated as of v2.1 38 | */ 39 | @Deprecated 40 | void setAlpha(double alpha); 41 | 42 | /** 43 | * Access the shape parameter, alpha 44 | * 45 | * @return alpha. 46 | */ 47 | double getAlpha(); 48 | 49 | /** 50 | * Modify the scale parameter, beta. 51 | * 52 | * @param beta the new scale parameter. 53 | * @deprecated as of v2.1 54 | */ 55 | @Deprecated 56 | void setBeta(double beta); 57 | 58 | /** 59 | * Access the scale parameter, beta 60 | * 61 | * @return beta. 62 | */ 63 | double getBeta(); 64 | 65 | /** 66 | * Return the probability density for a particular point. 67 | * 68 | * @param x The point at which the density should be computed. 69 | * @return The pdf at point x. 70 | */ 71 | double density(Double x); 72 | } 73 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/HasDensity.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.distribution; 19 | 20 | import org.apache.commons.math.MathException; 21 | 22 | /** 23 | *

Interface that signals that a distribution can compute the probability density function 24 | * for a particular point. 25 | * 26 | * @param

the type of the point at which density is to be computed, this 27 | * may be for example Double.

28 | *

29 | *

This interface is deprecated. As of version 2.0, the {@link ContinuousDistribution} 30 | * interface will be extended to include a density(double) method.

31 | * @version $Revision: 924362 $ $Date: 2010-03-17 12:45:31 -0400 (Wed, 17 Mar 2010) $ 32 | * @deprecated to be removed in math 3.0 33 | */ 34 | @Deprecated 35 | public interface HasDensity

{ 36 | 37 | /** 38 | * Compute the probability density function. 39 | * 40 | * @param x point for which the probability density is requested 41 | * @return probability density at point x 42 | * @throws MathException if probability density cannot be computed at specifed point 43 | */ 44 | double density(P x) throws MathException; 45 | 46 | } 47 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/NormalDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.distribution; 19 | 20 | /** 21 | * Normal (Gauss) Distribution. 22 | *

23 | *

24 | * References:

25 | *

29 | *

30 | * 31 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 32 | */ 33 | public interface NormalDistribution extends ContinuousDistribution /*, HasDensity*/ { 34 | /** 35 | * Access the mean. 36 | * 37 | * @return mean for this distribution 38 | */ 39 | double getMean(); 40 | 41 | /** 42 | * Modify the mean. 43 | * 44 | * @param mean for this distribution 45 | * @deprecated as of v2.1 46 | */ 47 | @Deprecated 48 | void setMean(double mean); 49 | 50 | /** 51 | * Access the standard deviation. 52 | * 53 | * @return standard deviation for this distribution 54 | */ 55 | double getStandardDeviation(); 56 | 57 | /** 58 | * Modify the standard deviation. 59 | * 60 | * @param sd standard deviation for this distribution 61 | * @deprecated as of v2.1 62 | */ 63 | @Deprecated 64 | void setStandardDeviation(double sd); 65 | 66 | /** 67 | * Return the probability density for a particular point. 68 | * 69 | * @param x The point at which the density should be computed. 70 | * @return The pdf at point x. 71 | */ 72 | double density(Double x); 73 | } 74 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/PoissonDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | import org.apache.commons.math.MathException; 20 | 21 | /** 22 | * Interface representing the Poisson Distribution. 23 | *

24 | *

25 | * References: 26 | *

30 | *

31 | * 32 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 33 | */ 34 | public interface PoissonDistribution extends IntegerDistribution { 35 | 36 | /** 37 | * Get the mean for the distribution. 38 | * 39 | * @return the mean for the distribution. 40 | */ 41 | double getMean(); 42 | 43 | /** 44 | * Set the mean for the distribution. 45 | * The parameter value must be positive; otherwise an 46 | * IllegalArgument is thrown. 47 | * 48 | * @param p the mean 49 | * @throws IllegalArgumentException if p ≤ 0 50 | * @deprecated as of v2.1 51 | */ 52 | @Deprecated 53 | void setMean(double p); 54 | 55 | /** 56 | * Calculates the Poisson distribution function using a normal approximation. 57 | * 58 | * @param x the upper bound, inclusive 59 | * @return the distribution function value calculated using a normal approximation 60 | * @throws MathException if an error occurs computing the normal approximation 61 | */ 62 | double normalApproximateProbability(int x) throws MathException; 63 | 64 | } 65 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/TDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.apache.commons.math.distribution; 18 | 19 | /** 20 | * Student's t-Distribution. 21 | *

22 | *

23 | * References: 24 | *

28 | *

29 | * 30 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 31 | */ 32 | public interface TDistribution extends ContinuousDistribution { 33 | /** 34 | * Modify the degrees of freedom. 35 | * 36 | * @param degreesOfFreedom the new degrees of freedom. 37 | * @deprecated as of v2.1 38 | */ 39 | @Deprecated 40 | void setDegreesOfFreedom(double degreesOfFreedom); 41 | 42 | /** 43 | * Access the degrees of freedom. 44 | * 45 | * @return the degrees of freedom. 46 | */ 47 | double getDegreesOfFreedom(); 48 | } 49 | -------------------------------------------------------------------------------- /src/org/apache/commons/math/distribution/WeibullDistribution.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package org.apache.commons.math.distribution; 19 | 20 | /** 21 | * Weibull Distribution. This interface defines the two parameter form of the 22 | * distribution as defined by 23 | * 24 | * Weibull Distribution, equations (1) and (2). 25 | *

26 | *

27 | * References: 28 | *

32 | *

33 | * 34 | * @version $Revision: 920852 $ $Date: 2010-03-09 07:53:44 -0500 (Tue, 09 Mar 2010) $ 35 | * @since 1.1 36 | */ 37 | public interface WeibullDistribution extends ContinuousDistribution { 38 | 39 | /** 40 | * Access the shape parameter. 41 | * 42 | * @return the shape parameter. 43 | */ 44 | double getShape(); 45 | 46 | /** 47 | * Access the scale parameter. 48 | * 49 | * @return the scale parameter. 50 | */ 51 | double getScale(); 52 | 53 | /** 54 | * Modify the shape parameter. 55 | * 56 | * @param alpha The new shape parameter value. 57 | * @deprecated as of v2.1 58 | */ 59 | @Deprecated 60 | void setShape(double alpha); 61 | 62 | /** 63 | * Modify the scale parameter. 64 | * 65 | * @param beta The new scale parameter value. 66 | * @deprecated as of v2.1 67 | */ 68 | @Deprecated 69 | void setScale(double beta); 70 | } 71 | -------------------------------------------------------------------------------- /src/org/json/JSONException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010 The Android Open Source Project 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package org.json; 18 | 19 | // Note: this class was written without inspecting the non-free org.json sourcecode. 20 | 21 | /** 22 | * Thrown to indicate a problem with the JSON API. Such problems include: 23 | *
    24 | *
  • Attempts to parse or construct malformed documents 25 | *
  • Use of null as a name 26 | *
  • Use of numeric types not available to JSON, such as {@link 27 | * Double#isNaN() NaNs} or {@link Double#isInfinite() infinities}. 28 | *
  • Lookups using an out of range index or nonexistent name 29 | *
  • Type mismatches on lookups 30 | *
31 | * 32 | *

Although this is a checked exception, it is rarely recoverable. Most 33 | * callers should simply wrap this exception in an unchecked exception and 34 | * rethrow: 35 | *

  public JSONArray toJSONObject() {
36 |  *     try {
37 |  *         JSONObject result = new JSONObject();
38 |  *         ...
39 |  *     } catch (JSONException e) {
40 |  *         throw new RuntimeException(e);
41 |  *     }
42 |  * }
43 | */ 44 | public class JSONException extends Exception { 45 | 46 | private static final long serialVersionUID = 1L; 47 | 48 | public JSONException(String s) { 49 | super(s); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /test/test/beast/beast2vs1/trace/TraceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * TraceException.java 3 | * 4 | * Copyright (C) 2002-2006 Alexei Drummond and Andrew Rambaut 5 | * 6 | * This file is part of BEAST. 7 | * See the NOTICE file distributed with this work for additional 8 | * information regarding copyright ownership and licensing. 9 | * 10 | * BEAST is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU Lesser General Public License as 12 | * published by the Free Software Foundation; either version 2 13 | * of the License, or (at your option) any later version. 14 | * 15 | * BEAST is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU Lesser General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU Lesser General Public 21 | * License along with BEAST; if not, write to the 22 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 | * Boston, MA 02110-1301 USA 24 | */ 25 | 26 | package test.beast.beast2vs1.trace; 27 | 28 | /** 29 | * An exception for traces 30 | * 31 | * @author Andrew Rambaut 32 | * @author Alexei Drummond 33 | */ 34 | 35 | public class TraceException extends Exception { 36 | private static final long serialVersionUID = 1L; 37 | 38 | public TraceException() { 39 | super(); 40 | } 41 | 42 | public TraceException(String message) { 43 | super(message); 44 | } 45 | } -------------------------------------------------------------------------------- /test/test/beast/beast2vs1/trace/TraceType.java: -------------------------------------------------------------------------------- 1 | package test.beast.beast2vs1.trace; 2 | 3 | /** 4 | * @author Alexei Drummond 5 | * @author Walter Xie 6 | */ 7 | public enum TraceType { 8 | DOUBLE("double", "D", Double.class), 9 | INTEGER("integer", "I", Integer.class), 10 | STRING("string", "S", String.class); 11 | 12 | TraceType(String name, String brief, Class type) { 13 | this.name = name; 14 | this.brief = brief; 15 | this.type = type; 16 | } 17 | 18 | @Override 19 | public String toString() { 20 | return name; 21 | } 22 | 23 | public String getBrief() { 24 | return brief; 25 | } 26 | 27 | public Class getType() { 28 | return type; 29 | } 30 | 31 | private final String name; 32 | private final String brief; 33 | private final Class type; 34 | } 35 | -------------------------------------------------------------------------------- /test/test/beast/core/PrimitiveInterface.java: -------------------------------------------------------------------------------- 1 | package test.beast.core; 2 | 3 | 4 | import beast.base.core.BEASTObject; 5 | import beast.base.core.Description; 6 | import beast.base.core.Param; 7 | 8 | @Description("PrimitiveInterface is used for testing inner class inside interface") 9 | public interface PrimitiveInterface { 10 | 11 | 12 | @Description("InterfaceInnerClass is used for testing inner class inside interface") 13 | public class InterfaceInnerClass extends BEASTObject implements PrimitiveInterface { 14 | private int i; 15 | 16 | public InterfaceInnerClass(@Param(name="i", description="input of primitive type") int i) { 17 | this.i = i; 18 | } 19 | 20 | public InterfaceInnerClass() {} 21 | 22 | @Override 23 | public void initAndValidate() { 24 | } 25 | 26 | public int getI() { 27 | return i; 28 | } 29 | public void setI(int i) { 30 | this.i = i; 31 | } 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /test/test/beast/core/StateNodeInitialiserTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.core; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import beast.base.evolution.alignment.Alignment; 8 | import beast.base.evolution.tree.ClusterTree; 9 | import beast.base.evolution.tree.Tree; 10 | import beast.base.evolution.tree.TreeParser; 11 | 12 | import test.beast.BEASTTestCase; 13 | 14 | public class StateNodeInitialiserTest { 15 | 16 | @Test 17 | public void testClusterTree() throws Exception { 18 | Alignment data = BEASTTestCase.getAlignment(); 19 | Tree tree = new Tree(); 20 | tree.initAndValidate(); 21 | assertEquals(true, tree.getNodeCount() == 1); 22 | 23 | TreeParser tree2 = new TreeParser(); 24 | tree2.initByName( 25 | "initial", tree, 26 | "taxa", data, 27 | "newick", "((((human:0.024003,(chimp:0.010772,bonobo:0.010772):0.013231):0.012035,gorilla:0.036038):0.033087000000000005,orangutan:0.069125):0.030456999999999998,siamang:0.099582);", 28 | "IsLabelledNewick", true); 29 | 30 | assertEquals(true, tree.getNodeCount() > 1); 31 | assertEquals(11, tree.getNodeCount()); 32 | } 33 | 34 | @Test 35 | public void testNewickTree() throws Exception { 36 | Alignment data = BEASTTestCase.getAlignment(); 37 | Tree tree = new Tree(); 38 | tree.initAndValidate(); 39 | assertEquals(true, tree.getNodeCount() == 1); 40 | 41 | ClusterTree tree2 = new ClusterTree(); 42 | tree2.initByName( 43 | "initial", tree, 44 | "clusterType", "upgma", 45 | "taxa", data); 46 | assertEquals(true, tree.getNodeCount() > 1); 47 | assertEquals(11, tree.getNodeCount()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /test/test/beast/core/util/SumTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.core.util; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.Test; 6 | 7 | import beast.base.evolution.Sum; 8 | import beast.base.inference.parameter.BooleanParameter; 9 | import beast.base.inference.parameter.IntegerParameter; 10 | import beast.base.inference.parameter.RealParameter; 11 | 12 | 13 | public class SumTest { 14 | 15 | 16 | @Test 17 | public void testSum() { 18 | RealParameter p1 = new RealParameter("1.0 2.0"); 19 | Sum sum = new Sum(); 20 | 21 | // single argument sum 22 | sum.initByName("arg", p1); 23 | double v = sum.getArrayValue(); 24 | assertEquals(3.0, v, 1e-10); 25 | 26 | // multiple argument sum 27 | sum = new Sum(); 28 | RealParameter p2 = new RealParameter("2.0 2.5"); 29 | sum.initByName("arg", p1, "arg", p2); 30 | v = sum.getArrayValue(); 31 | assertEquals(7.5, v, 1e-10); 32 | 33 | // multiple same argument sum 34 | sum = new Sum(); 35 | sum.initByName("arg", p1, "arg", p1); 36 | v = sum.getArrayValue(); 37 | assertEquals(6.0, v, 1e-10); 38 | 39 | // sum of integers 40 | IntegerParameter p3 = new IntegerParameter("1 2 5"); 41 | sum = new Sum(); 42 | sum.initByName("arg", p3); 43 | v = sum.getArrayValue(); 44 | assertEquals(8.0, v, 1e-10); 45 | 46 | // sum of boolean 47 | BooleanParameter p4 = new BooleanParameter("true false false true true"); 48 | sum = new Sum(); 49 | sum.initByName("arg", p4); 50 | v = sum.getArrayValue(); 51 | assertEquals(3.0, v, 1e-10); 52 | 53 | // sum of booleans and integer 54 | sum = new Sum(); 55 | sum.initByName("arg", p4, "arg", p3); 56 | v = sum.getArrayValue(); 57 | assertEquals(11.0, v, 1e-10); 58 | 59 | // sum of booleans and real 60 | sum = new Sum(); 61 | sum.initByName("arg", p1, "arg", p4); 62 | v = sum.getArrayValue(); 63 | assertEquals(6.0, v, 1e-10); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /test/test/beast/evolution/datatype/DataTypeDeEncodeTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.datatype; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import java.util.Arrays; 6 | import java.util.List; 7 | 8 | import org.junit.jupiter.api.Test; 9 | import beast.base.evolution.datatype.Aminoacid; 10 | import beast.base.evolution.datatype.Binary; 11 | import beast.base.evolution.datatype.IntegerData; 12 | import beast.base.evolution.datatype.Nucleotide; 13 | import beast.base.evolution.datatype.TwoStateCovarion; 14 | import beast.base.evolution.datatype.DataType.Base; 15 | 16 | public class DataTypeDeEncodeTest { 17 | 18 | @Test 19 | public void testDataTypeDeEncode() { 20 | Base dAa = new Aminoacid(); 21 | Base dBi = new Binary(); 22 | Base dIn = new IntegerData(); 23 | Base dNt = new Nucleotide(); 24 | Base d2C = new TwoStateCovarion(); 25 | 26 | for (Object [] o : Arrays.asList(new Object[][] { 27 | { dIn, "1,2,14,23,?", Arrays.asList(new Integer[] { 1, 2, 14, 23, -1 }) }, 28 | { dNt, "ACGTURYMWSKBDHVNX", Arrays.asList( 29 | new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }) }, 30 | { dBi, "01-?10", Arrays.asList(new Integer[] { 0, 1, 2, 3, 1, 0 }) }, 31 | { d2C, "01ABCD-?", Arrays.asList(new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7 }) }, 32 | { dAa, "ACDEFGHIKLMNPQRSTVWY", Arrays.asList( 33 | new Integer[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }) } 34 | })) { 35 | Base d = (Base) o[0]; 36 | String s = (String) o[1]; 37 | List c = (List) o[2]; 38 | // o.testStingToEncoding(); 39 | assertEquals(c, d.stringToEncoding(s)); 40 | //o.testRoundTrip(); 41 | assertEquals(s, d.encodingToString(d.stringToEncoding(s))); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /test/test/beast/evolution/datatype/IntegerDataTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.datatype; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import beast.base.evolution.datatype.IntegerData; 6 | import beast.base.util.Randomizer; 7 | import static org.junit.jupiter.api.Assertions.assertEquals;; 8 | 9 | public class IntegerDataTest { 10 | 11 | 12 | @Test 13 | public void testIntegerData() { 14 | IntegerData datatype = new IntegerData(); 15 | assertEquals("?", datatype.getCharacter(-1)); 16 | assertEquals("0", datatype.getCharacter(0)); 17 | assertEquals("1", datatype.getCharacter(1)); 18 | assertEquals("10", datatype.getCharacter(10)); 19 | assertEquals("123", datatype.getCharacter(123)); 20 | Randomizer.setSeed(127); 21 | for (int i = 0; i < 100; i++) { 22 | int state = Randomizer.nextInt(100000000); 23 | int x = state; 24 | String str = ""; 25 | while (state > 0) { 26 | str = (char)('0' + state%10) + str; 27 | state /= 10; 28 | } 29 | assertEquals(str, datatype.getCharacter(x)); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/test/beast/evolution/likelihood/BeagleTreeLikelihoodTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.likelihood; 2 | 3 | import beast.base.evolution.likelihood.TreeLikelihood; 4 | 5 | public class BeagleTreeLikelihoodTest extends TreeLikelihoodTest { 6 | 7 | @Override 8 | protected TreeLikelihood newTreeLikelihood() { 9 | System.err.println("=============================================================================================================="); 10 | System.err.println("=============================================================================================================="); 11 | System.err.println("== Make sure to have BEAGLE installed and set the -Djava.library.path=/path/to/beagle option for this test. =="); 12 | System.err.println("=============================================================================================================="); 13 | System.err.println("=============================================================================================================="); 14 | System.setProperty("java.only", "false"); 15 | return new TreeLikelihood(); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/test/beast/evolution/operator/CompoundParameterHelperTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.operator; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.junit.jupiter.api.Test; 7 | 8 | import beast.base.inference.operator.CompoundParameterHelper; 9 | import beast.base.inference.parameter.RealParameter; 10 | import static org.junit.jupiter.api.Assertions.assertEquals; 11 | 12 | public class CompoundParameterHelperTest { 13 | 14 | 15 | @Test 16 | public void testCompoundParameterHelper() { 17 | RealParameter p1 = new RealParameter("1.0 2.0"); 18 | RealParameter p2 = new RealParameter("3.0 4.0 5.0"); 19 | List list = new ArrayList<>(); 20 | list.add(p1); 21 | list.add(p2); 22 | 23 | CompoundParameterHelper cph = new CompoundParameterHelper(list); 24 | 25 | // prints 5 26 | System.out.println("Dim = " + cph.getDimension()); 27 | // results in java.lang.ArrayIndexOutOfBoundsException: 2 28 | for (int i = 0; i < cph.getDimension(); i++) { 29 | System.out.println("value[" + i + "] = " +cph.getValue(i)); 30 | } 31 | 32 | assertEquals(5, cph.getDimension()); 33 | for (int i = 0; i < 4; i++) { 34 | assertEquals(i+1.0, cph.getValue(i), 1e-15); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /test/test/beast/evolution/operator/DeltaExchangeOperatorTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test.beast.evolution.operator; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | import org.junit.jupiter.api.Test; 9 | 10 | import beast.base.inference.State; 11 | import beast.base.inference.operator.DeltaExchangeOperator; 12 | import beast.base.inference.parameter.IntegerParameter; 13 | import beast.base.inference.parameter.RealParameter; 14 | 15 | /** 16 | * @author gereon 17 | * 18 | */ 19 | public class DeltaExchangeOperatorTest extends TestOperator { 20 | 21 | @Test 22 | public void testKeepsSum() { 23 | DeltaExchangeOperator operator = new DeltaExchangeOperator(); 24 | RealParameter parameter = new RealParameter(new Double[] {1., 1., 1., 1.}); 25 | register(operator, 26 | "parameter", parameter); 27 | for (int i=0; i<100; ++i) { 28 | operator.proposal(); 29 | } 30 | double i = 0; 31 | for (Double p : parameter.getValues()) { 32 | i += p; 33 | } 34 | assertEquals(i, 4, 0.00001, "The DeltaExchangeOperator should not change the sum of a parameter"); 35 | } 36 | 37 | @Test 38 | public void testKeepsWeightedSum() { 39 | RealParameter parameter = new RealParameter(new Double[] {1., 1., 1., 1.}); 40 | register(new DeltaExchangeOperator(), 41 | "weightvector", new IntegerParameter(new Integer[] {0, 1, 2, 1}), 42 | "parameter", parameter); 43 | Double[] p = parameter.getValues(); 44 | assertEquals(0*p[1]+1*p[1]+2*p[2]+1*p[3], 4, 0.00001, 45 | "The DeltaExchangeOperator should not change the sum of a parameter"); 46 | } 47 | 48 | @Test 49 | public void testCanOperate() { 50 | // Test whether a validly initialised operator may make proposals 51 | State state = new State(); 52 | RealParameter parameter = new RealParameter(new Double[] { 1., 1., 1., 1. }); 53 | state.initByName("stateNode", parameter); 54 | state.initialise(); 55 | DeltaExchangeOperator d = new DeltaExchangeOperator(); 56 | // An invalid operator should either fail in initByName or make valid 57 | // proposals 58 | try { 59 | d.initByName("parameter", parameter, "weight", 1.0); 60 | } catch (RuntimeException e) { 61 | return; 62 | } 63 | d.proposal(); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /test/test/beast/evolution/operator/ScaleOperatorTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.operator; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import beast.base.evolution.operator.ScaleOperator; 6 | import beast.base.evolution.tree.Node; 7 | import beast.base.evolution.tree.TreeParser; 8 | import static org.junit.jupiter.api.Assertions.assertEquals; 9 | 10 | public class ScaleOperatorTest { 11 | final static double EPSILON = 1e-10; 12 | 13 | 14 | @Test 15 | public void testTreeScaling() { 16 | String newick = "((0:1.0,1:1.0)4:1.0,(2:1.0,3:1.0)5:0.5)6:0.0;"; 17 | 18 | TreeParser tree = new TreeParser(newick, false, false, false, 0); 19 | 20 | Node [] node = tree.getNodesAsArray(); 21 | 22 | ScaleOperator operator = new ScaleOperator(); 23 | operator.initByName("tree", tree, "weight", 1.0); 24 | operator.proposal(); 25 | 26 | // leaf node 27 | node = tree.getNodesAsArray(); 28 | assertEquals(0.0, node[0].getHeight(), EPSILON); 29 | assertEquals(0.0, node[1].getHeight(), EPSILON); 30 | // leaf node, not scaled 31 | assertEquals(0.5, node[2].getHeight(), EPSILON); 32 | assertEquals(0.5, node[3].getHeight(), EPSILON); 33 | 34 | // internal nodes, all scaled 35 | // first determine scale factor 36 | double scale = node[4].getHeight() / 1.0; 37 | assertEquals(1.0 * scale, node[4].getHeight(), EPSILON); 38 | assertEquals(1.5 * scale, node[5].getHeight(), EPSILON); 39 | assertEquals(2.0 * scale, node[6].getHeight(), EPSILON); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /test/test/beast/evolution/operator/TestOperator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | */ 4 | package test.beast.evolution.operator; 5 | 6 | import java.util.ArrayList; 7 | import java.util.HashMap; 8 | 9 | import beast.base.inference.Operator; 10 | import beast.base.inference.State; 11 | import beast.base.inference.StateNode; 12 | import static org.junit.jupiter.api.Assertions.assertEquals; 13 | 14 | /** 15 | * @author gereon 16 | * 17 | */ 18 | public abstract class TestOperator { 19 | 20 | static public void register(Operator operator, final Object... operands) { 21 | HashMap operandsMap; 22 | operandsMap = new HashMap(); 23 | if (operands.length % 2 == 1) { 24 | throw new RuntimeException("Expected even number of arguments, name-value pairs"); 25 | } 26 | for (int i = 0; i < operands.length; i += 2) { 27 | if (operands[i] instanceof String) { 28 | final String name = (String) operands[i]; 29 | if (operands[i + 1] instanceof StateNode) { 30 | final StateNode node = (StateNode) operands[i + 1]; 31 | operandsMap.put(name, node); 32 | } else { 33 | throw new IllegalArgumentException("Expected a StateNode in " + (i + 1) + "th argument "); 34 | } 35 | } else { 36 | throw new IllegalArgumentException("Expected a String in " + i + "th argument "); 37 | } 38 | } 39 | State state = new State(); 40 | state.initByName("stateNode", new ArrayList(operandsMap.values())); 41 | state.initialise(); 42 | Object[] operandsAndWeight = new Object[operands.length + 2]; 43 | for (int i = 0; i < operands.length; ++i) { 44 | operandsAndWeight[i] = operands[i]; 45 | } 46 | operandsAndWeight[operands.length] = "weight"; 47 | operandsAndWeight[operands.length + 1] = "1"; 48 | operator.initByName(operandsAndWeight); 49 | operator.validateInputs(); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /test/test/beast/evolution/tree/TreeTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.tree; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import beast.base.evolution.tree.Node; 6 | import beast.base.evolution.tree.TreeParser; 7 | import static org.junit.jupiter.api.Assertions.assertEquals; 8 | 9 | public class TreeTest { 10 | final static double EPSILON = 1e-10; 11 | 12 | @Test 13 | public void testTreeScaling() { 14 | String newick = "((0:1.0,1:1.0)4:1.0,(2:1.0,3:1.0)5:0.5)6:0.0;"; 15 | 16 | TreeParser treeParser = new TreeParser(newick, false, false, false, 0); 17 | 18 | Node [] node = treeParser.getNodesAsArray(); 19 | assertEquals(0.0, node[0].getHeight(), EPSILON); 20 | assertEquals(0.0, node[1].getHeight(), EPSILON); 21 | // leaf node, not scaled 22 | assertEquals(0.5, node[2].getHeight(), EPSILON); 23 | assertEquals(0.5, node[3].getHeight(), EPSILON); 24 | // internal nodes, all scaled 25 | assertEquals(1.0, node[4].getHeight(), EPSILON); 26 | assertEquals(1.5, node[5].getHeight(), EPSILON); 27 | assertEquals(2.0, node[6].getHeight(), EPSILON); 28 | 29 | treeParser.scale(2.0); 30 | 31 | // leaf node 32 | node = treeParser.getNodesAsArray(); 33 | assertEquals(0.0, node[0].getHeight(), EPSILON); 34 | assertEquals(0.0, node[1].getHeight(), EPSILON); 35 | // leaf node, not scaled 36 | assertEquals(0.5, node[2].getHeight(), EPSILON); 37 | assertEquals(0.5, node[3].getHeight(), EPSILON); 38 | // internal nodes, all scaled 39 | assertEquals(2.0, node[4].getHeight(), EPSILON); 40 | assertEquals(3.0, node[5].getHeight(), EPSILON); 41 | assertEquals(4.0, node[6].getHeight(), EPSILON); 42 | 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /test/test/beast/evolution/tree/TreeUtilsTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.tree; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import beast.base.evolution.tree.TreeParser; 7 | import beast.base.evolution.tree.TreeUtils; 8 | 9 | /** 10 | * Test class for TreeUtils methods 11 | */ 12 | public class TreeUtilsTest { 13 | 14 | @Test 15 | public void testSortTreeAlphabetically() { 16 | 17 | String newick = "((D:5.0,C:4.0):6.0,(A:1.0,B:2.0):3.0):0.0;"; 18 | 19 | TreeParser treeParser = new TreeParser(); 20 | treeParser.initByName("IsLabelledNewick", true, 21 | "newick", newick, 22 | "adjustTipHeights", false); 23 | 24 | 25 | TreeUtils.rotateTreeAlphabetically(treeParser.getRoot()); 26 | 27 | String result = treeParser.getRoot().toNewick(); 28 | String goal = "((A:1.0,B:2.0):3.0,(C:4.0,D:5.0):6.0):0.0"; 29 | 30 | assertEquals(goal, result); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/test/beast/evolution/tree/coalescent/BayesianSkylineTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.tree.coalescent; 2 | 3 | 4 | import org.junit.jupiter.api.Test; 5 | 6 | import beast.base.evolution.tree.Tree; 7 | import beast.base.evolution.tree.TreeIntervals; 8 | import beast.base.evolution.tree.coalescent.BayesianSkyline; 9 | import static org.junit.jupiter.api.Assertions.assertEquals; 10 | 11 | 12 | 13 | /** 14 | * @author Alexei Drummond 15 | */ 16 | public class BayesianSkylineTest { 17 | 18 | @Test 19 | public void testSkyline() throws Exception { 20 | 21 | //RealParameter popSize = new RealParameter("1.0", 0.0, 10.0, 2); 22 | //IntegerParameter groupSize = new IntegerParameter("2", 1, 4, 2); 23 | 24 | //popSize.setValue(1, 2.0); 25 | 26 | Tree tree = new Tree("(((1:1,2:1):2.5,(3:1.5,4:1.5):2):2,5:5.5);"); 27 | TreeIntervals intervals = new TreeIntervals(tree); 28 | 29 | BayesianSkyline skyline = new BayesianSkyline(); 30 | //skyline.init(popSize, groupSize, intervals); 31 | skyline.initByName("popSizes", "1.0 2.0", 32 | "groupSizes", "2 2", 33 | "treeIntervals", intervals); 34 | 35 | assertEquals(skyline.getPopSize(0.01), 1.0); 36 | assertEquals(skyline.getPopSize(1.49), 1.0); 37 | assertEquals(skyline.getPopSize(1.51), 2.0); 38 | assertEquals(skyline.getPopSize(5.51), 2.0); 39 | 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /test/test/beast/evolution/tree/coalescent/CoalescentTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.evolution.tree.coalescent; 2 | 3 | import static org.junit.jupiter.api.Assertions.assertEquals; 4 | 5 | import org.junit.jupiter.api.BeforeEach; 6 | 7 | import beast.base.evolution.alignment.Alignment; 8 | import beast.base.evolution.tree.Tree; 9 | import beast.base.evolution.tree.TreeIntervals; 10 | import beast.base.evolution.tree.coalescent.Coalescent; 11 | import beast.base.evolution.tree.coalescent.ConstantPopulation; 12 | import test.beast.BEASTTestCase; 13 | 14 | /** 15 | * @author Alexei Drummond 16 | * @author Walter Xie 17 | */ 18 | public class CoalescentTest extends BEASTTestCase { 19 | String[] trees = new String[]{"((A:1.0,B:1.0):1.0,C:2.0);", ""}; //more trees ? 20 | Alignment data; 21 | final double pop = 10000; 22 | 23 | @BeforeEach 24 | protected void setUp() throws Exception { 25 | //super.setUp(); 26 | data = getFourTaxaNoData(); 27 | } 28 | 29 | public void testConstantPopulation() throws Exception { 30 | // *********** 3 taxon ********** 31 | Tree tree = getTree(data, trees[0]); 32 | TreeIntervals treeIntervals = new TreeIntervals(); 33 | treeIntervals.initByName("tree", tree); 34 | 35 | ConstantPopulation cp = new ConstantPopulation(); 36 | cp.initByName("popSize", Double.toString(pop)); 37 | 38 | Coalescent coal = new Coalescent(); 39 | coal.initByName("treeIntervals", treeIntervals, "populationModel", cp); 40 | 41 | double logL = coal.calculateLogP(); 42 | 43 | assertEquals(logL, -(4 / pop) - 2 * Math.log(pop), PRECISION); 44 | 45 | // *********** 4 taxon ********** 46 | // tree = getTree(data, trees[1]); 47 | // treeIntervals = new TreeIntervals(); 48 | // treeIntervals.initByName("tree", tree); 49 | // 50 | // cp = new ConstantPopulation(); 51 | // cp.initByName("popSize", Double.toString(pop)); 52 | // 53 | // coal = new Coalescent(); 54 | // coal.initByName("treeIntervals", treeIntervals, "populationModel", cp); 55 | // 56 | // logL = coal.calculateLogP(); 57 | // 58 | // assertEquals(logL, -(4 / pop) - 2 * Math.log(pop), PRECISION); 59 | 60 | } 61 | 62 | public void testExponentialGrowth() throws Exception { 63 | 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /test/test/beast/util/RandomizerTest.java: -------------------------------------------------------------------------------- 1 | package test.beast.util; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import beast.base.util.DiscreteStatistics; 6 | import beast.base.util.Randomizer; 7 | 8 | import static org.junit.jupiter.api.Assertions.assertEquals; 9 | 10 | public class RandomizerTest { 11 | 12 | @Test 13 | public void logNormalTest() { 14 | 15 | Randomizer.setSeed(1); 16 | 17 | double M1=1, M2=0, S=0.5; 18 | 19 | int reps=10000000; 20 | 21 | double [] vals1 = new double[reps]; 22 | double [] vals2 = new double[reps]; 23 | 24 | for (int i=0; i taxa = new ArrayList<>(); 27 | taxa.add(new Taxon("first one")); 28 | taxa.add(new Taxon("second one")); 29 | 30 | AnnotatedRunnableTestClass t = new AnnotatedRunnableTestClass(3, taxa); 31 | BEASTClassLoader.addService(BEASTInterface.class.getName(), AnnotatedRunnableTestClass.class.getName(), "BEAST.base"); 32 | 33 | XMLProducer producer = new XMLProducer(); 34 | String xml = producer.toXML(t); 35 | 36 | assertEquals(3, (int) t.getParam1()); 37 | 38 | 39 | FileWriter outfile = new FileWriter(new File("/tmp/XMLTest.xml")); 40 | outfile.write(xml); 41 | outfile.close(); 42 | 43 | 44 | XMLParser parser = new XMLParser(); 45 | BEASTInterface b = parser.parseFile(new File("/tmp/XMLTest.xml")); 46 | assertEquals(3, (int) ((AnnotatedRunnableTestClass) b).getParam1()); 47 | assertEquals(2, ((AnnotatedRunnableTestClass) b).getTaxon().size()); 48 | } 49 | 50 | @Test 51 | public void testVariableReplacement() { 52 | 53 | String stringWithVariables = "$(one) $(two) $(three=3)"; 54 | 55 | Map variableDefs = new HashMap<>(); 56 | 57 | XMLParserUtils.extractVariableDefaultsFromString(stringWithVariables, variableDefs); 58 | 59 | assertEquals(1, variableDefs.size()); 60 | assertTrue(variableDefs.containsKey("three")); 61 | assertTrue(variableDefs.containsValue("3")); 62 | 63 | String modifiedString = XMLParserUtils.replaceVariablesInString(stringWithVariables, variableDefs); 64 | assertEquals("$(one) $(two) 3", modifiedString); 65 | } 66 | } 67 | --------------------------------------------------------------------------------