[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Sat Apr 10 00:40:18 UTC 2010


gordonp
Fri Apr  9 20:40:17 EDT 2010
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util
In directory dev.open-bio.org:/tmp/cvs-serv14854/src/main/ca/ucalgary/seahawk/util

Modified Files:
	DataFlowRecorder.java DataUtils.java FilterSearch.java 
Log Message:
Added support for filter inversion (boolean negation)
moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,1.3,1.4 DataUtils.java,1.2,1.3 FilterSearch.java,1.3,1.4
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java	2010/04/09 15:58:22	1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java	2010/04/10 00:40:17	1.4
@@ -174,7 +174,8 @@
 	    String[] regexProcessorAndPorts = null;
 	    String filterKey = null;
 	    if(filter != null && filter.getFilterRegex().length() > 0){
-		filterKey = result.getKey()+"\n"+filter.getFilterRegex()+"\n"+filter.getSelectedXPath().getXPath();
+		filterKey = result.getKey()+"\n"+filter.getFilterRegex()+"\n"+
+		    filter.getSelectedXPath().getXPath()+"\n"+filter.getCaseSensitivity();
 	    }
 
 	    // Create the workflow output and data links
@@ -206,8 +207,10 @@
 			filter2Processor.put(filterKey, regexProcessorAndPorts);
 		    }
 
+		    // The proc has an output port for non-matches (penultimate index) and matches (ultimate index)
+		    int regexOutPort = regexProcessorAndPorts.length-(filter.getSelectionInversed() ? 2 : 1);
 		    datalinks.appendChild(createWorkflowOutputLinkElement(regexProcessorAndPorts[0],
-									  regexProcessorAndPorts[regexProcessorAndPorts.length-1],
+									  regexProcessorAndPorts[regexOutPort],
 									  uniqueOutputName,
 									  doc));
 		    break; // only one output when filter is attached: the XML doc
@@ -317,16 +320,18 @@
 		// where the filter and conditionalURL are optional 
 		data = sampleData.getUserData().toString().split("\t");
 		//options: selection + filter + cond, selection + cond, or cond only
