Skip to content

Commit

Permalink
LPhy 1.5.*, LPhyBEAST 1.1.*, LPhyBeastExt 0.3.* #7
Browse files Browse the repository at this point in the history
  • Loading branch information
walterxie committed Jan 24, 2024
1 parent af7b69d commit 98195b4
Show file tree
Hide file tree
Showing 130 changed files with 2,022 additions and 49 deletions.
94 changes: 84 additions & 10 deletions beast2.7/bin/lphybeast-mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/sh
#!/bin/bash
# It is preferable to place lphybeast inside the BEAST2 bin folder

if [ -z "$BEAST" ]; then
## resolve links - $0 may be a link to application
Expand All @@ -22,10 +23,28 @@ if [ -z "$BEAST" ]; then
cd "$saveddir"
fi

BEAST_LIB="$BEAST/lib"
JAVA="java"
if [ -n "$BEAST" ]; then
# if not empty
BEAST_LIB="$BEAST/lib"
else
echo "Error: cannot locate the BEAST 2 folder ! $BEAST"
exit 1
fi

if [ -d "$BEAST"/jre ]; then
# use Zulu JRE in the BEAST directory if it exists
JAVA="$BEAST"/jre/bin/java
elif [ -n "$JAVA_HOME" ]; then
# else use $JAVA_HOME
JAVA="$JAVA_HOME"/bin/java
else
# else
JAVA=java
fi
# print Java version
echo $("$JAVA" -version)

# use BEAGLE_LIB if the BEAGLE library is not in a standard location
# use BEAGLE_LIB if it is not empty
if [ -n "$BEAGLE_LIB" ]; then
if [ -n "$BEAST_EXTRA_LIBS" ]; then
BEAST_EXTRA_LIBS="$BEAST_EXTRA_LIBS:$BEAGLE_LIB"
Expand All @@ -43,19 +62,74 @@ else
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH":/usr/local/lib
fi

### $LPHY_LIB must be provided

if [ -z "$LPHY_LIB" ]; then
# if $LPHY_LIB does not exist, detect the OS
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Guessing LPHY_LIB on Linux ..."
# set working dir to ~
OS_PREFIX="$HOME"

elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Guessing LPHY_LIB on macOS ..."
OS_PREFIX="/Applications"

# elif [[ "$OSTYPE" == "cygwin" ]]; then
# echo "Running on Cygwin (Windows)"
# elif [[ "$OSTYPE" == "msys" ]]; then
# echo "Running on MSYS (Windows)"
# elif [[ "$OSTYPE" == "win32" ]]; then
# echo "Running on Windows"

else
echo "Cannot guess the LPhy library path LPHY_LIB in unknown OS: $OSTYPE !"
echo "Please set it as your environment variable."
echo "Get help from https://linguaphylo.github.io/setup"
exit 1
fi

# if multiple LPhy installed, sort the search result to get the latest version, usually last line
LPHY_DIR=$(find "$OS_PREFIX" -maxdepth 1 -type d -name 'lphy*studio-1*' | sort | tail -1)
# Guess LPHY_LIB
LPHY_LIB="$LPHY_DIR/lib"
fi
# set to specific path in script
#LPHY_LIB="/Applications/BEAST 2.7.5/lphystudio-1.4.3/lib"

if [ ! -d "$LPHY_LIB" ]; then
echo "Error: Invalid LPhy library path : $LPHY_LIB !"
echo "Please set an existing LPhy library path to LPHY_LIB as your environment variable."
echo "Get help from https://linguaphylo.github.io/setup"
exit 1
fi
echo "BEAST_LIB = $BEAST_LIB"
echo "BEAST_EXTRA_LIBS = $BEAST_EXTRA_LIBS"
echo "LPHY_LIB = $LPHY_LIB"
echo ""

# test if there is any lphy*.jar
JAR_FILES=$(ls "$LPHY_LIB"/lphy*.jar)
if [ -z "$JAR_FILES" ]; then
echo "Error: No core jar files found in $LPHY_LIB !"
echo "Please install LPhy properly. Get help from https://linguaphylo.github.io/setup"
exit 1
fi

