Mobyle XML file

Download Report

Transcript Mobyle XML file

Version history:
First version for training Nick and Art
– Vivek, 02/07/2011
Mobyle XML
Vivek Gopalan
Mobyle XML
• Link between command-line application and
web-form or web service
• Defines the command-line application
documentations and arguments in XML
format
Mobyle Framework : Command-line Application to Web Application
clustalw-mobyle.xml
Tutorial
• Assume Vivek has written a simple commandline application called fah2celsius to convert
Fahrenheit (F) to Celsius (C)
fah2celsius --input 270
• The above commands prints the Celsius value
in the standard output.
• Let’s convert this simple application to web
application using Mobyle Framework
Implementation/Deployment steps
1. Create a Mobyle XML file called fah2celsius.xml to handle
the application input and output parameters.
fah2celsius --input 270
2. Copy the file to the Local/Services/Programs folder in
Mobyle library folder
– Mobyle folder is configured by default to fetch XML files from
this folder
3. Deploy the fah2celsius.xml to the Mobyle web location
using Tools/mobdeploy command
–
The deployment step checks erros and processes the XML file
from the above folder and copy it to the web folder that is
accessible by Mobyle application.
Tools/mobdeploy deploy -p fah2celsus
4. Test the deployment from the Mobyle web interface
Design slide link
Mobyle XML file – primary tags
program tag is the primary tag used to define about specific application
head tag contains the metadata about the
Application such as title, author, categories,
Documentation, references, etc.
parameters tag defines the input and output
arguments used by the command-line
XML view generated using http://xmlgrid.net/
Mobyle XML file – head tag (meta data)
name tag (usually same as the XML file name), used to name job name
category tag is used to show the fah2cesius
application in the applications list tree in Mobyle
interface
command tag represent the actual command or executable file name
XML view generated using http://xmlgrid.net/
Mobyle XML file – parameter Vs Paragraph
Parameter represents a specific command line argument
and represent one HTML form component or widget.
First parameter (input_value)
fah2celsius --input 270
1st parameter (input_value)
3rd parameter (output_file)
fah2celsius --input 270 --format-output > celcius.txt
2st parameter (format_output)
Paragraph represents one or more parameters
(command line argument)
2nd and 3rd parameters could be combined as “Output options”
XML view generated using http://xmlgrid.net/
Parameter
• Defines the specific argument of command line
arguments
– Should contain unique name
– value and/or default value
– Code to generate the command-line argument string
• Written as simple python conditions
– User-friendly description and comments
– Relative position of it in the command-line
– Precondition to generate the condition
• E.g only add the parameter value if some other parameter
value is selected
• Written as simple python conditions
Parameter - continues
– Different data types that is mapped to specific HTML
form components or widgets
•
•
•
•
•
Sequence/Alignment/Tree (file upload button)
Integer/Float/String (Text box)
Text/Report (File upload button)
Choice/MultipleChoice (list box)
Boolean (Check box)
– Can be categorized based on the attributes
• Issimple ( show in simple view only)
• Ishidden (do not show this panel – used for options that are
given as default)
• Ismandatory (cannot be empty)
• Isstdout/isout ( the output files generated from the
application – used for pipelining and workflow creation)
Mobyle XML file – parameter
The parameter tag attributes represents the categories
The name tag should be unique.
The prompt tag gives the simple description
The type/datatype/class tags defines the type
The argpos tag defines the relative position of the
Parameter in the command line
The format tag defines actual command-line string
Generated. A python code snippet is used.
XML view generated using http://xmlgrid.net/
Mobyle XML file – Other examples (Boolean type)
The vdef value selects the default value for Boolean type
It can be 0 or 1
XML view generated using http://xmlgrid.net/
Python code snippet
• The parameter name is used refer to value
– E.g input_value could used to refer to the
value of that parameter in any parameters
• Special variables - value & vdef
– Parameters cannot have value or vdef as their
names or id.
– value: represents the selected value of that
parameter or file name (if parameter is file
upload)
– vdef: represents the default value of that
parameter
Python code snippets
1. Concatenation:
“ --input “ + str(value)
If the value entered by user is 10 then “ --input 10” will
Be generated by the above code
Notes:
1. Leave a whitespace at the beginning of the code.
2. + is used to concatenate two string
3. Double or single quote should be used to delimit strings
2. One line Condition:
(“” , “ -b ”)[value is not None]
(“” , “ --o ” + str(value))[value != vdef]
(“ --x ” + vdef , “ --x ” + value)[input_value < 5 ]
General structure : circular bracket and square bracket
(false action, true action) [condition]
The input_value represent the parameter name in that XML file.
Python code snippets
3. Check value is present in a list:
(“”,” –a tempCal ”) [ input_type in [‘fahrenheit’,’celsius’] ]
If input_type parameter value is fahrenheit or celsius
then “ –a tempCal “ will be used as parameter command-line
Argument
Very often used in the <precond> tag which is used to
check/evaluate whether the command-line argument for that
parameter could be used or not in the command.
Paragraph
• Contains one or more parameters
• Group command-line arguments into
meaningful categories
– E.g. input options, output options, advanced
features
• Could be used to control the layout of
multiple parameters (not often used now in
Mobyle)
Mobyle XML file – paragraph
The name tag should be unique.
The parameters tag defines multiple parameters
Or paragraphs in it
The layout tag could be used for arranging the parameters
In the paragraph in the web interface (optional)
XML view generated using http://xmlgrid.net/
Design steps
(follow this before implementation step)
• Read the manual or help page of the command-line application
– Note whether the order of parameter matters
• Categorize the parameters into meaningful groups(paragraph)
• Use the command-line arguments names (eg. --input or -x ) as part
of the parameter description (<prompt> tag)
• Note down the different types of output files generated from
application
– Useful to display the output file in job results and linking to other applications
in workflow
• Note which parameters will be assigned simple and/mandatory
• Try to use all the command-line arguments for the applications
– Helps experienced command-line user to related web form to the commandline utility
Implementation slide link
Final notes
• Use Xinclude option for parameters that uses
local resources
– Eg blast databases
– Eg bowtie indexes
• Remember
– We covered only the <program> tag in this tutorial
– Mobyle manages the job results and workflow
definitions also through XML
– Workflow definitions can be automatically handled
Mobyle Workflow application or manually by user.
Thanks….