Associated Region to Gene List
Created: 2012-02-08 16:14:17
Last updated: 2012-02-08 16:14:47
Produces a gene list from the Associated Region XML file
Preview
Run
Run this Workflow in the Taverna Workbench...
Workflow Components
Authors (1)
Titles (1)
Associated Region to Gene List |
Descriptions (1)
Produces a gene list from the Associated Region XML file |
Dependencies (0)
Inputs (2)
Name |
Description |
additionalParameters |
Allows the user to supply any additional parameters.
Options are:-
nameType [associatedName, ensgId, ucscId, description]
addRsId [false, true]
addPvalue [false, true]
geneStatus [null, anyGeneStatus]
excludeHLA [false, true]
The first value in each list specifies the default value for that parameter. HLA region is defined as 28477797-3344854, based on genome assembly hg19/GRCh37.
|
associatedSNPs |
AssociatedSNPs XML document
|
Processors (9)
Name |
Type |
Description |
parseParameters |
beanshell |
Scriptimport org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
String getParameter(Element root, String parameterName) {
List nodeList = root.selectNodes("Parameter[@name='" + parameterName + "']");
if (nodeList.size() == 1) {
Node parameterNode = (Node) nodeList.get(0);
String parameter = "";
if (parameterNode.isTextOnly())
parameter = parameterNode.getText();
else {
List paramElements = parameterNode.elements();
for (int i = 0; i < paramElements.size(); i++) {
parameter += ((Element) paramElements.get(i)).asXML();
}
}
if (parameter == null || parameter.equals(""))
return null;
else
return parameter;
} else if (nodeList.size() > 1) {
throw new Exception("Multiple parameters matching " + parameterName + "!");
}
return null;
}
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
Document document = reader.read(new StringReader(paramXML));
Element root = document.getRootElement();
// Set parameter defaults.
nameType = "associatedName";
addPvalue = "false";
geneStatus = "";
excludeHLA = "false";
addRsId = "false";
associatedSNPs = new ArrayList();
errorsOut = errorsIn;
// Get parameters from XML.
String paramTmp;
// nameType.
if ((paramTmp = getParameter(root, "nameType")) != null) {
if (paramTmp.equals("ensgId") || paramTmp.equals("ucscId") || paramTmp.equals("associatedName") || paramTmp.equals("description"))
nameType = paramTmp;
else {
errorsOut.add("Name type '" + paramTmp + "' not recognised! Must be one of ensgId, ucscId, associatedName or description.");
nameType = null;
}
}
// addPvalue.
if ((paramTmp = getParameter(root, "addPvalue")) != null)
addPvalue = paramTmp.equals("false") ? "false" : "true";
// Gene status.
if ((paramTmp = getParameter(root, "geneStatus")) != null) {
geneStatus = paramTmp;
}
// excludeHLA.
if ((paramTmp = getParameter(root, "excludeHLA")) != null)
excludeHLA = paramTmp.equals("false") ? "false" : "true";
// addRsId.
if ((paramTmp = getParameter(root, "addRsId")) != null)
addRsId = paramTmp.equals("false") ? "false" : "true";
// associatedSNPs.
if ((paramTmp = getParameter(root, "associatedSNPs")) != null) {
Document assocSnpDoc = reader.read(new StringReader(paramTmp));
List nodeList = assocSnpDoc.selectNodes(xpath);
for (int i = 0; i < nodeList.size(); i++) {
Node node = (Node) nodeList.get(i);
String xmlVal = node.asXML();
if (xmlVal != null && ! xmlVal.equals(""))
associatedSNPs.add(xmlVal);
}
} |
associatedSnpXpath |
stringconstant |
Value*/AssociatedSNP |
getGeneNames |
beanshell |
Scriptimport org.dom4j.Document;
import org.dom4j.Node;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
List geneNames = new ArrayList();
for (int i = 0; i < associatedSNPs.size(); i++) {
String xmlText = associatedSNPs.get(i);
Document document = reader.read(new StringReader(xmlText));
Node node = document.selectSingleNode("AssociatedSNP");
if (node == null)
continue;
String line = addRsId.equals("true") ? node.attributeValue("rsId") + "\t" : "";
// Get associated regions.
List assocRegionNodes = node.selectNodes("AssociatedRegion");
for (int j = 0; j < assocRegionNodes.size(); j++) {
Node assocRegionNode = (Node) assocRegionNodes.get(j);
if (assocRegionNode == null)
continue;
// Get associated Genes.
Node assocGeneNode = assocRegionNode.selectSingleNode("AssociatedRegionGenes");
if (assocGeneNode == null)
continue;
List geneNodes = assocGeneNode.selectNodes("Gene");
for (int k = 0; k < geneNodes.size(); k++) {
Node geneNode = (Node) geneNodes.get(k);
if (geneNode == null)
continue;
String statusAtt = geneNode.attributeValue("status");
if (! geneStatus.equals("") && ! statusAtt.equals(geneStatus))
continue;
Node locationNode = (Node) geneNode.selectSingleNode("Location[@ucscBuild='hg19']");
if (locationNode != null && excludeHLA.equals("true")) {
String chr = locationNode.attributeValue("chromosome");
int start = locationNode.attributeValue("start") == null ? 0 : Integer.parseInt(locationNode.attributeValue("start"));
int end = locationNode.attributeValue("end") == null ? 0 : Integer.parseInt(locationNode.attributeValue("end"));
if (chr.equals("chr6") && start <= 33448354 && end >= 28477797)
continue;
}
if (nameType.equals("ensgId")) {
String id = line + geneNode.attributeValue("ensgId");
if (addPvalue.equals("true"))
id += node.attributeValue("pValue") == null ? "\t" : "\t" + node.attributeValue("pValue");
geneNames.add(id);
continue;
}
List geneNameNodes = geneNode.selectNodes("GeneName");
for (int l = 0; l < geneNameNodes.size(); l++) {
Node geneNameNode = (Node) geneNameNodes.get(l);
if (geneNameNode == null)
continue;
String type = geneNameNode.attributeValue("type");
if (type.equals(nameType)) {
String name = line + geneNameNode.attributeValue("name");
if (addPvalue.equals("true"))
name += node.attributeValue("pValue") == null ? "\t" : "\t" + node.attributeValue("pValue");
geneNames.add(name);
continue;
}
}
}
}
} |
addAssociatedParameter |
beanshell |
Scriptimport org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.Node;
import org.dom4j.dom.DOMDocument;
import org.dom4j.io.SAXReader;
SAXReader reader = new SAXReader(false);
reader.setIncludeInternalDTDDeclarations(false);
reader.setIncludeExternalDTDDeclarations(false);
Document document = reader.read(new StringReader(associatedSNPs));
Element root = document.getRootElement();
// Create Document.
Document paramDoc = new DOMDocument();
// Add root element.
Element rootElement = paramDoc.addElement("Parameters");
Element paramElement = rootElement.addElement("Parameter")
.addAttribute("name", "associatedSNPs");
paramElement.add(root.detach());
paramXML = paramDoc.asXML(); |
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]);
}
}
|
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();
} |
splitParamsRegex |
stringconstant |
Value[\n\r]+ |
removeDuplicateGenes |
localworker |
ScriptList strippedlist = new ArrayList();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
if (strippedlist.contains(item) == false) {
strippedlist.add(item);
}
}
|
geneListToString |
localworker |
ScriptString seperatorString = "\n";
if (seperator != void) {
seperatorString = seperator;
}
StringBuffer sb = new StringBuffer();
for (Iterator i = stringlist.iterator(); i.hasNext();) {
String item = (String) i.next();
sb.append(item);
if (i.hasNext()) {
sb.append(seperatorString);
}
}
concatenated = sb.toString();
|
Beanshells (4)
Name |
Description |
Inputs |
Outputs |
parseParameters |
|
paramXML
xpath
errorsIn
|
nameType
addPvalue
associatedSNPs
errorsOut
geneStatus
excludeHLA
addRsId
|
getGeneNames |
|
nameType
associatedSNPs
addPvalue
geneStatus
excludeHLA
addRsId
|
geneNames
|
addAssociatedParameter |
|
associatedSNPs
|
paramXML
|
addAdditionalParams |
|
additionalParams
paramXmlIn
|
paramXmlOut
errors
|
Outputs (2)
Name |
Description |
errors |
|
geneNames |
|
Datalinks (18)
Source |
Sink |
associatedSnpXpath:value |
parseParameters:xpath |
addAdditionalParams:paramXmlOut |
parseParameters:paramXML |
addAdditionalParams:errors |
parseParameters:errorsIn |
parseParameters:associatedSNPs |
getGeneNames:associatedSNPs |
parseParameters:addPvalue |
getGeneNames:addPvalue |
parseParameters:nameType |
getGeneNames:nameType |
parseParameters:geneStatus |
getGeneNames:geneStatus |
parseParameters:excludeHLA |
getGeneNames:excludeHLA |
parseParameters:addRsId |
getGeneNames:addRsId |
associatedSNPs |
addAssociatedParameter:associatedSNPs |
additionalParameters |
additionalParamsToList:string |
splitParamsRegex:value |
additionalParamsToList:regex |
additionalParamsToList:split |
addAdditionalParams:additionalParams |
addAssociatedParameter:paramXML |
addAdditionalParams:paramXmlIn |
getGeneNames:geneNames |
removeDuplicateGenes:stringlist |
removeDuplicateGenes:strippedlist |
geneListToString:stringlist |
parseParameters:errorsOut |
errors |
geneListToString:concatenated |
geneNames |
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