### lphy lib must be loaded to classpath
"$JAVA" -version
echo $(ls "$BEAST_LIB")

LPHY_LIB="$BEAST/lphy-studio-1.4/lib"
LPHY_LIB="$BEAST/lphy-studio-1.5/lib"
echo "Set LPHY_LIB = $LPHY_LIB"
echo $(ls "$LPHY_LIB")


# must set -Dpicocli.disable.closures=true using picocli:4.7.0
# it will throw otherwise java.lang.NoClassDefFoundError: groovy.lang.Closure
ARG="-Dpicocli.disable.closures=true -Dlauncher.wait.for.exit=true -Xms256m -Xmx60g -Duser.language=en"
LPHY_BEAST="beast.pkgmgmt.launcher.AppLauncherLauncher lphybeast"
# otherwise it will throw otherwise java.lang.NoClassDefFoundError: groovy.lang.Closure
ARG="-Xms256m -Xmx60g -Dpicocli.disable.closures=true -Dlauncher.wait.for.exit=true -Duser.language=en"
if [ -n "$BEAST_EXTRA_LIBS" ]; then
"$JAVA" $ARG -Djava.library.path="$BEAST_EXTRA_LIBS" -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" $LPHY_BEAST $*
"$JAVA" $ARG -Djava.library.path="$BEAST_EXTRA_LIBS" -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" beast.pkgmgmt.launcher.AppLauncherLauncher lphybeast $*
else
"$JAVA" $ARG -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" $LPHY_BEAST $*
"$JAVA" $ARG -cp "$BEAST_LIB/launcher.jar:$LPHY_LIB/*" beast.pkgmgmt.launcher.AppLauncherLauncher lphybeast $*
fi
Binary file modified beast2.7/lib/launcher.jar
Binary file not shown.
Binary file added beast2.7/lib/launcher.src.jar
Binary file not shown.
Binary file modified beast2.7/lib/packages/BEAST.app.jar
Binary file not shown.
Binary file modified beast2.7/lib/packages/BEAST.app.src.jar
Binary file not shown.
20 changes: 18 additions & 2 deletions beast2.7/lib/packages/BEAST.app.version.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<package name='BEAST.app' version='2.7.4'>
<depends on='BEAST.base' atleast='2.7.4' atmost="2.7.9"/>
<package name='BEAST.app' version='2.7.6'>
<depends on='BEAST.base' atleast='2.7.6' atmost="2.7.9"/>

<service type="beastfx.app.beauti.ThemeProvider">
<provider classname="beastfx.app.beauti.theme.Default"/>
Expand All @@ -14,6 +14,7 @@
<provider classname="beastfx.app.inputeditor.BEASTObjectInputEditor"/>
<provider classname="beastfx.app.inputeditor.TypeTraitSetInputEditor"/>
<provider classname="beastfx.app.inputeditor.BooleanInputEditor"/>
<provider classname="beastfx.app.inputeditor.ConstantInputEditor"/>
<provider classname="beastfx.app.inputeditor.DoubleInputEditor"/>
<provider classname="beastfx.app.inputeditor.DoubleListInputEditor"/>
<provider classname="beastfx.app.inputeditor.EnumInputEditor"/>
Expand Down Expand Up @@ -46,6 +47,8 @@
<provider classname="beastfx.app.inputeditor.TipDatesInputEditor"/>
<provider classname="beastfx.app.beauti.ClockModelListInputEditor"/>
<provider classname="beastfx.app.beauti.ConstantPopulationInputEditor"/>
<provider classname="beastfx.app.beauti.ExponentialPopulationInputEditor"/>
<provider classname="beastfx.app.beauti.ScaledPopulationInputEditor"/>
<provider classname="beastfx.app.beauti.GeneTreeForSpeciesTreeDistributionInputEditor"/>
<provider classname="beastfx.app.beauti.OperatorListInputEditor"/>
<provider classname="beastfx.app.beauti.SpeciesTreePriorInputEditor"/>
Expand Down Expand Up @@ -88,6 +91,19 @@
<provider classname="beastfx.app.methodsection.XML2HTMLPaneFX"/>
</service>

