Relative path in file=”…”

The LPhy studio will set the working directory (also known as the property user.dir) to the parent directory where the script is located.

This will cooperate with any relative paths inside the LPhy script, such as readNexus(file="data/RSV2.nex", ...);, which is intended to conceal personal information in the path names. It is relatively easy to organise all the LPhy scripts in a folder (e.g. tutorials/) and their required alignments (e.g. RSV2.nex) in the subfolder data under that folder. This also make it convenient for batch processing purposes.

However, when using the LPhy Studio console, it is more likely to encounter issues with accurate file referencing. So, we recommend you to use the absolute path if you can, such as file="/Applications/lphystudio-1.4.3/tutorials/data/RSV2.nex". It provides a more reliable way to reference files and avoids any confusion caused by changing working directories.

Using LPhy extensions

To install LPhy extensions, download the extension .jar files you need. Then, copy these files into the lib subfolder of your LPhy installation directory (i.e., $LPHY_PATH). Once the .jar file are placed in the LPhy lib folder, the will automatically register the extensions, making it available for use within LPhy.

Here is the folder structure after the LPhy extension, Phylonco, is installed.

LPhyLibPhylonco
Figure 1: LPhy extension, Phylonco.

Also see this page on LPhy extensions.

LPhyBEAST command line options

The lphybeast script will launch LPhyBEAST using the BEAST 2 applauncher. It requires $LPHY_LIB to load all LPhy’s libraries.

  1. When dealing with files situated in various directories, it is advisable to employ the absolute path. This method offers the entire path of the file or folder on the file system, ensuring accurate referencing and access:
cd $MY_PATH
$BEAST_PATH/bin/lphybeast $LPHY_PATH/tutorials/RSV2.lphy

Please note: In case the path contains whitespaces, it must be enclosed within quotation marks to ensure that the whitespace is interpreted correctly by picocli. This will help avoid any issues related to file path parsing.

  1. When dealing with relative paths for input/output, LPhyBEAST will automatically append user.dir to the beginning of the path. If you wish to explicitly define the user.dir from the LPhyBEAST command line, you can use the -wd option as shown below. However, if you omit the -wd option, the user.dir will be automatically set to the parent folder where the input LPhy script is located.
$BEAST_DIR/bin/lphybeast -wd $LPHY_PATH/tutorials/ -l 15000000 -o RSV2long.xml RSV2.lphy

This also contains two extra arguments:

  • -l changes the MCMC chain length (default to 1 million) in the XML;
  • -o replaces the output file name (default to use the same file steam as the lphy input file).

If a LPhy script uses the relative path to load data, e.g., D = readNexus(file="data/RSV2.nex", ...);, the data subfolder containing RSV2.nex has to be in the same folder where “RSV2.lphy” sits inside.

Note: please use -wd to simplify your input and output paths. Do not make them more complex, such as combining -wd with relative paths in either input or output. For example, do not try -wd $LPHY_PATH tutorials/RSV2.lphy, then you will mess up some relative paths inside the LPhy scripts, e.g. readNexus.