diff --git a/.github/workflows/ci-publish.yml b/.github/workflows/ci-publish.yml new file mode 100644 index 0000000..1023d05 --- /dev/null +++ b/.github/workflows/ci-publish.yml @@ -0,0 +1,55 @@ +name: CI & Publish + +on: + push: + branches: [ master ] + tags: [ 'v*' ] + pull_request: + branches: [ master ] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up JDK 25 (Azul Zulu) + if: "!startsWith(github.ref, 'refs/tags/v')" + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: '25' + cache: maven + + - name: Set up JDK 25 (Azul Zulu) for Maven Central + if: startsWith(github.ref, 'refs/tags/v') + uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: '25' + cache: maven + server-id: central + server-username: CENTRAL_USERNAME + server-password: CENTRAL_TOKEN + gpg-private-key: ${{ secrets.GPG_PRIVATE_KEY }} + gpg-passphrase: GPG_PASSPHRASE + + - name: Set release version from tag + if: startsWith(github.ref, 'refs/tags/v') + run: | + VERSION=${GITHUB_REF_NAME#v} + echo "Publishing version: $VERSION" + mvn versions:set -DnewVersion=$VERSION -DgenerateBackupPoms=false + + - name: Build and test + run: mvn verify + + - name: Publish to Maven Central + if: startsWith(github.ref, 'refs/tags/v') + run: mvn deploy -Prelease -DskipTests + env: + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} diff --git a/.gitignore b/.gitignore index d5272d8..691c93d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,4 @@ bdtree.iml *.log *.state *.trees -out/ \ No newline at end of file +out/target/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md index 7e4e4f3..e7479a4 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,47 @@ # bdtree -A central repository for birth-death models in BEAST 2. +Birth-death tree models for [BEAST 3](https://github.com/CompEvol/beast3). -**Contributors**: Fábio K. Mendes, Rong Zhang +Implements the birth-death-sequential-sampling (BDSS) model for tree likelihood and simulation (Stadler & Yang, 2013). -## Building +**Contributors:** Fabio K. Mendes, Rong Zhang -In order to build the *bdtree* package .jar file: +## Models -(1) Clone and build BEAST2 from [here](https://github.com/CompEvol/beast2); +| Class | Description | +|-------|-------------| +| `BirthDeathSequentialSampling` | BDSS tree likelihood with optional fossil sampling | +| `BirthDeathSerialSamplingTree` | Tree simulator under the BDSS model | -(2) Clone the *bdtree* repository side-by-side with the *beast2/* directory resulting from step (1); +## Building -(3) From *bdtree/*, type: +BEAST 3 dependencies are resolved from [Maven Central](https://central.sonatype.com/namespace/io.github.compevol) — no extra configuration needed. +```bash +mvn compile +mvn test ``` -$ ant + +To develop against an unreleased SNAPSHOT, install BEAST 3 from source: + +```bash +cd ~/Git/beast3 +mvn install -DskipTests ``` -This command invokes the *ant* tool, which executes the building instructions inside *build.xml*. The new *bdtree* .jar file will be put inside *build/dist/*. +## Running -## Models +```bash +# Run an analysis +mvn exec:exec -Dbeast.args="examples/testing/BDSSLikelihood.xml" +``` + +## Examples -Below we list all the models contained within *bdtree*: +- `examples/testing/BDSSLikelihood.xml` — MCMC analysis with BDSS tree prior (10 taxa, fossils) +- `examples/testing/BDSSTreeSimulator.xml` — Simulate trees from the BDSS model +- `examples/legacy-2.7/` — BEAST 2.7 XML files (require migration for BEAST 3) -**Birth-death-sequential-sampling (BDSS)** +## References -[[ref]](https://academic.oup.com/sysbio/article/62/5/674/1684217) Tanja Stadler, Ziheng Yang (2013). Dating phylogenies with sequentially sampled tips. *Syst. Biol.* 62(5), 674-688. +Stadler, T., & Yang, Z. (2013). Dating phylogenies with sequentially sampled tips. *Systematic Biology*, 62(5), 674-688. https://doi.org/10.1093/sysbio/syt030 diff --git a/build.xml b/build.xml deleted file mode 100644 index c331e78..0000000 --- a/build.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - Build BDTree. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ** Required file version.xml does not exist. ** - If this is a new project, run "ant skeleton" from - the command line to create the files required for - your BEAST 2 package. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ** Package ${binName}.v${projVersion}.zip created successfuly! ** - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/testing/Shankarappa.xml b/examples/legacy-2.7/Shankarappa.xml similarity index 100% rename from examples/testing/Shankarappa.xml rename to examples/legacy-2.7/Shankarappa.xml diff --git a/examples/testing/BDSSLikelihood.xml b/examples/testing/BDSSLikelihood.xml index 5b41550..0fb0b33 100644 --- a/examples/testing/BDSSLikelihood.xml +++ b/examples/testing/BDSSLikelihood.xml @@ -1,17 +1,5 @@ - - - beast.base.inference.distribution.Uniform - beast.base.inference.distribution.Exponential - beast.base.inference.distribution.LogNormalDistributionModel - beast.base.inference.distribution.Normal - beast.base.inference.distribution.Beta - beast.base.inference.distribution.Gamma - beast.base.inference.distribution.LaplaceDistribution - beast.base.inference.distribution.Prior - beast.base.inference.distribution.InverseGamma - beast.base.inference.distribution.OneOnX - beast.base.inference.distribution.Dirichlet + @@ -24,12 +12,11 @@ - - 1.0 + @@ -69,10 +56,10 @@ - - - - + + + + @@ -111,4 +98,4 @@ - \ No newline at end of file + diff --git a/examples/testing/BDSSTreeSimulator.xml b/examples/testing/BDSSTreeSimulator.xml index 387ab0c..115cd17 100644 --- a/examples/testing/BDSSTreeSimulator.xml +++ b/examples/testing/BDSSTreeSimulator.xml @@ -1,8 +1,7 @@ - + - - + @@ -47,22 +46,11 @@ - - - - - - - - diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..f19fa7a --- /dev/null +++ b/pom.xml @@ -0,0 +1,240 @@ + + + 4.0.0 + + io.github.compevol + bdtree + 0.1.0-SNAPSHOT + + bdtree + Birth-death tree models for BEAST + + https://github.com/CompEvol/bdtree + + + + GNU Lesser General Public License v3.0 + https://www.gnu.org/licenses/lgpl-3.0.html + + + + + + Rong Zhang + + + Fábio K. Mendes + + + + + scm:git:git://github.com/CompEvol/bdtree.git + scm:git:ssh://github.com:CompEvol/bdtree.git + https://github.com/CompEvol/bdtree + + + + UTF-8 + UTF-8 + 25 + + 2.8.0-beta2 + beast.base + beast.base.minimal.BeastMain + + bdtree + ${project.version} + + + + + + io.github.compevol + beast-base + ${beast.version} + + + io.github.compevol + beast-pkgmgmt + ${beast.version} + + + + + org.junit.jupiter + junit-jupiter + 5.8.2 + test + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.15.0 + + 25 + UTF-8 + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.1.2 + + ${project.build.testOutputDirectory} + + --add-reads bdtree=ALL-UNNAMED + --add-reads beast.base=ALL-UNNAMED + --add-reads beast.pkgmgmt=ALL-UNNAMED + + + ${project.build.outputDirectory} + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + copy-version-xml + generate-resources + copy-resources + + ${project.build.directory} + + + ${project.basedir} + + version.xml + + + + + + + embed-version-xml-in-jar + generate-resources + copy-resources + + ${project.build.outputDirectory} + + + ${project.basedir} + + version.xml + + + + + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.5.0 + + java + ${project.basedir} + --module-path %classpath -DBEAST_PACKAGE_PATH=${project.build.outputDirectory} -m ${beast.module}/${beast.main} ${beast.args} + + + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 3.7.1 + + + src/assembly/beast-package.xml + + ${beast.pkg.name}.v${beast.pkg.version} + false + + + + beast-package + package + single + + + + + + + + + release + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + none + + + + attach-javadocs + jar + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.7 + + + sign-artifacts + verify + sign + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.6.0 + true + + central + true + published + + + + + + + diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..08cb7f7 --- /dev/null +++ b/release.sh @@ -0,0 +1,91 @@ +#!/bin/bash +# +# Build and release a BEAST 2.8 package. +# +# Runs `mvn package` to produce the BEAST package ZIP (via maven-assembly-plugin), +# then optionally creates a GitHub release with the ZIP attached. +# +# Usage: +# ./release.sh # build + create package ZIP +# ./release.sh --release # also create a GitHub release with the ZIP attached +# +# The ZIP can then be submitted to CBAN (CompEvol/CBAN) by adding an entry +# to packages2.8.xml via pull request. See README.md for details. +# +set -euo pipefail + +# --- Extract metadata from version.xml --- + +if [[ ! -f version.xml ]]; then + echo "ERROR: version.xml not found in $(pwd)" >&2 + exit 1 +fi + +# Parse only the element (not etc.) +PKG_LINE=$(grep '&2 + exit 1 +fi + +ZIP_NAME="${PKG_NAME}.v${VERSION}.zip" +GITHUB_REPO=$(git remote get-url origin 2>/dev/null \ + | sed 's|.*github.com[:/]\(.*\)\.git$|\1|; s|.*github.com[:/]\(.*\)$|\1|') + +echo "=== ${PKG_NAME} v${VERSION} ===" +echo "" + +# --- Step 1: Maven build + assemble package ZIP --- + +echo "--- Building with Maven ---" +mvn clean package -DskipTests +echo "" + +# Locate the ZIP produced by maven-assembly-plugin +ZIP_PATH="target/${ZIP_NAME}" +if [[ ! -f "$ZIP_PATH" ]]; then + echo "ERROR: expected ZIP not found at ${ZIP_PATH}" >&2 + exit 1 +fi + +# Copy to project root for convenience +cp "$ZIP_PATH" "$ZIP_NAME" + +echo "=== Package: ${ZIP_NAME} ===" +unzip -l "$ZIP_NAME" + +# --- Step 2: Optionally create GitHub release --- + +if [[ "${1:-}" == "--release" ]]; then + if [[ -z "$GITHUB_REPO" ]]; then + echo "ERROR: could not determine GitHub repo from git remote" >&2 + exit 1 + fi + + echo "" + echo "--- Creating GitHub release v${VERSION} on ${GITHUB_REPO} ---" + gh release create "v${VERSION}" "$ZIP_NAME" \ + --repo "$GITHUB_REPO" \ + --title "${PKG_NAME} v${VERSION}" \ + --generate-notes + + DOWNLOAD_URL="https://github.com/${GITHUB_REPO}/releases/download/v${VERSION}/${ZIP_NAME}" + echo "" + echo "=== Release created ===" + echo "URL: https://github.com/${GITHUB_REPO}/releases/tag/v${VERSION}" + echo "" + echo "--- Next step: submit to CBAN ---" + echo "Add this entry to packages2.8.xml in https://github.com/CompEvol/CBAN via pull request:" + echo "" + cat < + + +XMLEOF +fi diff --git a/src/assembly/beast-package.xml b/src/assembly/beast-package.xml new file mode 100644 index 0000000..70c45bd --- /dev/null +++ b/src/assembly/beast-package.xml @@ -0,0 +1,48 @@ + + beast-package + + zip + + false + + + + + ${project.basedir}/version.xml + / + + + + ${project.build.directory}/${project.build.finalName}-sources.jar + ${beast.pkg.name}.src.jar + / + + + + + + + /lib + true + runtime + + io.github.compevol:bdtree + + + + + + + + ${project.basedir}/src/main/resources/bdtree/fxtemplates + /fxtemplates + + + + ${project.basedir}/examples + /examples + + + diff --git a/src/bdtree/likelihood/BirthDeathSequentialSampling.java b/src/main/java/bdtree/likelihood/BirthDeathSequentialSampling.java similarity index 91% rename from src/bdtree/likelihood/BirthDeathSequentialSampling.java rename to src/main/java/bdtree/likelihood/BirthDeathSequentialSampling.java index 3a7ffb0..14bcdd3 100644 --- a/src/bdtree/likelihood/BirthDeathSequentialSampling.java +++ b/src/main/java/bdtree/likelihood/BirthDeathSequentialSampling.java @@ -3,11 +3,14 @@ import beast.base.core.Description; import beast.base.core.Input; import beast.base.inference.State; -import beast.base.inference.parameter.RealParameter; import beast.base.inference.Distribution; import beast.base.evolution.tree.Node; import beast.base.evolution.tree.Tree; import beast.base.inference.util.InputUtil; +import beast.base.spec.domain.NonNegativeReal; +import beast.base.spec.domain.PositiveReal; +import beast.base.spec.domain.UnitInterval; +import beast.base.spec.type.RealScalar; import java.util.List; import java.util.Random; @@ -20,10 +23,10 @@ // Note: to comment tree.getRoot.sort() in tree logger public class BirthDeathSequentialSampling extends Distribution { final public Input treeInput = new Input<>("tree", "tree over which to calculate a prior or likelihood"); - final public Input birthRateInput = new Input<>("birthRate", "birth rate parameter", Input.Validate.REQUIRED); - final public Input deathRateInput = new Input<>("deathRate", "death rate parameter", Input.Validate.REQUIRED); - final public Input rhoInput = new Input<>("rho", "probability of sampling each extant lineage", Input.Validate.REQUIRED); - final public Input psiInput = new Input<>("psi", "sampling rate parameter, for analysis including fossils"); + final public Input> birthRateInput = new Input<>("birthRate", "birth rate parameter", Input.Validate.REQUIRED); + final public Input> deathRateInput = new Input<>("deathRate", "death rate parameter", Input.Validate.REQUIRED); + final public Input> rhoInput = new Input<>("rho", "probability of sampling each extant lineage", Input.Validate.REQUIRED); + final public Input> psiInput = new Input<>("psi", "sampling rate parameter, for analysis including fossils"); final public Input rootAgeLowerInput = new Input<>("lower", "lower soft bound for the root age"); final public Input rootAgeUpperInput = new Input<>("upper", "upper soft bound for the root age"); final public Input rootAgeInput = new Input<>("rootAge", "specified root age when the tree height is fixed"); @@ -69,13 +72,13 @@ public void initAndValidate() { } private void getBDSSModelParameters(){ - birthRate = birthRateInput.get().getValue(); - deathRate = deathRateInput.get().getValue(); - rho = rhoInput.get().getValue(); + birthRate = birthRateInput.get().get(); + deathRate = deathRateInput.get().get(); + rho = rhoInput.get().get(); if (psiInput.get() == null) { psi = 0.0; } else { - psi = psiInput.get().getValue(); + psi = psiInput.get().get(); } } @@ -275,7 +278,7 @@ public double getZStar(Node aNode) { @Override protected boolean requiresRecalculation() { - return super.requiresRecalculation() || birthRateInput.get().somethingIsDirty() || + return super.requiresRecalculation() || InputUtil.isDirty(birthRateInput) || InputUtil.isDirty(deathRateInput) || InputUtil.isDirty(psiInput) || InputUtil.isDirty(rhoInput); } diff --git a/src/bdtree/simulator/BirthDeathSerialSamplingTree.java b/src/main/java/bdtree/simulator/BirthDeathSerialSamplingTree.java similarity index 92% rename from src/bdtree/simulator/BirthDeathSerialSamplingTree.java rename to src/main/java/bdtree/simulator/BirthDeathSerialSamplingTree.java index d58e091..8fd01c7 100644 --- a/src/bdtree/simulator/BirthDeathSerialSamplingTree.java +++ b/src/main/java/bdtree/simulator/BirthDeathSerialSamplingTree.java @@ -9,8 +9,11 @@ import beast.base.evolution.tree.Node; import beast.base.evolution.tree.TraitSet; import beast.base.evolution.tree.Tree; -import beast.base.inference.parameter.RealParameter; import beast.base.parser.XMLParserException; +import beast.base.spec.domain.NonNegativeReal; +import beast.base.spec.domain.PositiveReal; +import beast.base.spec.domain.UnitInterval; +import beast.base.spec.type.RealScalar; import beast.base.util.Randomizer; import java.io.IOException; @@ -33,11 +36,11 @@ public class BirthDeathSerialSamplingTree extends beast.base.inference.Runnable final public Input iterationsInput = new Input<>("iterations","number of trees to simulate", Input.Validate.REQUIRED); final public Input logEveryInput = new Input<>("logEvery","frequency of screen log.", Input.Validate.REQUIRED); - final public Input rootAgeInput = new Input<>("rootAge", "the height of simulated trees", Input.Validate.REQUIRED); - final public Input birthRateInput = new Input<>("birthRate", "birth rate parameter", Input.Validate.REQUIRED); - final public Input deathRateInput = new Input<>("deathRate", "death rate parameter", Input.Validate.REQUIRED); - final public Input rhoInput = new Input<>("rho", "probability of sampling each extant lineage", Input.Validate.REQUIRED); - final public Input psiInput = new Input<>("psi", "sampling rate parameter, for analysis including fossils"); + final public Input> rootAgeInput = new Input<>("rootAge", "the height of simulated trees", Input.Validate.REQUIRED); + final public Input> birthRateInput = new Input<>("birthRate", "birth rate parameter", Input.Validate.REQUIRED); + final public Input> deathRateInput = new Input<>("deathRate", "death rate parameter", Input.Validate.REQUIRED); + final public Input> rhoInput = new Input<>("rho", "probability of sampling each extant lineage", Input.Validate.REQUIRED); + final public Input> psiInput = new Input<>("psi", "sampling rate parameter, for analysis including fossils"); //tree used for generating samples @@ -68,7 +71,7 @@ public class BirthDeathSerialSamplingTree extends beast.base.inference.Runnable @Override public void initAndValidate() { // get inputs - tmrca = rootAgeInput.get().getValue(); + tmrca = rootAgeInput.get().get(); if(taxonsetInput.get() == null){ // if taxa names are not input, sp_i will be used @@ -98,10 +101,10 @@ public void initAndValidate() { traitSet = traitSetInput.get(); } - lambda = birthRateInput.get().getValue(); - mu = deathRateInput.get().getValue(); - rho = rhoInput.get().getValue(); - psi = psiInput.get().getValue(); + lambda = birthRateInput.get().get(); + mu = deathRateInput.get().get(); + rho = rhoInput.get().get(); + psi = psiInput.get().get(); // check valid inputs if(lambda < mu) { diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 0000000..6824839 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,11 @@ +open module bdtree { + requires beast.base; + requires beast.pkgmgmt; + + exports bdtree.likelihood; + exports bdtree.simulator; + + provides beast.base.core.BEASTInterface with + bdtree.likelihood.BirthDeathSequentialSampling, + bdtree.simulator.BirthDeathSerialSamplingTree; +} diff --git a/fxtemplates/BDSS.xml b/src/main/resources/bdtree/fxtemplates/BDSS.xml similarity index 73% rename from fxtemplates/BDSS.xml rename to src/main/resources/bdtree/fxtemplates/BDSS.xml index caa247b..6cda943 100644 --- a/fxtemplates/BDSS.xml +++ b/src/main/resources/bdtree/fxtemplates/BDSS.xml @@ -1,5 +1,5 @@ + namespace='beast.app.beauti:beast.pkgmgmt:beast.base.core:beast.base.inference:beast.base.evolution.branchratemodel:beast.base.evolution.speciation:beast.base.evolution.tree.coalescent:beast.pkgmgmt:beast.base.core:beast.base.inference.util:beast.evolution.nuc:beast.base.evolution.operator:beast.base.inference.operator:beast.base.evolution.sitemodel:beast.base.evolution.substitutionmodel:beast.base.evolution.likelihood:beast.evolution:beast.base.math.distributions:beast.base.spec.inference.parameter'> @@ -16,31 +16,31 @@ - - - - + + + + - - + + - - + + - - + + - - + + - - - - + + + + @@ -82,4 +82,4 @@ - \ No newline at end of file + diff --git a/src/test/GetZstarTest.java b/src/test/java/bdtree/likelihood/GetZstarTest.java similarity index 76% rename from src/test/GetZstarTest.java rename to src/test/java/bdtree/likelihood/GetZstarTest.java index ff0b69f..77c3970 100644 --- a/src/test/GetZstarTest.java +++ b/src/test/java/bdtree/likelihood/GetZstarTest.java @@ -1,18 +1,22 @@ -package test; +package bdtree.likelihood; -import beast.base.inference.parameter.RealParameter; import beast.base.evolution.alignment.Taxon; import beast.base.evolution.alignment.TaxonSet; -import beast.base.evolution.tree.TraitSet; -import org.junit.Assert; -import org.junit.Test; -import bdtree.likelihood.BirthDeathSequentialSampling; import beast.base.evolution.tree.Node; +import beast.base.evolution.tree.TraitSet; import beast.base.evolution.tree.Tree; import beast.base.evolution.tree.TreeParser; +import beast.base.spec.domain.NonNegativeReal; +import beast.base.spec.domain.PositiveReal; +import beast.base.spec.domain.UnitInterval; +import beast.base.spec.inference.parameter.RealScalarParam; +import org.junit.jupiter.api.Test; + import java.util.ArrayList; import java.util.List; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; + public class GetZstarTest { /* @@ -54,10 +58,10 @@ public void testingGetZStar() { // initializing BDSS likelihood BirthDeathSequentialSampling treePrior = new BirthDeathSequentialSampling(); - RealParameter birthRate = new RealParameter(new Double[] { 1.0 }); - RealParameter deathRate = new RealParameter(new Double[] { 1.0 }); - RealParameter samplingRate = new RealParameter(new Double[] { 0.001 }); - RealParameter rho = new RealParameter(new Double[] { 0.0 }); + var birthRate = new RealScalarParam<>(1.0, PositiveReal.INSTANCE); + var deathRate = new RealScalarParam<>(1.0, PositiveReal.INSTANCE); + var samplingRate = new RealScalarParam<>(0.001, NonNegativeReal.INSTANCE); + var rho = new RealScalarParam<>(0.0, UnitInterval.INSTANCE); treePrior.initByName("tree", tree, "birthRate", birthRate, "deathRate", deathRate, @@ -76,6 +80,6 @@ public void testingGetZStar() { } // test! - Assert.assertArrayEquals(new Double[] { 4.0, 1.0, 0.0, 3.0, 3.0 }, zStars); + assertArrayEquals(new Double[] { 4.0, 1.0, 0.0, 3.0, 3.0 }, zStars); } -} \ No newline at end of file +} diff --git a/version.xml b/version.xml index 2998e5f..9bb0e1e 100644 --- a/version.xml +++ b/version.xml @@ -1,10 +1,9 @@ - - - + + - - - - + + + +