<service type="beastfx.app.treeannotator.services.TopologySettingService">
<provider classname="beastfx.app.treeannotator.services.MCCTopologyService"/>
<provider classname="beastfx.app.treeannotator.services.MaxSumCladeCrediblityTopologyService"/>
<provider classname="beastfx.app.treeannotator.services.UserTargetTreeTopologyService"/>
</service>

<service type="beastfx.app.treeannotator.services.NodeHeightSettingService">
<provider classname="beastfx.app.treeannotator.services.CommonAncestorNodeHeigtService"/>
<provider classname="beastfx.app.treeannotator.services.KeepHeightsNodeHeightsService"/>
<provider classname="beastfx.app.treeannotator.services.MeanNodeHeightService"/>
<provider classname="beastfx.app.treeannotator.services.MedianNodeHeightService"/>
</service>

<packageapp description="Interactive Methods Section Generator"
class="beastfx.app.methodsection.XML2HTMLPaneFX"
/>
Expand Down
Binary file modified beast2.7/lib/packages/BEAST.base.jar
Binary file not shown.
Binary file modified beast2.7/lib/packages/BEAST.base.src.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion beast2.7/lib/packages/BEAST.base.version.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<package name="BEAST.base" version="2.7.4">
<package name="BEAST.base" version="2.7.6">
<!-- note version="2.7.x" must be double quotes for Mac release script release/Mac/createdmg.sh -->

<!-- data types -->
Expand Down
20 changes: 10 additions & 10 deletions beast2.7/lib/prerelease.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

<!-- url="https://s01.oss.sonatype.org/content/repositories/releases/io/github/linguaphylo/lphybeast/0.3.1/lphybeast-0.3.1.zip" -->
<!-- url="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/linguaphylo/lphybeast/0.4.1-SNAPSHOT/lphybeast-0.4.1-20220722.033341-1.zip" -->
<package name="lphybeast" version="1.0.1"
url="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/linguaphylo/lphybeast/1.0.1-SNAPSHOT/lphybeast-1.0.1-20230525.214335-1.zip"
<package name="lphybeast" version="1.1.0"
url="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/linguaphylo/lphybeast/1.1.0-SNAPSHOT/lphybeast-1.1.0-20240124.023923-4.zip"
projectURL="https://github.com/LinguaPhylo/LPhyBeast"
description="A command-line program that takes an LPhy model specification including a data block,
and produces a BEAST 2 XML input file.">
<depends on='BEAST.base' atleast='2.7.4'/>
<depends on='BEAST.app' atleast='2.7.4'/>
<depends on='BEAST.base' atleast='2.7.6'/>
<depends on='BEAST.app' atleast='2.7.6'/>

<depends on='BEASTLabs' atleast='2.0.0'/>
<depends on='BEAST_CLASSIC' atleast='1.6.0'/>
<depends on='feast' atleast='9.2.0'
<depends on='BEASTLabs' atleast='2.0.2'/>
<depends on='BEAST_CLASSIC' atleast='1.6.3'/>
<depends on='feast' atleast='9.8.5'
projectURL="https://github.com/tgvaughan/feast"
description="Expands the flexibility of BEAST 2 XML."/>
<depends on='SSM' atleast='1.2.0'
Expand All @@ -22,11 +22,11 @@
<depends on='bdtree' atleast='0.0.1'/>
</package>

<package name="LPhyBeastExt" version="0.2.1"
url="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/linguaphylo/LPhyBeastExt/0.2.1-SNAPSHOT/LPhyBeastExt-0.2.1-20230525.222434-1.zip"
<package name="LPhyBeastExt" version="0.3.0"
url="https://s01.oss.sonatype.org/content/repositories/snapshots/io/github/linguaphylo/LPhyBeastExt/0.3.0-SNAPSHOT/LPhyBeastExt-0.3.0-20240124.221018-1.zip"
projectURL="https://github.com/LinguaPhylo/LPhyBeastExt"
description="An extension of LPhyBEAST.">
<depends on='lphybeast' atleast='1.0.1'/>
<depends on='lphybeast' atleast='1.1.0'/>

