[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Wed Apr 18 16:01:00 UTC 2007


gordonp
Wed Apr 18 12:01:00 EDT 2007
Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services
In directory dev.open-bio.org:/tmp/cvs-serv12392/src/main/ca/ucalgary/seahawk/services

Modified Files:
	MobyClient.java 
Log Message:
Made less verbose, fixed binary data search pass-through for non-binary data
moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.10,1.11
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java	2007/04/08 17:26:24	1.10
+++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java	2007/04/18 16:01:00	1.11
@@ -554,10 +554,14 @@
     public MobyDataInstance getMobyObject(Map<String, byte[]> resultParts, MobyPrimaryData dataTemplate) 
 	throws Exception, MobyServiceException{
 	Vector<MobyDataObject> results = new Vector<MobyDataObject>();
+
+	// System.err.println("Data has " + resultParts.size()  + " parts");
 	// The output parameter *potentially* has multiple parts 
-	// (e.g. multiple .png file from EMBOSS's "banana" program)
+	// (e.g. multiple .png files from EMBOSS's "banana" program)
 	// hence the nested for loops (part iteration, followed by created-object iteration)
 	for(String resultPartName: resultParts.keySet()){
+
+	    //System.err.println("About to check part "+ resultPartName);
 	    for(MobyDataObject resultPart: getMobyObjects(resultParts.get(resultPartName), dataTemplate.getDataType())){
 		// Maintain the name for the object in the collection, as banana.1.png, banana.2.png, etc.
 		// is useful information for the end-user for making sense of them together! (left to right)
@@ -608,10 +612,17 @@
 	}
 	else if(results.size() > 1){
 	    if(dataTemplate instanceof MobyPrimaryDataSimple){
-		System.err.println("The data map provided " +
-				   "was a collection, but the request was to return a simple. " +
+		// In this case, eliminate any higher-up objects that 
+		// have the exact same contents as the same members who are their
+		// subtypes, as these are superfluous.
+
+		System.err.println("Multiple Moby objects were found in the text data, " +
+				   "but the request was to return a simple. " +
 				   "Only the first value in the collection has been returned.");
-		// TODO: should we instead return the one deepest in the heirarchy (or with the most members)?
+		for(MobyDataObject result: results){
+		    System.err.println("Found object: " + result.getDataType().getName()); 
+		}
+		// TODO: should we instead return the one deepest in the hierarchy (or with the most members)?
 		return results.elementAt(0);
 	    }
 	    else{
@@ -647,8 +658,11 @@
     public MobyDataObject[] getMobyObjects(byte[] rawData, MobyDataType targetDataType){
 	// Only do the magic check if the target data type inherits from MOBY's base64 class (i.e. might encode binary data)
 	if(!targetDataType.inheritsFrom(MobyDataType.getDataType(MobyDataBytes.BASE64_DATATYPE))){
-	    return getMobyObjects(new String(rawData));
+	    //System.err.println("Data type does not inerit from Base64, continuing with string-based search...");
+	    return getMobyObjects(new String(rawData), targetDataType);
 	}
+	//System.err.println("Data type " + targetDataType.getName() + " inherits from " + MobyDataBytes.BASE64_DATATYPE +
+	//		   ", continuing with byte-based search...");
 
 	String rawDataAsString = null;
 
@@ -656,18 +670,22 @@
 
 	for(Pattern pattern: regexMap.keySet()){
 	    MobyComplexBuilder rule = regexMap.get(pattern);
+	    //System.err.print("Checking" + rule.getDataType().getName()+":");
+	    //for(MobyDataType parent: rule.getDataType().getLineage()){System.err.print(" " + parent.getName());}
+	    //System.err.println("");
 	    if(rule.getDataType().inheritsFrom(targetDataType)){
+		//System.err.println("Checking rule that generates data type " +  rule.getDataType().getName());
 		// Only build the string representation of the byte array if we
 		// found a rule that applies (since it's a somewhat expensive operation
 		// to do the conversion)
 		if(rawDataAsString == null){
 		    rawDataAsString = bytesToString(rawData);
-		    System.err.println("Start of data is " + rawDataAsString.substring(0, 4));
+		    //System.err.println("Start of data is " + rawDataAsString.substring(0, 4));
 		}
 		Matcher matcher = pattern.matcher(rawDataAsString);
 
 		while(matcher.find()){
-		    System.err.println("Found match for binary data");
+		    //System.err.println("Found match for binary data");
 		    try{
 			MobyDataObject mobyObj = rule.apply(matcher, rawData);
 			if(mobyObj != null){




More information about the MOBY-guts mailing list