[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Dec 6 23:36:21 UTC 2007


gordonp
Thu Dec  6 18:36:21 EST 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services
In directory dev.open-bio.org:/tmp/cvs-serv31080/src/main/ca/ucalgary/services

Modified Files:
	ACDService.java 
Log Message:
Added ArrayList typecheck, and improved handling of fixed values for normally primary ACD inputs
moby-live/Java/src/main/ca/ucalgary/services ACDService.java,1.4,1.5
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java	2007/07/30 13:54:05	1.4
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/ACDService.java	2007/12/06 23:36:21	1.5
@@ -309,12 +309,15 @@
     private String runProgram(MobyDataJob request, String[] command, File workingDir, final byte[] input) throws Exception{
 	// Ensure $embossRootDirName/lib is in the LD_LIBRARY_PATH, 
 	// what is the equivalent in Windows?  Windows searches just PATH...
+	// PATH should therefore include the lib and bin dirs of EMBOSS (bin because
+	// programs like emma call other programs such as clustalw
 	String libDir = embossRootDirName+File.separator+"lib";
+	String binDir = programBinaryFile.getParent();
 	final Process process = runtime.exec(command, 
 					     new String[]{"EMBOSS="+embossRootDirName,
 							  "EMBOSS_ACDROOT="+acdRootDirName,
 					                  "LD_LIBRARY_PATH="+libDir,
-					                  "PATH="+libDir},
+					                  "PATH="+libDir+File.pathSeparator+binDir},
 					     workingDir);
 	final OutputStream stdin = process.getOutputStream();
 	final InputStream stderr = process.getErrorStream();
@@ -737,11 +740,15 @@
     protected void configureServiceFromACDInput(MobyService service, 
 						List<Map<String,String>> spec) throws Exception{
 	MobyPrimaryData[] mobyInputTypes = service.getPrimaryInputs();
-	Map<String,MobyPrimaryData> paramUnused = new HashMap<String,MobyPrimaryData>();
+	Map<String,MobyData> paramUnused = new HashMap<String,MobyData>();
 
 	for(MobyPrimaryData mobyPrimaryInput: mobyInputTypes){
 	    paramUnused.put(mobyPrimaryInput.getName(), mobyPrimaryInput);
 	}
+	// There is a chance that the input was fixed as a secondary
+	for(MobySecondaryData mobySecondaryInput: service.getSecondaryInputs()){
+	    paramUnused.put(mobySecondaryInput.getName(), mobySecondaryInput);
+	}	
 
 	for(MobyData acdInput: specToMoby(spec)){
 	    if(acdInput instanceof MobyPrimaryData){
@@ -757,31 +764,37 @@
 					") does not have a matching declaration in the " +
 					"servlet configuration ( "+declInputNames+")");
 		}
+		MobyData mobyPrimaryInput = paramUnused.get(acdInputName);
+		// A fixed value was given rather than supplying a param...
+		if(paramUnused.get(acdInputName) instanceof MobySecondaryData){
+		    paramUnused.remove(acdInputName);
+		    continue;
+		}
 
-		MobyPrimaryData mobyPrimaryInput = paramUnused.get(acdInputName);
-		if(!textClient.canProduceTextTypeFromMoby(acdTypes.get(acdInputName), mobyPrimaryInput)){
+		if(!textClient.canProduceTextTypeFromMoby(acdTypes.get(acdInputName), 
+							  (MobyPrimaryData) mobyPrimaryInput)){
 		    throw new Exception("No XSLT rules exist that can produce the requested " +
 					"text type '" + acdTypes.get(acdInputName) + 
 					"' (acd input parameter " + acdInputName + 
 					") from the given MOBY object type (" + 
-					mobyPrimaryInput.getDataType().getName()+")");
+					((MobyPrimaryData) mobyPrimaryInput).getDataType().getName()+")");
 		}
 
 		// If it exists, make sure it's of the right type
 		if(acdInput instanceof MobyPrimaryDataSimple &&
 		   paramUnused.get(acdInputName) instanceof MobyPrimaryDataSet){
-		    throw new Exception("The MOBY input parameter \""+acdInputName+
-					"\" is a Collection, but the ACD input parameter is " +
-					"a simple (expected a declaration like \""+acdInputName+":"+
-					""+
-					paramUnused.get(acdInputName).getDataType().getName()+
+		    System.err.println("Potential issue: The MOBY input parameter \""+acdInputName+
+					"\" is a Collection, but the ACD input parameter appears " +
+					"to be a simple (expected a declaration like \""+acdInputName+":"+
+					((MobyPrimaryData) paramUnused.get(acdInputName)).getDataType().getName()+
 					"\")");
 		}
 		paramUnused.remove(acdInputName);
 	    }
 	    // Secondary params read from the ACD spec always get included
 	    else if(acdInput instanceof MobySecondaryData){
-		service.addInput(acdInput);	      
+		service.addInput(acdInput);
+		paramUnused.remove(acdInput.getName());
 	    }
 	    else{		
 		throw new Exception("While parsing ACD input section: input field was not interpreted as " +
@@ -802,7 +815,7 @@
     
     protected void configureServiceFromACDParams(MobyService service,
 						 List<Map<String,String>> spec) throws Exception{
-	List<MobySecondaryData> paramTypes = new ArrayList();
+	List<MobySecondaryData> paramTypes = new ArrayList<MobySecondaryData>();
 	for(MobyData param: specToMoby(spec)){
 	    if(!(param instanceof MobySecondaryData)){		
 		throw new Exception("While parsing ACD input section: parameter field was not interpreted as " +
@@ -892,7 +905,7 @@
 	    String additional = block.get("additional");
 	    String deFault = block.get("default");
 	    //System.err.println("param: " + acdName + "/" + acdType +" " + additional +" ("+deFault+")");
-	    if((additional != null && additional.toUpperCase().equals("Y")) ||
+	    if((additional != null && !additional.toUpperCase().equals("N")) ||
 	       deFault != null){
 		if("boolean".equals(acdType) || "toggle".equals(acdType)){
 		    MobySecondaryData bool = new MobySecondaryData(acdName);
@@ -936,12 +949,15 @@
 		    mobyDataType = floating;
 		}
 		else{
-		    System.err.println("Skipping secondary parameter that is not a primitive in MOBY:" + acdType);
-		    continue;
+		    // If non-secondary with a default value, this is weird
+		    if(deFault.length() != 0){
+			System.err.println("Found secondary parameter that is not a primitive in MOBY:" + acdType);
+		    }
+		    //continue;  fall through to mobyDataType == null (Primary parameter)
 		}
 	    }  //end if(additional)
 	    // else it's a required parameter
-	    else{
+	    if(mobyDataType == null){
 		// If it's an input or output parameter, just fill in a basic object to keep
 		// track if the name of the ACD parameter and whether it's a collection or not.
 		// The calling methods must make sure these match the MOBY service description provided
@@ -978,6 +994,13 @@
 
     private void processACDList(MobySecondaryData param, String values, 
 				String itemDelim, String tagValueDelim){
+	// Sometimes, delimiters are not given in the ACD file, use the defaults instead
+	if(tagValueDelim == null){
+	    tagValueDelim = ":";
+	}
+	if(itemDelim == null){
+	    itemDelim = ",";
+	}
 	for(String item: values.split(itemDelim)){
 	    String[] tagValuePair = item.split(tagValueDelim);
 	    param.addAllowedValue(tagValuePair[0].trim());




More information about the MOBY-guts mailing list