<depends on='Mascot' atleast='3.0.0'
description="Marginal approximation of the structured coalescent"
Expand Down
4 changes: 0 additions & 4 deletions beast2.7/lphy-studio-1.4/examples/mapExample.lphy

This file was deleted.

Binary file removed beast2.7/lphy-studio-1.4/lib/lphy-1.4.2.jar
Binary file not shown.
Binary file removed beast2.7/lphy-studio-1.4/lib/lphy-studio-1.4.2.jar
Binary file not shown.
Binary file removed beast2.7/lphy-studio-1.4/src/lphy-1.4.2-sources.jar
Binary file not shown.
Binary file not shown.
Binary file removed beast2.7/lphy-studio-1.4/src/lphy.icns
Binary file not shown.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ if [ -z "$LPHY" ]; then
fi

LPHY_LIB=$LPHY/lib
java -Xms64m -Xmx5g -p $LPHY_LIB -m lphystudio $*
java -Xms64m -Xmx5g -Duser.dir="$LPHY" -p $LPHY_LIB -m lphystudio $*
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ fi
echo "LPHY path = $LPHY"

LPHY_LIB="$LPHY/lib"
java -Xms64m -Xmx5g -p "$LPHY_LIB" -m lphystudio/lphystudio.app.simulator.SLPhy $*
java -Xms64m -Xmx5g -p "$LPHY_LIB" -m lphy.core/lphy.core.simulator.SLPhy $*
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
set JAVA_EXE=%JAVA_HOME%\bin\java.exe

if exist "%JAVA_EXE%" goto setLPHYLIB

Expand All @@ -65,24 +65,26 @@ echo location of your Java installation.
goto fail

:setLPHYLIB
set LPHY_LIB=%APP_HOME%/../lib/
set LPHY_LIB=%APP_HOME%..\lib
echo set the LPHY_LIB to "%LPHY_LIB%"

:execute
@rem Setup the command line
@rem Execute
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% -p %LPHY_LIB% -m lphystudio/lphystudio.app.simulator.SLPhy %*
set CMD="%JAVA_EXE%" %DEFAULT_JVM_OPTS% -p "%LPHY_LIB%" -m lphy.core/lphy.core.simulator.SLPhy %*
%CMD%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
echo ERROR: fail to run
echo "%JAVA_EXE%" %DEFAULT_JVM_OPTS% -p %LPHY_LIB% -m lphystudio/lphystudio.app.simulator.SLPhy %*

