PCD ENV
From Bioinformatics.Org Wiki
Click here to go back to: PCD
Proposal
There are endless possible uses for being able to substitute environment variables into parameter values. For example, in $BIRCH/dat/blreads/PCD/Reads/FastQC.blmenu,
var "threads" type number label "Number of threads to use" min 1 max $BL_CORES default 4
"$BL_CORES" would be replaced with the value of the BL_CORES variable, which is set in some of the biolegato launchers such as bldna. This variable tells the number of cores on the system. If BL_CORES was 8, then the threads parameter would be parsed as
var "threads" type number label "Number of threads to use" min 1 max 8 default 4
Considerations
Note: It may be instructive to look at the .java files generated from the .jj files during compilation, to see the correspondence between the javacc code and the java code.
pcd.jj
PARSER_BEGIN(PCD) token definitions public class PCD /** * Parses a PCD file into its corresponding PCDObject. ** * @param path the path for the file * @param canvas the canvas for the PCD menu to interact with */ public static PCDObject loadPCDFile (File path, PCDIO canvas) /** * Parses a PCD input stream into its corresponding PCDObject ** * @param in the reader object to read the menu from. * @param path the path for the file. * @param canvas the canvas for the PCD menu to interact with. */ public static PCDObject loadPCDStream (Reader in, File path, PCDIO canvas) /** * Loads a path of PCD files into BioLegato ** * @param path the relative path of the PCD file(s) to load * - used for making the command path relative * @param menu the object to store all menu items * @param canvas the parent canvas of the PCD menu items * @param parent the parent window for displaying the PCD menu items in */ public static void loadPCDPath (File path, Map<String,Map<String, PCDObject>> menu, PCDIO canvas, JFrame parent) PARSER_END(PCD) /* PRODUCTIONS */ /** * * Generates a parameter component according to the PCD file's * <T_PARAM> production(s). */ void Param(int scope, Map<String, Widget> widgetList, PCDIO pcdio)
It looks like all parsing has a step in which a string called t.image is returned, and then parsed futher. There is one of these statements for each type of value that can be processed eg. Number, Decimal, Test etc.
Probably what will have to be done is to add a step in each Production that looks for '$' at the beginning of a string and pre-processes that to resolve the environment variable.
Legal Substitution Fields
There are a limited number of fields for which it makes sense to allow an enviroment variable to be substituted:
- chooser, combobox, lists: choices value(text)
- text,textbox: default(text)
- number: min,max(integer)
- decimal (not implemented): decimal
- file: default(text)