-		if(data.length == 11 || data.length == 7 || data.length == 5){
+		if(data.length == 14 || data.length == 8 || data.length == 6){
 		    System.err.println("Adding conditional for " + resultURLString);
-		    String conditionURL = data[data.length-5];
-		    String conditionRegex = data[data.length-4];
-		    XPathOption conditionXPath = new XPathOption(data[data.length-3], data[data.length-2]);
-		    boolean caseSensitivity = Boolean.parseBoolean(data[data.length-1]);
-		    condPassProcessorAndPorts = createServiceConditionFilter(new URL(conditionURL), conditionRegex, conditionXPath, caseSensitivity,
+		    String conditionURL = data[data.length-6];
+		    String conditionRegex = data[data.length-5];
+		    XPathOption conditionXPath = new XPathOption(data[data.length-4], data[data.length-3]);
+		    boolean caseSensitivity = Boolean.parseBoolean(data[data.length-2]);
+		    boolean inverse = Boolean.parseBoolean(data[data.length-1]);
+		    condPassProcessorAndPorts = createServiceConditionFilter(new URL(conditionURL), conditionRegex, 
+									     conditionXPath, caseSensitivity, inverse,
 									     doc, inputPorts, processors, datalinks);
-		    String[] conditionlessData = new String[data.length-5];
-		    System.arraycopy(data, 0, conditionlessData, 0, data.length-5);
+		    String[] conditionlessData = new String[data.length-6];
+		    System.arraycopy(data, 0, conditionlessData, 0, data.length-6);
 		    data = conditionlessData;
 		}
 		else{
@@ -357,10 +362,10 @@
 		    feedingProcessorName = addWorkflowElements(dataSrcURL, doc, inputPorts, processors, datalinks);
 		}
 		
-		// Take into account data[2..5] if they are present, 
+		// Take into account data[2..6] if they are present, 
 		// which filter the data by a regex before any other activities happen
 		// Format of spec is regex <tab> xpath <tab> xpathTextDesc <tab> booleanForCaseSensitivity
-		if(data.length == 6){
+		if(data.length == 7){
 		    String[] origFeederProcessorAndPort = getPortFromURLRef(dataSrcURL,
 									    sampleData,
 									    feedingProcessorName,
@@ -370,9 +375,11 @@
 									    doc,
 									    false);
 		    
-		    // Lookup key is url \n regex \n xpath \n caseSensitivity
+		    // Lookup key is url \n regex \n xpath \n caseSensitivity 
+		    // (inverse selection uses same processor, different output port, so not part of the key)
 		    String[] regexProcessorAndPorts = null;
 		    String filterKey = dataSrcURLString+"\n"+data[2]+"\n"+data[3]+"\n"+data[5];
+		    boolean inversed = Boolean.parseBoolean(data[6]);
 		    if(filter2Processor.containsKey(filterKey)){ // filter already exists from another branch
 			regexProcessorAndPorts = filter2Processor.get(filterKey);
 		    }
@@ -389,7 +396,9 @@
 			filter2Processor.put(filterKey, regexProcessorAndPorts);
 		    }
 		    feedingProcessorName = regexProcessorAndPorts[0];
-		    feedingProcessorPort = regexProcessorAndPorts[regexProcessorAndPorts.length-1];  //last one is output
+		    // The proc has an output port for non-matches (penultimate index) and matches (ultimate index)
+		    int regexOutPort = regexProcessorAndPorts.length-(inversed ? 2 : 1);
+		    feedingProcessorPort = regexProcessorAndPorts[regexOutPort];  
 		}
 		
 		// getPortFromURLRef() may inject extra processors between the processorName and feedingProcessorName
@@ -921,6 +930,7 @@
 		// supertype of the output from the other service!		
 		if(namespace != null){
 		    MobyNamespace nsObj = MobyNamespace.getNamespace(namespace, getRegistryFromService(srcService));
+		    System.err.println("About to create namespace filter for "+ srcProcessor + " port " + portName + " when srcPort was " + srcPort);
 		    return createNamespaceFilter(nsObj, srcProcessor, portName, processors, datalinks, doc);
 		}
 		else if(xrefNs != null){
@@ -974,7 +984,7 @@
     // and passing the filter condition set on f.  Equivalent to if(f(X) matches f_filter){...}
     // returns [proc name, input port, output port]
     private String[] createServiceConditionFilter(URL conditionURL, String filterRegex, XPathOption filterXPath,
-						  boolean caseSensitive, Document doc,
+						  boolean caseSensitive, boolean inverse, Document doc,
 						  Element inputPorts, Element processors, Element datalinks)
 	throws Exception{
 
@@ -996,30 +1006,31 @@
  	}
 
  	String filterKey = dataSrcURLString+"\n"+filterRegex+"\n"+filterXPath.getXPath()+"\n"+caseSensitive;
- 	String[] regexFilterProcNameAndPort = null;
+ 	String[] regexFilterProcNameAndPorts = null;
  	//todo: gimpy loop below, as more than one service output would cause a trampling of regex output ports
  	for(MobyPrimaryData outputParam: service.getPrimaryOutputs()){
  	    // See if the filter on the conditional service has already been used in the workflow
  	    if(filter2Processor.containsKey(filterKey)){
- 		regexFilterProcNameAndPort = filter2Processor.get(filterKey);
+ 		regexFilterProcNameAndPorts = filter2Processor.get(filterKey);
  	    }
  	    else{
- 		regexFilterProcNameAndPort = createRegexFilter(filterRegex, 
+ 		regexFilterProcNameAndPorts = createRegexFilter(filterRegex, 
  							       filterXPath,
 							       caseSensitive, 
  							       processorName,
  							       getPortName(outputParam, true),
 							       0, //depth of list desired (will return match count)
  							       processors, datalinks, doc);
- 		filter2Processor.put(filterKey, regexFilterProcNameAndPort);
+ 		filter2Processor.put(filterKey, regexFilterProcNameAndPorts);
  	    }
  	}
 
 	// We need to flatten the 2-deep list generated by the regex filter's cross product
 	String[] beanShellFlattenerProcNameAndPorts = addListFlattenBeanShell(processors, doc);
 
-	datalinks.appendChild(createDataLinkElement(regexFilterProcNameAndPort[0],
-						    regexFilterProcNameAndPort[1],
+	int regexOutPort = regexFilterProcNameAndPorts.length-(inverse ? 2 : 1);
+	datalinks.appendChild(createDataLinkElement(regexFilterProcNameAndPorts[0],
+						    regexFilterProcNameAndPorts[regexOutPort],
 						    beanShellFlattenerProcNameAndPorts[0], 
 						    beanShellFlattenerProcNameAndPorts[1],
 						    doc));
@@ -1068,7 +1079,9 @@
 						    beanShellFilterProcNameAndPorts[0], 
 						    beanShellFilterProcNameAndPorts[4],
 						    doc)); 
-	return new String[]{beanShellFilterProcNameAndPorts[0], beanShellFilterProcNameAndPorts[5]};	
+	return new String[]{beanShellFilterProcNameAndPorts[0], 
+			    beanShellFilterProcNameAndPorts[5], // false (non-matching) output
+			    beanShellFilterProcNameAndPorts[6]}; // true (matching) output
     }
     
     private String[] createXrefParser(MobyNamespace nsObj, String srcProcessor, String srcPort, 
@@ -1090,6 +1103,7 @@
 	throws Exception{
 
 	String decompKey = srcProcessor+"\n"+srcPort+"\n"+xpath;
+	System.err.println("Decomp key is " + decompKey);
 	// Has this decomp already been created in another branch?
 	if(decomp2Processor.containsKey(decompKey)){
 	    return decomp2Processor.get(decompKey);
@@ -1108,7 +1122,7 @@
 						    beanShellFilterProcNameAndPorts[0], 
 						    beanShellFilterProcNameAndPorts[2],
 						    doc)); 
-	String[] procSpec =  new String[]{beanShellFilterProcNameAndPorts[0], beanShellFilterProcNameAndPorts[3]};
+	String[] procSpec = new String[]{beanShellFilterProcNameAndPorts[0], beanShellFilterProcNameAndPorts[3]};
 	decomp2Processor.put(decompKey, procSpec); //in case we need to reuse it in another branch
 	return procSpec;
     }
@@ -1453,10 +1467,12 @@
 	inputTypes.put("case_sensitive", "text/plain");
 	Map<String,String> outputsMap = new LinkedHashMap<String,String>();
 	if(listDepth == 0){
-	    outputsMap.put("matchCount", "0");
+	    outputsMap.put("FALSE_matchCount", "0");
+	    outputsMap.put("TRUE_matchCount", "0");
         }
         else{
-            outputsMap.put("nodelistAsXML", ""+listDepth);
+            outputsMap.put("FALSE_nodelistAsXML", ""+listDepth);
+            outputsMap.put("TRUE_nodelistAsXML", ""+listDepth);
         }
 
 	return addBeanShell(beanShellProcName, "cross",
@@ -1991,8 +2007,9 @@
 	    }
 	    regexFilterScript = HTMLUtils.getURLContents(scriptURL);
 	}
-	if(listDepth == 0){// list to scalar conversion
-	    return regexFilterScript+"\nString matchCount = \"\"+nodelistAsXML.size();";
+	if(listDepth == 0){// list to scalar conversions
+	    return regexFilterScript+"\nString TRUE_matchCount = \"\"+TRUE_nodelistAsXML.size();\n"+
+		                     "\nString FALSE_matchCount = \"\"+FALSE_nodelistAsXML.size();\n";
         }
         else{
  	    return regexFilterScript;

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java	2010/04/09 15:57:46	1.2
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataUtils.java	2010/04/10 00:40:17	1.3
@@ -117,7 +117,8 @@
 		    if(newFilter != null){
 			XPathOption xsel = newFilter.getSelectedXPath();
 			newProvenanceData += "\t"+newFilter.getFilterRegex()+
-			    "\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+newFilter.getCaseSensitivity();
+			    "\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+
+			    newFilter.getCaseSensitivity()+"\t"+newFilter.getSelectionInversed();
 		    }
 		    pi.setData(attr_val[0]+"=\""+newProvenanceData+"\"");
 		}
@@ -640,7 +641,8 @@
 	
 	if(fs != null && fs.getFilterRegex().length() > 0){
 	    XPathOption xsel = fs.getSelectedXPath();
-	    userData.append("\t"+fs.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+fs.getCaseSensitivity());
+	    userData.append("\t"+fs.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+
+			    fs.getCaseSensitivity()+"\t"+fs.getSelectionInversed());
 	}
 	mobyData.setUserData(userData.toString());
     }
@@ -653,7 +655,8 @@
 	String filterSpec = "";
 	if(filter != null && filter.getFilterRegex().length() > 0){
 	    XPathOption xsel = filter.getSelectedXPath();
-	    filterSpec = "\t"+filter.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+filter.getCaseSensitivity();
+	    filterSpec = "\t"+filter.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()+"\t"+
+		filter.getCaseSensitivity()+"\t"+filter.getSelectionInversed();
 	}
 	if(mdi.getUserData() != null){
 	    mdi.setUserData(mdi.getUserData().toString()+"\t"+conditionalOutputURL+filterSpec);

===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java	2010/04/09 15:48:19	1.3
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java	2010/04/10 00:40:17	1.4
@@ -21,6 +21,7 @@
 
     private URL docURL;
     private boolean caseSensitivity = false;
+    private boolean inverseSelection = false;
     private StringBuffer filterRegex;
     private Vector<XPathOption> xpathOptions;
     private int xpathSelected = 0;
@@ -74,6 +75,14 @@
 	}
     }
 
+    public boolean getSelectionInversed(){
+	return inverseSelection;
+    }
+
+    public void setSelectionInversed(boolean inversed){
+	inverseSelection = inversed;
+    }
+
     public boolean getCaseSensitivity(){
 	return caseSensitivity;
     }




More information about the MOBY-guts mailing list