echo.
echo ERROR: fail to run the command
echo %CMD%
echo.
echo Get help from https://linguaphylo.github.io/setup

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
model {
data {
λ = 1;
deathRate = 0.5;
tmrca = 10;
ψ ~ BirthDeathSerialSampling(lambda=λ, mu=deathRate, rho=0.1, psi=1.0, rootAge=tmrca, ages=[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0]);
ages = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0];
}
model {
ψ ~ BirthDeathSerialSampling(lambda=λ, mu=deathRate, rho=0.1, psi=1.0, rootAge=tmrca, ages=ages);
TL = ψ.treeLength();
rootAge = ψ.rootAge();
}
3 changes: 3 additions & 0 deletions beast2.7/lphy-studio-1.5/examples/birth-death/test.lphy
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data {
table = readDelim(file="data/bears_taxa.tsv", sep="\t");
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ model {

// multiplier in log space : 1.124022 2.300000 3.475978
// real space : 3.077205 9.974182 32.329444
multiplierLg ~ LogNormal(meanlog=2.3, sdlog=0.6);
multiplierLg ~ Normal(mean=2.3, sd=0.6);
// hyperMean * multiplier
hyperLgMean2 = hyperLgMean + multiplierLg;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ model {
Θ ~ LogNormal(meanlog=3.0, sdlog=1.0);
ψ ~ Coalescent(theta=Θ, taxa=taxa);
D ~ PhyloCTMC(tree=ψ, L=L, Q=jukesCantor());
E = rmTaxa(names=1:3, alignment=D);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
model {
taxa = taxa(names=["A1", "A2", "B1", "B2", "C1", "C2", "D1", "D2"], species=["A", "A", "B", "B", "C", "C", "D", "D"]);
data {
// cannot wrap the line
taxa = taxa(names=["A1","A2","B1","B2","C1","C2","D1","D2"],species=["A","A","B","B","C","C","D","D"],ages=[0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0]);
// create new taxa from species
species = species(taxa);
speciesPopCount = species.nodeCount();
Θ ~ LogNormal(meanlog=-3.0, sdlog=0.5, replicates=speciesPopCount);
}
model {
Θ ~ LogNormal(meanlog=-3.0,sdlog=0.5, replicates=speciesPopCount);
λ ~ LogNormal(meanlog=0.0, sdlog=1.0);
sp ~ Yule(lambda=λ, taxa=species);
g ~ MultispeciesCoalescent(theta=Θ, S=sp, taxa=taxa, replicates=2);
Expand Down
46 changes: 46 additions & 0 deletions beast2.7/lphy-studio-1.5/examples/data-clamping/covidDPG.lphy
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
data {
// extract dates
options={ageDirection="forward", ageRegex=".*\|(\d+\.\d+)$"};
D = readFasta(file="data/bluff-wedding-cluster.fasta", options=options);

// Bayesian Skyline
numGroups = 20;
taxa = D.taxa();
w = taxa.length()-1;
// i starts from 0
D_trait = extractTrait(taxa=taxa, sep="|", i=1);
K = D_trait.stateCount();
dim = K*(K-1)/2;
dataType = D_trait.dataType();
}
model {
κ ~ LogNormal(meanlog=1.0, sdlog=1.25);
π ~ Dirichlet(conc=[1.0,1.0,1.0,1.0]);

firstValue ~ LogNormal(meanlog=0.0, sdlog=2.0);
Θ ~ ExpMarkovChain(firstValue=firstValue, n=numGroups);
groupSizes ~ RandomComposition(n=w, k=numGroups);
ψ ~ SkylineCoalescent(theta=Θ, taxa=taxa, groupSizes=groupSizes);

// "7.87e-05" "9.12e-04" "1.06e-02"
clockRate ~ LogNormal(meanlog=-7.0, sdlog=1.25);

D ~ PhyloCTMC(L=D.nchar(), Q=hky(kappa=κ, freq=π), mu=clockRate, tree=ψ);

π_trait ~ Dirichlet(conc=rep(element=3.0, times=K));
// symmetric, rates dimension = n * (n-1) / 2
R_trait ~ Dirichlet(conc=rep(element=1.0, times=dim));

// trait indicators
I ~ Bernoulli(p=0.5, replicates=dim, minSuccesses=dim-2);
// S ~ Poisson(lambda=2, min=K, max=dim);
// I ~ RandomBooleanArray(length=dim, hammingWeight=S);

//μ_trait ~ Gamma(shape=0.001, scale=1000.0);
μ_trait ~ LogNormal(meanlog=2.0, sdlog=2.0);

// construct the GTR instantaneous rate matrix
Q_trait = generalTimeReversible(freq=π_trait, rates=select(x=R_trait, indicator=I));
// use the data type of trait alignment extracted from taxa names
D_trait ~ PhyloCTMC(L=1, Q=Q_trait, mu=μ_trait, tree=ψ, dataType=dataType);
}

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions beast2.7/lphy-studio-1.5/examples/data-clamping/readDelim.lphy
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
data {
table = readDelim(file="data/bears_taxa.tsv", sep="\t");
colNames = table.getColumnNames();
taxonNames = table.getColumn(0);
// cast doubles
minAges = toDouble(table.getColumn(1));
// otherwise it will be string
maxAges = table.getColumn(2);
// ages must be a double array
taxa = taxa(names = taxonNames, ages = minAges);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data {
L = [22,11,33];
n = length(L);
}
model {
L ~ Poisson(lambda=1.0, replicates=n);
}
Loading

0 comments on commit 98195b4

Please sign in to comment.