Make XML Parameters
Created: 2012-02-08 16:10:48
Last updated: 2012-02-08 16:12:39
Reformats a SNP list with optional p-value into the required XML input for the 'Define Associated Regions and Genes' workflow. Additional parameters can be supplied to add to the XML document.
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (0)
Titles (0)
Descriptions (0)
Dependencies (0)
Inputs (2)
Name |
Description |
associatedSNPs |
|
additionalParameters |
|
Processors (5)
Name |
Type |
Description |
additionalParamsToList |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
splitParamsRegex |
stringconstant |
Value[\n\r]+ |
associatedSNPsToList |
localworker |
ScriptList split = new ArrayList();
if (!string.equals("")) {
String regexString = ",";
if (regex != void) {
regexString = regex;
}
String[] result = string.split(regexString);
for (int i = 0; i < result.length; i++) {
split.add(result[i]);
}
}
|
addAssociatedParameter |
beanshell |
Scriptimport org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.dom.DOMDocument;
// Create Document.
Document paramDoc = new DOMDocument();
// Add root element.
Element rootElement = paramDoc.addElement("Parameters");
Element paramElement = rootElement.addElement("Parameter")
.addAttribute("name", "associatedSNPs");
Element assocElement = paramElement.addElement("AssociatedSNPs");
//ArrayList xmlElements = new ArrayList();
// Loop through SNPs, split into ID & pValue.
for (int i = 0; i < associatedSNPs.size(); i++) {
String line = (String) associatedSNPs.get(i);
if (line == null || line.equals(""))
continue;
String [] lineArray = line.split("\t");
Element snpElement = assocElement.addElement("AssociatedSNP")
.addAttribute("rsId", lineArray[0]);
if (lineArray.length > 1)
snpElement.addAttribute("pValue", lineArray[1]);
}
paramXML = paramDoc.asXML(); |
addAdditionalParams |
beanshell |
Scriptimport org.dom4j.Element;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
List errors = new ArrayList();
if (additionalParams == void || additionalParams.size() == 0) {
paramXmlOut = paramXmlIn;
} else {
// Initialise Reader for parameter XML.
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
Document paramDoc = reader.read(new StringReader(paramXmlIn));
Element rootElement = paramDoc.getRootElement();
for (int i = 0; i < additionalParams.size(); i++) {
String paramInfo = (String) additionalParams.get(i);
if (paramInfo == null || paramInfo.equals(""))
continue;
String [] paramArray = paramInfo.split("\t");
if (paramArray.length != 2) {
errors.add("Invalid parameter '" + paramInfo + "' on line " + (i + 1) + ".");
continue;
}
// Add Parameter.
Element paramElement = rootElement.addElement("Parameter")
.addAttribute("name", paramArray[0]);
paramElement.addText(paramArray[1]);
}
paramXmlOut = paramDoc.asXML();
} |
Beanshells (2)
Name |
Description |
Inputs |
Outputs |
addAssociatedParameter |
|
associatedSNPs
|
paramXML
|
addAdditionalParams |
|
additionalParams
paramXmlIn
|
paramXmlOut
errors
|
Outputs (2)
Name |
Description |
xmlOutput |
|
errors |
|
Datalinks (9)
Source |
Sink |
splitParamsRegex:value |
additionalParamsToList:regex |
additionalParameters |
additionalParamsToList:string |
splitParamsRegex:value |
associatedSNPsToList:regex |
associatedSNPs |
associatedSNPsToList:string |
associatedSNPsToList:split |
addAssociatedParameter:associatedSNPs |
addAssociatedParameter:paramXML |
addAdditionalParams:paramXmlIn |
additionalParamsToList:split |
addAdditionalParams:additionalParams |
addAdditionalParams:paramXmlOut |
xmlOutput |
addAdditionalParams:errors |
errors |
Uploader
License
All versions of this Workflow are
licensed under:
Version 1
(of 1)
Credits (1)
(People/Groups)
Attributions (0)
(Workflows/Files)
None
Shared with Groups (0)
None
Featured In Packs (0)
None
Log in to add to one of your Packs
Attributed By (0)
(Workflows/Files)
None
Favourited By (0)
No one
Statistics
Other workflows that use similar services
(0)
There are no workflows in myExperiment that use similar services to this Workflow.
Comments (0)
No comments yet
Log in to make a comment