Pline plugin API
The Pline plugin API allows to describe command-line program arguments and corresponding interface in JSON format.
Each option is specified with an Object
containing one or more attributes described in this document.
The interface elements (and the resulting arguments in the command line) are generated in the same order as they appear in JSON.
TIP
Native Javascript objects can be used instead of JSON. Object format supports e.g. embedded comments and unquoted attribute names:
JSON
{"name": {"key": "value"}}
Object
{name: {key: "value"}} //some comment
Glossary
- program - command-line executable
- options
- additional parameters added to the program launch command
- descriptions of program parameters in the plugin JSON file
- attributes â JSON-formatted text fields for describing plugin/program options
- tracked name â name of an option in JSON (set with name or option attribute)
- input â HTML input element (a textbox, checkbox or selection menu) in the generated plugin interface
String
,Boolean
,Array
,Object
â valid value types for the attributes
Plugin attributes
These attributes describe the program or plugin settigns.
program: String
Name of the executable (global command or filepath in the plugin folder).
options: Array
Array
can contain strings (displayed as text) and option objects (described in the next section).
You can group options to multiple âoptionsâ arrays by wrapping each Array
to an Object
.
The group wrapper appearance can be customized by including one of these attributes:
group:
String
options (input elements) are displayed in a collapsible section below the label String
.
collapsed:
Boolean
sets whether the options section is initially collapsed
+ Default: true
section:
String
options are displayed in a bordered section below a horizontal line and label String
.
line:
String
option inputs are displayed in a line (wrapped if necessary)
select:
String
display options in a selectable list. Same as {type:âselectâ, title:String
} (see the type attribute).
Note
Leave the String
label empty (ââ) for untitled section.
Optional plugin attributes:
desc: String
Description of the program. Can include HTML and web addresses are automatically parsed to HTML links.
name: String
Name of the program.
icon: String | Array
Icon for the program interface.
String
can be:
- SVG path. Example:
âM 11.193359 0.55078125 zâ
- Image data URI: Example:
âdata:image/gif;base64,R0lGODlhEAâŚâ
- Path to image file (in the plugin folder). Example:
âimages/icon.jpgâ
Multiple icon formats can be given inArray
.
outfile: String | Object | Array
Specifies (partial or full) name of the the expected main output file.
You can list alternative candidates in Array
(file selected after program execution).
TIP
Use Object
for conditional output naming (see Conditionals) or a comma-separated String
for specifying multiple output files.
submitBtn: String | Object | Array
String
is a label displayed on the submit button in the interface.
- Default:
âSend jobâ
Use (Array
of) Objects
for conditional labeling (see Conditionals).
prefix: String
Specifies leading character(s) for each parameter name in the command line.
- Default:
â-â
Prefix can also be set for a single option or options group.
valuesep: String
Specifies the character separating parameter name from its value in the command line.
- Default:
â â
version: String
The version of the program the plugin is written for.
disable: true
Sets the plugin as disabled.
debug: true | String
Write debug messages to the javascript console to keep track of plugin JSON parsing and value changes of all (if set to true
) or one specific (if set to option name String
) option in the interface.
- Default:
false
Option attributes
These properties are used in each JSON Object
describing an option in the options Array
.
type: âboolâ | âtickboxâ | âcheckboxâ | âintâ | âfloatâ | ânumberâ | âtextâ | âstringâ | âfileâ | âhiddenâ | âselectâ | âoutputâ
Sets the type for the option (input argument).
- Default:
"text"
Available option types:
âfileâ
â option accepts input datafile.
Optional attributes for file inputs
- Use the title attribute to add custom text to the filedrop area
- Use the desc attribute to add custom text next to the filedata that user has added
- Use the name attribute to change the filename
âdirpathâ
â for giving the program a directory path Use this option if the program parameter value (named via option attribute) needs a full path to the working directory. Otherwise works as theâhiddenâ
option type.
TIP
You can add a filename to the directory path with the default attribute.
âhiddenâ
â automatically added option without user input. Use default attribute to set its value. With option attribute, âdefaultâ sets pre-defined program arguments (String | Number
) or flags (true/false).
Note
- âhiddenâ options can use value attribute as alias to âdefaultâ.
- âhiddenâ option with an empty/false value excludes it from the command line.
Note
The program output stream (console output) will be written to text file output.log. If the program prints its results to screen, direct it to another file: {hidden: âoutfile.faâ, prefix: â>â}
âselectâ
â list of options (or values for an option) where only one can be selected. Additional attributes:- selection:
Array
ofString | Number | Object
items
Mutually exclusive list of items to choose from.
String | Number
is a shorthand for{title: String|Number, value: String|Number}
.
Valid attributes in the selection list
Object
:- title:
String
Text to be displayed in the list.
Note
title also sets the selection item value (unless overriden with value).
- option:
String | Array | Object
Other program option(s) to be set when the item is selected. Program options can be set as {argname:âargvalueâ
} or asâargnameâ
forBoolean
options (command-line flags).
TIP
title can be omitted if option is set as
String
.- value:
String | Number | âno valueâ
Sets the value for the program option/selection when this list item is selected.âno valueâ
assigns an empty value (ââ
). When value attribute is omitted,âtitleâ
is used instead. - desc:
String
Additional text (shown via info icon) for the selected item. - default:
true | String
Sets the item as the initial selection.
Note
default:
String
is a shorthand for {title:String
, default:true
}- extendable:
true | âconfigurationsâ
Allows users to add custom options to the selection list.âconfigurationsâ
allows to select or store sets of values (presets) for all the plugin options.
- selection:
âboolâ | âtickboxâ | âcheckboxâ | âswitchâ
Tickbox element. User input adds/removes the option from the command line.âtextâ | âstringâ
Text input box. User input is assigned to an option (see option attribute) and/or tracked name (name attribute).ânumberâ | âintâ | âfloatâ
Same astype: âtextâ
, but accepts only numerical input.âintâ
restricts input to whole numbers.
TIP
- type, title and option attributes can be combined to inputType:
String
shorthand syntax:
{number: âargnameâ}`
Available for option types
âtextâ
,ânumberâ
,âtickboxâ
andâselectâ
- When name attribute is present (or type is
âselectâ
), the syntax sets just the title (e.g. not a command line argument). - type: âdefaultâ shorthand syntax is available for option types
âoutputâ
andâhiddenâ
.
{output: âoutfile.fasâ}
title: String
Shows a text label next to the input element (except for option type âhiddenâ).
option: String
Sets the command-line argument name. Also sets a reference name for its value tracking (see name attribute).
You can include a prefix to override global prefix attribute. Set to empty String
(ââ) for positional arguments.
Note: options are passed to the program in the order of appearance in JSON.
TIP
Use the name attribute to differentiate between multiple options with the same argument name.
desc: String
Tooltip text, displayed when hovering the title (or form element when title is missing).
name: String
Enables option value tracking. String
is unique reference name that can be used by other options (see e.g. âenableâ and âdefaultâ attributes).
Overrides the option attribute as reference name for tracking.
enable | disable: Boolean | String | Object | Array
Includes or excludes the program argument(s) from command line, its input element(s) from the interface, and clear the input value (revert the option to its âdefaultâ or empty value).
String
or Object
(or Array
of these) define rules for conditional enabling/disabling (see Conditionals).
Examples
{ enable: âoption_name is not tickedâ }
{ disable: {ââoption nameâ is more than 10â: âyesâ}
{ enable: âno treeâ }
{ enable: âoption_name is disabledâ }
check: String | Object
Checks the option value and displays the message String
whenever the input element is empty
Object
is a conditional in the form {rule
: String
}, where rule
is a logic expression (see Conditionals) to check the input element value against, and String
is the corresponding error message.
required: String | Object
Same as the check attribute, except
- checks the value and displays the error message only after the âsubmitâ button is clicked, and
- an error prevents the plugin launch.
default: value | Object | Array
Initial/default value for an option. Can be overriden by user input, unless the input element is disabled with fixed, disabled or hidden attribute.
Note
For text inputs, it is assumed that the default value does not need to be added to the program command line parameters, and is shown just for information when user has not inserted any value. If itâs not the case, make the program option compulsory with the required attribute.
Conditionals
The value for the default (and many other) option attributes can change according to a logical expression (conditional) and the values of the current (or any other) option. The conditional values are defined in the plugin JSON as {condition
: result
} objects.
- Alternative (mutually exclusive) conditionals can be listed in array: [{
condition1
:result1
}, {condition2
:result2
}, âŚ]. - The conditional strings can use Javascript logical operators, which in the plugin JSON can be replaced with API keywords:
- âisâ/âequalsâ (=); ânotâ/âis notâ (!=)
- âcontainsâ
- âandâ (&&), âorâ (||)
- âtickedâ/âselectedâ/âonâ/âenableâ (true)
- ânoâ/âoffâ/âdisableâ (false)
- âinvertâ (!)
Both the
condition
andresult
strings can use the option input values via each optionâs tracked name (set by the option or name attributes). Together with the logic expressions, you can construct rules to check for a value of an option and change an option attribute accordingly.
Examples
{disable: {âoption_name is not tickedâ: true}}
{check: {âoption_name is 10â: âyou typed 10â}}
{default: {âoption_name is more than other_option_name and no third_optionâ: ânumeric_option + 0.5â}}
Note
Wrap tracked/option names to single quotes (ââoption name'â
) if it contains spaces.
Wrap tracked names to escaped double quotes (â\âoptionName\ââ
) to use the name as text (instead of the optionâs value).
{ââsome argumentâ equals \âsome argument\ââ : âThe option value is now its name:\âsome argument\â.â }
fixed: âyesâ | true | String | Object | Array
Input element cannot be changed by user. String
or Object
(or Array
of these) define rules for conditional fixing (see enable attribute).
If input element is disabled by fixed, the default value (see default attribute) overrides input value from user.
format: âinvertâ | expressionString | Object
Do some postprocessing with the value of this option (this_option_name) before passing to the program.
âinvertâ
is same as âinvert this_option_nameâ
(only useful for Boolean
type options).
expressionString
is a fixed value or javascript code for formatting.
Example
{ format: âthis_option_name + \â concatenated text\'â. }
Object
can be used for conditional formatting (see Conditionals):
{ âthis_option_name is less than 0â: âMath.abs( this_option_name )â }
Note
- the type of the variable this_option_name is defined by type:
String | Boolean | Number
- in Javascript expression, use spaces around
option_name
,\âquoted text\â
and other syntax tokens
line: Boolean
Options marked with line attribute are displayed in one line (alternative to grouping with the line attribute)
prefix: String
Option-specific command-line prefix (overrides global prefix attribute).
TIP
You can inspect/debug imported plugins via Javascript console:
console.log( Pline.plugins[âplugin nameâ] ); //plugin datamodel object
console.log( Pline.plugins.pluginName.options.optionName() ); //current input value
Wasabi-specific attributes
Wasabi extends the Pline plugin API with some attributes and modifications.
Plugin attributes
menudesc:
String
Short description of the program. Displayed as tooltip in the Wasabi tools menu (on mouseover).
icon:
String | Array
Wasabi displays the program icon in the tools menu and in the interface window. These can be given as
Array
with an SVG and img/png (recommended size 25*25px).outfile:
String | Object | Array
This attribute tells Wasabi which file to use for the âOpenâ button in the analysis library. Use comma-spearated
String
for opening a dataset with multiple files (e.g."alignment.fas,tree.nwk"
).translate_names:
Boolean
If set to true, all sequence names in input file(s) are converted to simple IDs (âseq1â, âseq2â, âŚ), which are translated back to the original names when the output is opened in Wasabi.
Default:
false
(retain input taxa names, with spaces converted to underscore)enable:
âtreeâ | âsequenceâ | âdataâ
The plugin is disabled until tree/sequence/one of these is imported (e.g. required for input file).
libraryname:
String
Default name for the stored results in the analysis library
Default:
âmy analysisâ
Additional attributes for type: "file" input options:
source:
âcurrent sequenceâ | âcurrent treeâ | âcurrent dataâ | âfileinputâ
Sets input file data source: either currently imported dataset or a local file added by the user (using the file input).
Default:
âcurrent sequenceâ
fileformat:
âfastaâ | ânewickâ | âextended newickâ | âphyloxmlâ | âhsamlâ | âphylipâ | ânexusâ | âoriginalâ
Input file will be converted to specified format before feeding it to the program. Use
âoriginalâ
to skip file conversion.Default:
âfastaâ
(for sequence data) |ânewickâ
(for tree)TIP
- Use multiple (
[âfastaâ,ânewickâ]
) or merged (âphyloxmlâ
) file formats if both tree and sequence data is expected. inputType: âsourceâ
shorthand syntax can be used for fileinputs:
{file: âfiledropâ}
Conditionals Wasabi adds predefined option names
âtreeâ
,âsequenceâ
and keywordsâDNAâ
,âRNAâ
,âcodonsâ
,âproteinâ
.
These can be used to check for the data type and the type of sequence that is currently imported in the Wasabi interface:
//example conditionals
{âsequence and no treeâ: âtickedâ}
{âsequence is DNAâ: 0.5}
Note
Donât use the Wasabi reserved keywords (e.g. "tree") as an option name attribute
The âtreeâ
/âsequenceâ
keywords can also be used to check the content of user-supplied file data.
Remember to quote the keywords when used in this form:
{âfileInputOption contains \âsequence\ââ: ânewValueâ}
â Guide